服务器环境搭建方法记录
2017-09-15 14:13
211 查看
jdk安装
1.在/usr/local/下创建java文件夹mkdir java
2.将jdk-8u111-linux-x64.tar.gz移动到java文件夹里
cp jdk-8u111-linux-x64.tar.gz ../java/
3.解压jdk到java
tar -zxvf jdk-8u111-linux-x64.tar.gz
4.安装完毕建立链接以节省目录长度
ln -s /usr/local/java/jdk1.8.0_111/ /usr/jdk
5.编辑配置文件,配置环境变量
vim /etc/profile 添加如下内容: JAVA_HOME=/usr/jdk CLASSPATH=$JAVA_HOME/lib/ PATH=$PATH:$JAVA_HOME/bin export PATH JAVA_HOME CLASSPATH
6.执行命令
source /etc/profile
7.查看安装情况
java -version java version "1.8.0_111" Java(TM) SE Runtime Environment (build 1.8.0_111-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
安装完毕
nginx安装
1.安装opensslyum -y install openssl*
2.安装pcre
#查看是否已经安装了pcre rpm -qa | grep pcre #如果存在,则删除已经安装的pcre(最好不要用系统自带的pcre, #因为后面会报错 #./configure: error: the HTTP rewrite module requires the PCRE library.) rpm -e --nodeps pcre-7.8-7.el6.x86_64 #然后安装pcre yum install pcre*
3.解压nginx
#路径位置/usr/local/src/nginx-1.11.5.tar.gz tar -zxvf nginx-1.11.5.tar.gz #将解压后的文件移动到上一层 mv nginx-1.11.5 ../nginx
4.执行安装前的检查配置
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre
5.执行完毕,如果没有error,则可以打印出:
... checking for struct dirent.d_namlen ... not found checking for struct dirent.d_type ... found checking for sysconf(_SC_NPROCESSORS_ONLN) ... found checking for openat(), fstatat() ... found checking for getaddrinfo() ... found checking for PCRE library ... found checking for PCRE JIT support ... not found checking for OpenSSL library ... found checking for zlib library ... found creating objs/Makefile Configuration summary + using system PCRE library + using system OpenSSL library + using system zlib library nginx path prefix: "/home/nginx-1.11.5" nginx binary file: "/home/nginx-1.11.5/sbin/nginx" nginx modules path: "/home/nginx-1.11.5/modules" nginx configuration prefix: "/home/nginx-1.11.5/conf" nginx configuration file: "/home/nginx-1.11.5/conf/nginx.conf" nginx pid file: "/home/nginx-1.11.5/logs/nginx.pid" nginx error log file: "/home/nginx-1.11.5/logs/error.log" nginx http access log file: "/home/nginx-1.11.5/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"
6.然后编译
make
执行结束,如下
... objs/src/http/modules/ngx_http_uwsgi_module.o \ objs/src/http/modules/ngx_http_scgi_module.o \ objs/src/http/modules/ngx_http_memcached_module.o \ objs/src/http/modules/ngx_http_empty_gif_module.o \ objs/src/http/modules/ngx_http_browser_module.o \ objs/src/http/modules/ngx_http_upstream_hash_module.o \ objs/src/http/modules/ngx_http_upstream_ip_hash_module.o \ objs/src/http/modules/ngx_http_upstream_least_conn_module.o \ objs/src/http/modules/ngx_http_upstream_keepalive_module.o \ objs/src/http/modules/ngx_http_upstream_zone_module.o \ objs/src/http/modules/ngx_http_stub_status_module.o \ objs/ngx_modules.o \ -ldl -lpthread -lcrypt -lpcre -lssl -lcrypto -ldl -lz \ -Wl,-E sed -e "s|%%PREFIX%%|/home/nginx-1.11.5|" \ -e "s|%%PID_PATH%%|/home/nginx-1.11.5/logs/nginx.pid|" \ -e "s|%%CONF_PATH%%|/home/nginx-1.11.5/conf/nginx.conf|" \ -e "s|%%ERROR_LOG_PATH%%|/home/nginx-1.11.5/logs/error.log|" \ < man/nginx.8 > objs/nginx.8 make[1]: Leaving directory `/usr/local/nginx'
然后执行安装命令
make install
执行结束,如下:
... cp conf/uwsgi_params \ '/home/nginx-1.11.5/conf/uwsgi_params.default' test -f '/home/nginx-1.11.5/conf/scgi_params' \ || cp conf/scgi_params '/home/nginx-1.11.5/conf' cp conf/scgi_params \ '/home/nginx-1.11.5/conf/scgi_params.default' test -f '/home/nginx-1.11.5/conf/nginx.conf' \ || cp conf/nginx.conf '/home/nginx-1.11.5/conf/nginx.conf' cp conf/nginx.conf '/home/nginx-1.11.5/conf/nginx.conf.default' test -d '/home/nginx-1.11.5/logs' \ || mkdir -p '/home/nginx-1.11.5/logs' test -d '/home/nginx-1.11.5/logs' \ || mkdir -p '/home/nginx-1.11.5/logs' test -d '/home/nginx-1.11.5/html' \ || cp -R html '/home/nginx-1.11.5' test -d '/home/nginx-1.11.5/logs' \ || mkdir -p '/home/nginx-1.11.5/logs' make[1]: Leaving directory `/usr/local/nginx'
redis安装
1.解压redis-3.2.5.tartar -xvf redis-3.2.5.tar #移动到/usr/local/下 mv redis-3.2.5 ../redis
2.检查 gcc 是否已安装. 直接命令:gcc 看是否已经安装.
yum install gcc
3.redis目录编译
make
4.make test报错
make[1]: Entering directory `/usr/local/redis/src' You need tcl 8.5 or newer in order to run the Redis test
解决办法:
yum install -y tcl
kafka配置
单台服务器启动一个broker配置1.下载kafka_2.11-0.10.1.0.tar包
2.解压到目录/usr/local/kafka
3.修改config/server.properties
... #单机一台broker broker.id=0 #服务器内网Ip host.name=xxx.xxx.xxx.xxx ...
4.启动
#先启动zookeeper bin/zookeeper-server-start.sh config/zookeeper.properties & #然后启动kafka nohup bin/kafka-server-start.sh config/server.properties >/home/start-kafka.nohup 2>&1 &
5.创建topic
bin/kafka-topics.sh --create --zookeeper [本机内网ip]:2181 --replication-factor 1 --partitions 1 --topic [topic名称] #replication factor 控制消息保存在几个broker(服务器)上,一般情况下等于broker的个数。 #partitions :分区数,控制topic将分片成多少个log。可以显示指定,如果不指定则会使用broker(server.properties)中的num.partitions配置的数量
单台服务器启动多个broker配置
例举一台服务器创建3个broker
1-2步同上
3.创建3个server.properties,如:server.properties、server1.properties、server2.properties
server.properties:(默认端口)
... broker.id=0 host.name=[内网ip] ...
server1.properties:(9093端口)
... broker.id=1 host.name=[内网ip] port=9093 ...
server2.properties:(9094端口)
... broker.id=2 host.name=[内网ip] port=9094 ...
4.启动
#先启动zookeeper bin/zookeeper-server-start.sh config/zookeeper.properties & #然后启动kafka nohup bin/kafka-server-start.sh config/server-1.properties >/home/start-kafka-1.nohup 2>&1 & nohup bin/kafka-server-start.sh config/server-2.properties >/home/start-kafka-2.nohup 2>&1 & nohup bin/kafka-server-start.sh config/server.properties >/home/start-kafka.nohup 2>&1 &
5.创建topic
bin/kafka-topics.sh --create --zookeeper [服务器内网ip]:2181 --replication-factor 3 --partitions 1 --topic [topic名称] #replication factor 控制消息保存在几个broker(服务器)上,一般情况下等于broker的个数。 #partitions :分区数,控制topic将分片成多少个log。可以显示指定,如果不指定则会使用broker(server.properties)中的num.partitions配置的数量
kafka多节点多broker集群
举例3台
每台都需要装zookeeper和kafka
1.zookeeper配置
节点1 conf/zoo.cfg :
... #自己设路径 dataDir=/work/kafka/zkpdata #自己设路径 dataLogDir=/work/kafka/zkplog server.1=[节点1内网ip地址]:2888:3888 server.2=[节点2内网ip地址]:2888:3888 server.3=[节点3内网ip地址]:2888:3888 ...
修改/work/kafka/zkpdata/myid值为1
节点2 conf/zoo.cfg 同上
修改/work/kafka/zkpdata/myid值为2
节点3 conf/zoo.cfg 同上
修改/work/kafka/zkpdata/myid值为3
2.kafka配置
1.节点1 server.properties:
... broker.id=1 host.name=[内网ip] ... zookeeper.connect=[节点1内网ip]:2181,[节点2内网ip]:2181,[节点3内网ip]:2181 zookeeper.connection.timeout.ms=6000 ...
2.节点2 server.properties:
... broker.id=2 host.name=[内网ip] ... zookeeper.connect=[节点1内网ip]:2181,[节点2内网ip]:2181,[节点3内网ip]:2181 zookeeper.connection.timeout.ms=6000 ...
3.节点3 server.properties:
... broker.id=3 host.name=[内网ip] ... zookeeper.connect=[节点1内网ip]:2181,[节点2内网ip]:2181,[节点3内网ip]:2181 zookeeper.connection.timeout.ms=6000 ...
4.创建topic
bin/kafka-topics.sh --create --zookeeper [节点1内网ip]:2181,[节点2内网ip]:2181,[节点3内网ip]:2181 --replication-factor 3 --partitions 1 --topic [topic名称] #replication factor 控制消息保存在几个broker(服务器)上,一般情况下等于broker的个数。 #partitions :分区数,控制topic将分片成多少个log。可以显示指定,如果不指定则会使用broker(server.properties)中的num.partitions配置的数量
5.启动
三台依次启动
#先启动zookeeper bin/zkServer.sh start conf/zoo.cfg & #然后启动kafka bin/kafka-server-start.sh config/server.properties >/work/start-kafka.nohup 2>&1 &
相关文章推荐
- 一次服务器环境搭建的记录(nginx+php+subversion)
- 解决在DHCP环境下私自指定IP和私自搭建DHCP服务器的方法
- 搭建PHP5.4+Apache+Mysql 服务器环境配置方法
- nfs服务器的简单搭建过程-记录方法
- 解决在DHCP环境下私自指定IP和私自搭建DHCP服务器的方法
- unix网络编程各种TCP客户-服务器程序设计实例附环境搭建和编译方法(一)
- 服务器环境搭建过程记录贴
- windows搭建PHP服务器环境最容易的方法
- unix网络编程各种TCP客户-服务器程序设计实例附环境搭建和编译方法(一)
- PHP开发框架HushFrameword在阿里服务器Windows Server2012上的环境搭建正确方法
- 搭建PHP5.4+Apache+Mysql 服务器环境配置的方法
- Centos7.3服务器搭建LNMP环境的方法
- 利用nodeJs anywhere搭建本地服务器环境的方法
- Windows Server 2016 服务器配置指南之PHP7运行环境搭建方法
- Windows Server 2016 服务器配置指南 之 MariaDB数据库环境搭建方法
- VM 安装Linux虚拟服务器:环境搭建遇到:《Linux “ifconfig”看不到inet address》问题--解决土方法
- 记录阿里云ECS服务器Java开发环境的搭建过程
- [环境搭建]-Web Api搭建到IIS服务器后PUT请求返回HTTP Error 405.0 - Method Not Allowed 解决方法
- svn服务器环境搭建个人记录
- Android NDK开发环境搭建与软件优化方法记录