0条评论
还没有人评论过~
centos7
zookeeper-3.5.2
三台虚拟机:master、slaves1、slaves2
#数据目录. 可以是任意目录,其中的dataDir目录和dataLogDir需要提前建立好
#注意 应该谨慎地选择日志存放的位置,使用专用的日志存储设备能够大大地提高系统的性能,如果将日志存储在比较繁忙的存储设备上,那么将会在很大程度上影响系统的性能。
dataDir=/opt/softWare/zookeeper/data/zookeeper
#log目录, 同样可以是任意目录. 如果没有设置该参数, 将使用和dataDir相同的设置,其中的dataDir目录和dataLogDir需要提前建立好
#注意 应该谨慎地选择日志存放的位置,使用专用的日志存储设备能够大大地提高系统的性能,如果将日志存储在比较繁忙的存储设备上,那么将会在很大程度上影响系统的性能。
dataLogDir=/opt/softWare/zookeeper/logs/zookeeper
#在之前设置的dataDir中新建myid文件, 写入一个数字, 该数字表示这是第几号server. 该数字必须和zoo.cfg文件中的server.X中的X一一对应.
server.1=master_ip:2888:3888
server.2=slaves1_ip:2888:3888
server.3=slaves2_ip:2888:3888
[root@master zookeeper]# mkdir -p data/zookeeper
[root@master zookeeper]# mkdir -p logs/zookeeper
scp -r zookeeper slaves1:/opt/softWare/
scp -r zookeeper slaves2:/opt/softWare/
在每个节点的/opt/softWare/zookeeper/data/zookeeper下新建一个名字为myid的文件,并且在第一行写入id,id分别对应server.n=localhost:2887:3887中的n。
vim /etc/profile
#set ZK env
export ZK_HOME=/opt/softWare/zookeeper/zookeeper-3.5.2
export PATH=${ZK_HOME}/bin:$PATH
source /etc/profile
[root@master ~]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/softWare/zookeeper/zookeeper-3.5.2/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@slaves1 ~]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/softWare/zookeeper/zookeeper-3.5.2/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@slaves2 ~]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/softWare/zookeeper/zookeeper-3.5.2/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@master ~]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/softWare/zookeeper/zookeeper-3.5.2/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: follower
[root@slaves1 ~]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/softWare/zookeeper/zookeeper-3.5.2/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: leader
[root@slaves2 ~]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/softWare/zookeeper/zookeeper-3.5.2/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: follower
来源:oschina
链接:https://my.oschina.net/u/4474619/blog/4326673