Zookeeper installation
1. Installation
wget http://www.apache.org/dist//zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz
Tar zxvf zookeeper-3.3.6.tar.gz
MV zookeeper-3.3.6/usr/local/zookeeper-3.3.6-2181
cd/usr/local/zookeeper-3.3.6-2181
CP Conf/zoo_sample.cfg Conf/zoo.cfg
2. Single-instance configuration modification configuration file
VI conf/zoo.cfg
#心跳时间
ticktime=2000
initlimit=10
Synclimit=5
#数据保存目录
datadir=/data/zhanglin/logistics/zookeeper-3.3.6
#客户端连接端口
clientport=2181
Increase memory
zkenv.sh
zkenv.sh
#在文件底部增加
Export jvmflags= "-xms1024m-xmx2048m $JVMFLAGS"
Querying memory size
Ps-ef|grep Zookeeper
#查询pid
3. Cluster configuration
Note: Where the data directory and server address need to be changed to the information of your actual deployment machine
Modifying a configuration file
VI conf/zoo.cfg
ticktime=2000
#连接leader的等待的最长时间 (seconds)
initlimit=10
#标识 Leader and Follower send messages, request and answer for the longest time
Synclimit=5
datadir=/data/zhanglin/logistics/zookeeper-3.3.6
clientport=2181
#server. A=b:c:d: Where A is a number indicating this is the first server, B is the IP address of this server, and C is the port that the server exchanges information with the Leader server in the cluster;
D means that in case the #Leader server in the cluster is hung up, a port is needed to re-elect a new Leader, which is the port that the server communicates with each other when the election is performed.
If it is a pseudo-cluster configuration, because B is the same, so different #Zookeeper instance communication port numbers can not be the same, so they should be assigned a different port number.
server.1=10.0.30.138:2555:3555
server.2=10.0.30.139:2555:3555
Add myID file
and place the myID file in the Data directory: (DataDir in the zoo.cfg above)
mkdir data
VI myID
myID indicates its own ID, corresponding to the server in zoo.cfg above. After the number, the content of the first is 1, the second set is 2, the contents are as follows:
myID
1
4. Start
./bin/zkserver.sh Start
5. Stop
./bin/zkserver.sh Stop
Note: command-line Reference (see:http://zookeeper.apache.org/doc/r3.3.6/zookeeperadmin.html)
6. Verify the Startup status
Telnet 127.0.0.1 2181
7. Usage
dubbo.registry.address=zookeeper://10.0.30.138:2181?backup=10.0.30.139:2181
Or
8. Test ZK Service
Execute $ zkcli.sh-server 10.0.30.138:2181 to check if the specified server started successfully.
Here's a case for my stand-alone 3 pseudo-clusters:
(1). Install the zookeeper on three machines, preferably in the same version.
Direct CP Three can be, make a mark, easy to distinguish.
(2). Modify the configuration file as follows
VI conf/zoo.cfg
Below is a sample of three node configuration files
1
2
3
Note: Where the data directory and server address need to be changed to the information of your actual deployment machine
(3). Add myID file
and place the myID file in the Data directory: (DataDir in the zoo.cfg above)
#cd/data/retail/zookeeper/
VI myID
myID indicates its own ID, corresponding to the server in the above zoo.cfg. The first set of contents is 1, the second one is 2, and so on.
Zookeeper Installation Deployment