ZooKeeper fully distributed installation and configuration
For more information about ZooKeeper, see the official website.
1. Environment Description
Install ZooKeeper on two servers with centos6.4 (32-bit). We recommend that you have at least three nodes on the official website and have limited resources. In this experiment, we will have two servers.
Jdk needs to be installed in advance, the selected version is jdk-6u27-linux-i586.bin,: http://pan.baidu.com/s/1mgICcFA
2. Configure the Host Name and ip ing relationship.
All nodes in the ZooKeeper cluster serve distributed applications as a whole. Therefore, to interconnect nodes, you must know the ing between hosts and ip addresses of other nodes. Configure the/etc/hosts file on each node and add the following:
192.168.1.67 MasterServer192.168.1.241 SlaveServer
3. Install ZooKeeper
1) download ZooKeeper. We recommend that you select stable version, that is, stable version.
wget http://apache.dataguru.cn/zookeeper/stable/zookeeper-3.4.6.tar.gz
2) decompress
tar -zxvf zookeeper-3.4.6.tar.gz
3) Modify/etc/profile and add ZooKeeper path
export ZOOKEEPER_HOME=/home/hadooper/hadoop/zookeeper-3.4.6export PATH=$ZOOKEEPER_HOME/bin:$ZOOKEEPER_HOME/conf:$PATH
4) Create and modify zoo. cfg
cp conf/zoo_sample.cfg conf/zoo.cfg
# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just # example sakes.dataDir=/home/hadooper/hadoop/zookeeper-3.4.6/data# the port at which the clients will connectclientPort=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=1server.1=MasterServer:2888:3888server.2=SlaveServer:2888:3888
Parameter description:
① TickTime: Heartbeat time, in milliseconds.
② InitLimit: This configuration item is used to configure Zookeeper to accept the client (the client mentioned here is not the client that the user connects to the Zookeeper server, but the Follower server connected to the Leader in the Zookeeper server cluster) the maximum heartbeat interval that can be tolerated during connection initialization. When the length of the heartbeat exceeds 10 (tickTime), the Zookeeper server does not receive the response from the client, which indicates that the connection to the client fails. The total length is 10*2000 = 20 seconds.
③ SyncLimit: This configuration item identifies the length of time for sending a message, request, and response between the Leader and Follower. the maximum length of a message is 5*2000 = 10 seconds.
④ DataDir: the location where database snapshots are stored in memory.
⑤ ClientPort: listening on the client connection Port
⑥ Server. A = B: C: D: where A is A number, indicating the number of the server. B is the ip address of the server; C Indicates the port on which the server exchanges information with the Leader server in the cluster. D indicates that if the Leader server in the cluster fails, a port is required for re-election, select a new Leader, which is the port used for communication between servers during the election. For the pseudo cluster configuration method, because B is the same, different Zookeeper instance communication port numbers cannot be the same, so you need to assign them different port numbers.
5) create A myid file in the dataDir directory and set the content to A value in column 6 to identify different servers.
4. Remotely copy the Installation File
Note: Remember to modify the myid of each node.
scp -r zookeeper-3.3.4/ hadooper@SlaveServer:/home/hadooper/hadoop/
Reprinted Please note: http://blog.csdn.net/hwwn2009/article/details/40000881
5. Test ZooKeeper
1) Start on each node
[hadooper@MasterServer zookeeper-3.4.6]$ bin/zkServer.sh start
2) view processes in jps
30056 QuorumPeerMain
QuorumPeerMain is the zookeeper process, which indicates that it is normal to start.
3) view the status
[hadooper@MasterServer zookeeper-3.4.6]$ bin/zkServer.sh status
JMX enabled by defaultUsing config: /home/hadooper/hadoop/zookeeper-3.4.6/bin/../conf/zoo.cfgMode: follower
[hadooper@SlaveServer zookeeper-3.4.6]$ bin/zkServer.sh statusJMX enabled by defaultUsing config: /home/hadooper/hadoop/zookeeper-3.4.6/bin/../conf/zoo.cfgMode: leader
Note: SlaveServer is the leader of the cluster.
4) Stop ZooKeeper
[hadooper@MasterServer zookeeper-3.4.6]$ bin/zkServer.sh stop
Reprinted Please note: http://blog.csdn.net/hwwn2009/article/details/40000881