3台服务器: 192.168.1.116 192.168.1.117 192.168.1.118
以192.168.1.116为例
(1)执行以下命令: cd /data/env wget http://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz tar -zxvf zookeeper-3.4.6.tar.gz cd zookeeper-3.4.6/ mkdir data mkdir dataLog
(2)上传zoo.cfg文件到/data/env/zookeeper-3.4.6/conf/目录下 内容如下:
# The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can take initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/data/env/zookeeper-3.4.6/data dataLogDir=/data/env/zookeeper-3.4.6/dataLog
# the port at which the clients will connect clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # 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.snapRetainCount=3 # Purge task interval in hours # Set to "0" to disable auto purge feature #autopurge.purgeInterval=1
server.1=192.168.1.116:2888:3888 server.2=192.168.1.117:2888:3888 server.3=192.168.1.118:2888:3888
(3)执行以下命令: cd /data/env/zookeeper-3.4.6/data echo 1 > myid
(4)将/data/env/zookeeper-3.4.6/目录复制到192.168.1.117的同样目录下, 修改/data/env/zookeeper-3.4.6/data/myid文件,内容改为数字2,请勿换行或多空格,只有一个数字。
(5)将/data/env/zookeeper-3.4.6/目录复制到192.168.1.118的同样目录下, 修改/data/env/zookeeper-3.4.6/data/myid文件,内容改为数字3,请勿换行或多空格,只有一个数字。
(6)修改3个服务器的防火墙设置,确保2181,2888,3888端口对外开放。
(6)3个服务器都执行以下命令: cd /data/env/zookeeper-3.4.6/bin ./zkServer.sh start
(7)3个服务器都启动后,都执行以下命令 ./zkServer.sh status
会显示类似如下的信息: ------ JMX enabled by default Using config: /data/env/zookeeper-3.4.6/bin/../conf/zoo.cfg Mode: follower ------ 确认两台服务器的Mode是follower,一台服务器的Mode是leader
(8)通知开发人员,进行验证,验证OK即安装完毕。 ------------------------------------- 简单的验证方式: ./zkCli.sh -server 192.168.1.115:2181 ls / create /test 123 get /test delete /test quit
|