临城网站建设,北京市住房与城乡建设部网站,网站设计制作哪个好,免费模板app下载前置环境
三台centos7服务器
192.168.2.201
192.168.2.202
192.168.2.150三台服务器都需要安装jdk1.8以上zookeeper安装包
安装jdk
在单机模式已经描述过#xff0c;这里略过#xff0c;有需要可以去看单机模式中的这部分#xff0c;注意的是三台服务器都需要安装
安装…前置环境
三台centos7服务器
192.168.2.201
192.168.2.202
192.168.2.150三台服务器都需要安装jdk1.8以上zookeeper安装包
安装jdk
在单机模式已经描述过这里略过有需要可以去看单机模式中的这部分注意的是三台服务器都需要安装
安装zookeeper
当前在192.168.2.201上操作解压zookeeper安装包在安装目录下新建zkData目录
mkdir zkData修改修改conf/zoo.cfg文件 cp zoo_sample.cfg ./zoo.cfg修改zoo.cfg中的DataDir值 改为zkData所在的目录
dataDir/opt/software/zookeeper-3.4.6/zkData在zoo.cfg目录中添加集群信息server.x 中的x是代表这台主机的序号如server.1代表这台zookeeper的序号是1server.2代表这台zookeeper的序号是2server.3代表这台zookeeper的序号是3
server.1192.168.2.201:2888:3888
server.2192.168.2.202:2888:3888
server.3192.168.2.150:2888:3888
# 自动触动清楚任务时间间隔小时为单位默认为0表示不自动清除
autopurge.purgeInterval2
# 保存的快照数量之外的会被清除
autopurge.snapRetainCount5最终的zoo.cfg文件
[rootaiops-release conf]# cat zoo.cfg
# The number of milliseconds of each tick
tickTime2000
# The number of ticks that the initial
# synchronization phase can take
initLimit10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
#dataDir/tmp/zookeeper
# the port at which the clients will connect
#clientPort2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount3
# Purge task interval in hours
# Set to 0 to disable auto purge feature
#autopurge.purgeInterval1dataDir/opt/software/zookeeper-3.4.6/zkData
clientPort2181
server.1192.168.2.201:2888:3888
server.2192.168.2.202:2888:3888
server.3192.168.2.150:2888:3888
autopurge.purgeInterval2
autopurge.snapRetainCount5在zkData目录下创建myid文件,并写入1对应之前zoo.cfg中的server.1中的序号1
echo 1 myid配置环境变量
vim /etc/profile在文件底部添加zookeeper的安装目录
export ZOOKEEPER_HOME/opt/software/zookeeper-3.4.6
export PATH$PATH:$ZOOKEEPER_HOME/bin刷新配置文件
source /etc/profile复制整个zookeeper安装目录到其余两台服务器最好在相同目录
scp -r zookeeper-3.4.6/ root192.168.2.202:/目录/z/zookeeper-3.4.6/
scp -r zookeeper-3.4.6/ root192.168.2.150:/目录/z/zookeeper-3.4.6/修改192.168.2.202 和192.168.2.150中myid对应的值分别为2和3
192.168.2.202
echo 2 myid
192.168.2.150
echo 3 myid配置192.168.2.202 和192.168.2.150的环境变量并刷新与上面配置192.168.2.201时的步骤一致最终三台服务器都应该装有jdk1.8以及三台服务器中的zoo.cfg文件是一致的zkData中的myid分别为1,23与zoo.cfg中的配置的服务器编号对应
启动
依次启动三台服务器的zookeeper查看三台服务器的状态 192.168.2.150
[rootaiops-test bin]# ./zkServer.sh status
JMX enabled by default
Using config: /opt/software/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: leader192.168.2.202
[rootaiops-release bin]# ./zkServer.sh status
JMX enabled by default
Using config: /opt/software/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: follower192.168.2.201
[rootaiops bin]# ./zkServer.sh status
JMX enabled by default
Using config: /opt/software/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: follower