Linux Zookeeper cluster configuration
First, pre-preparation 1, download zookeeper installation package: Http://zookeeper.apache.org/releases.html 2, JDK installation: jdk-8u131-linux-x64.rpm Second, the creation of software storage directory: Zook 1, [[email protected]/soft/zook]# Mkdir/soft/zook
Third, change the name: Zookeeper-1 zookeeper-2 zookeeper-3 and so on 1, [[email protected]/soft/zook]# tar XF zookeeper-3.4.12.tar.gz 2, [ [Email protected]/soft/zook]# mv zookeeper-3.4.12 zookeeper-1 3, [[email protected]/soft/zook]# mv zookeeper-3.4.12 zo Okeeper-2 4, [[email protected]/soft/zook]# MV zookeeper-3.4.12 zookeeper-3 Four, copy the configuration file zoo_sample.cfg for zoo.cfg each directory to be copied. 1, [[email protected]/soft/zook]# CD zookeeper-1/conf && cp-rp zoo_sample.cfg zoo.cfg
V. Modify the port of the zoo.cfg (because I do a pseudo-cluster on a server), 1, [[email protected]/soft/zook/zookeeper-1/conf]# sed '/#.*$/d; /^ *$/d ' zoo.cfg
Six, the configuration in the configuration file here: 1, the port to change the same, or it will conflict, 2, in each configuration file to add the above configuration; Serevr.x=a:b:c 3, I put the data and log in each zook inside, so created a date and logs 4, you also want to create a myID file in the data file created 5, [[email protected]/soft/zook/zookeeper-1/data] #echo ' 1 ' >myid # #这里的 1 corresponds to the configuration file Zoo. The last side of the CFG server.x=a:b:c this x is 1, which is 1. 6, other zookeeper-2, zookeeper-3, Zookeeper-4, zookeeper-5, and other configuration are the same as the Zooleeper-1 configuration method, I do not say (nothing is the port and the myID is not the same).
Seven, start the cluster: 1, [[email protected]/soft/zook]# sh zookeeper-1/bin/zkserver.sh start 2, [[email protected]/soft/zook]# sh zookeeper-2/bin/zkserver.sh start 3, [[email protected]/soft/zook]# sh zookeeper-3/bin/zkserver.sh start 4, [[Email P Rotected]/soft/zook]# sh zookeeper-4/bin/zkserver.sh start 5, [[email protected]/soft/zook]# sh zookeeper-5/bin/zkserv er.sh start 6, can be viewed through Ps-ef |grep Zook
Eight, into the cluster: 1, [[email protected]/soft/zook]# sh zookeeper-1/bin/zkcli.sh-server 192.168.30.76
2, through the command to see which node is selected as follower or leader [[email protected]/soft/zook]# echo stat|nc 192.168.30.76 2181 [[email protected] /soft/zook]# echo stat|nc 192.168.30.76 2182 [[email protected]/soft/zook]# echo stat|nc 192.168.30.76 2183 [[Emai L protected]/soft/zook]# echo stat|nc 192.168.30.76 2184 [[email protected]/soft/zook]# echo STAT|NC 192.168.30.76 21 85 3, Output related service configuration details [[email protected]/soft/zook]# echo conf | NC 192.168.30.76 2181
Linux Zookeeper cluster configuration