Zookeeper部署完全分布式
Zookeeper搭建规划
192.168.230.10/node1 192.168.230.11/node2 192.168.230.12/node3 192.168.230.14/node4
1、上传Zookeeper压缩文件到Linux主机的指定目录下
2、解压Zookeeper压缩文件
[root@node1 software]# tar -zxf zookeeper-3.4.6.tar.gz -C /opt/modules
3、进入/opt/modules目录下将zookeeper-3.4.6目录重命名为zookeeper
[root@node1 modules]# mv zookeeper-3.4.6 zookeeper
4、进入zookeeper文件夹,创建data和logs创建目录并赋于写权限,用于指定zookeeper的数据存放目录和日志目录
[root@node1 ~]# cd /opt/modules/zookeeper
[root@node1 zookeeper]# mkdir data
[root@node1 zookeeper]# mkdir logs
[root@node1 ~]# cd /opt/modules/zookeeper/conf
[root@node1 conf]# cp zoo_sample.cfg zoo.cfg
[root@node1 conf]# ll
total 16
-rw-rw-r-- 1 1000 1000 535 Feb 20 2014 configuration.xsl
-rw-rw-r-- 1 1000 1000 2161 Feb 20 2014 log4j.properties
-rw-r--r-- 1 root root 922 Mar 7 13:46 zoo.cfg
-rw-rw-r-- 1 1000 1000 922 Feb 20 2014 zoo_sample.cfg
dataDir=/opt/modules/zookeeper/data
dataLogDir=/opt/modules/zookeeper/logs
server.1=192.168.230.10:2888:3888
server.2=192.168.230.11:2888:3888
server.3=192.168.230.12:2888:3888
server.4=192.168.230.14:2888:3888
5、进入data文件夹 建立对应的myid文件
[root@node1 ~]# cd /opt/modules/zookeeper/data
[root@node1 data]# vi myid
1
6、拷贝zookeeper文件夹到其他机器node2(192.168.230.11)、node3(192.168.230.12)、node5(192.168.230.14)上
[root@node1 ~]# scp -r /opt/modules/zookeeper root@node2:/opt/modules/zookeeper/
[root@node1 ~]# scp -r /opt/modules/zookeeper root@node3:/opt/modules/zookeeper/
[root@node1 ~]# scp -r /opt/modules/zookeeper root@node5:/opt/modules/zookeeper/
7、修改其他机器node2(192.168.230.11)、node3(192.168.230.12)、node5(192.168.230.14)上的myid文件
[root@node2 ~]# cd /opt/modules/zookeeper/data
[root@node2 data]# vi myid
2
[root@node3 ~]# cd /opt/modules/zookeeper/data
[root@node3 data]# vi myid
3
[root@node5 ~]# cd /opt/modules/zookeeper/data
[root@node5 data]# vi myid
4
8、分别启动四台机器的zookeeper
[root@node1 data]# cd /opt/modules/zookeeper
[root@node1 zookeeper]# ./bin/zkServer.sh start
查看zookeeper的状态
[root@node1 zookeeper]# ./bin/zkServer.sh status
[root@node2 data]# cd /opt/modules/zookeeper
[root@node2 zookeeper]# ./bin/zkServer.sh start
查看zookeeper的状态
[root@node2 zookeeper]# ./bin/zkServer.sh status
[root@node3 data]# cd /opt/modules/zookeeper
[root@node3 zookeeper]# ./bin/zkServer.sh start
查看zookeeper的状态
[root@node3 zookeeper]# ./bin/zkServer.sh status
[root@node5 data]# cd /opt/modules/zookeeper
[root@node5 zookeeper]# ./bin/zkServer.sh start
查看zookeeper的状态
[root@node5 zookeeper]# ./bin/zkServer.sh status