[Switch] ZooKeeper installation process

1. Download zookeeper
wget http://mirror.bit.edu.cn/apache//zookeeper/zookeeper-3.4.3/zookeeper-3.4.3.tar.gz (version 3.4.3 is installed this time)
Download address for other versions (preferably use the stable version): http://zookeeper.apache.org/releases.html
 
2. Decompression
tar -xf zookeeper-3.4.3.tar.gz
Put the decompressed zookeeper-3.4.3 file in /home/hadooptest/ of the system.
 
3. Copy the zoo_sample.cfg file in the zookeeper-3.4.3/conf directory and name it "zoo.cfg"
 
4. Modify the zoo.cfg configuration file
Modify the content of zoo.cfg to:
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit = 10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/home/hadooptest/zookeeper-3.4.3/zookeeperdir/zookeeper-data
dataLogDir=/home/hadooptest/zookeeper-3.4.3/zookeeperdir/logs
 
# the port at which the clients will connect
clientPort=2181
#
# 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 = 1
 
# 2888,3888 are election port
server.1=zookeeper:2888:3888
 
Among them, the 2888 port number is the port for communication between zookeeper services, and 3888 is the port for zookeeper to communicate with other applications. The zookeeper has mapped the ip of the local machine in the hosts.
initLimit: This configuration item is used to configure Zookeeper to accept clients (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) How long can the initial connection be tolerated The number of heartbeat intervals. When the Zookeeper server has not received the return information from the client after more than 10 heartbeats (that is, tickTime), it indicates that the client connection failed. The total time length is 5*2000=10 seconds.
syncLimit: This configuration item identifies the length of the message, request and response time sent between the Leader and the Follower. The longest time length cannot exceed the length of several tickTimes. The total time length is 2*2000=4 seconds.
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 through which the server exchanges information with the leader server in the cluster; D It means that in case the leader server in the cluster hangs, a port is needed to re-elect and elect a new leader, and this port is the port used to communicate with each other during the election. If it is a pseudo-cluster configuration, since B is the same, the communication port numbers of different Zookeeper instances cannot be the same, so they must be assigned different port numbers.
 
5. Create the directory specified by the dataDir parameter (here refers to "/home/hadooptest/zookeeper-3.4.3/zookeeperdir/zookeeper-data"), and create a file in the directory named "myid".
 
6. Edit the "myid" file and enter the corresponding number on the machine with the corresponding IP. For example, on zookeeper, the "myid" file content is 1. Since the installation and configuration are only performed on a single point this time, there is only one server.1. If there are other servers, for example, the address is 192.168.1.102, you need to add server.2=192.168.1.102:2888:3888 to the zoo.cfg file. Then the content of the myid file on the 192.168.1.102 server is 2.
So far, if it is a multi-server configuration, you need to copy the zookeeper-3.4.3 directory to other servers, and then modify myid according to the above method.
 
7. Set PATH in the /etc/profile file
Modify the profile file:
sudo vi /etc/profile
 
export ZOOKEEPER_HOME=/home/hadooptest/zookeeper-3.4.3
PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH
 
8. Installation is complete
 
3. Start and test zookeeper
1. Execute in all servers: zookeeper-3.4.3/bin/zkServer.sh start
 
2. Enter the jps command to view the process:
The namenode is displayed as (this time it is a single-machine configuration):
7724 DataNode
19769 HMaster
7485 NameNode
8064 JobTracker
1936 QuorumPeerMain
8323 TaskTracker
7972 SecondaryNameNode
21691 Jps
19988 HRegionServer
 
Among them, QuorumPeerMain is the zookeeper process, which starts normally. (HMaster and HRegionServer are the started hbase processes, and the others are the processes started after hadoop installed)
 
3. Check the status: zookeeper-3.4.3/bin/zkServer.sh status
JMX enabled by default
Using config: /home/hadooptest/zookeeper-3.4.3/bin/../conf/zoo.cfg
Mode: standalone
 
4. Start the client script: zookeeper-3.4.3/bin/zkCli.sh -server zookeeper:2181
WatchedEvent state:SyncConnected type:None path:null
[zk: zookeeper:2181(CONNECTED) 0] 
[zk: zookeeper:2181(CONNECTED) 0] help
ZooKeeper -server host:port cmd args
        connect host:port
        get path [watch]
        ls path [watch]
        set path data [version]
        rmr path
        delquota [-n|-b] path
        quit 
        printwatches on|off
        create [-s] [-e] path data acl
        stat path [watch]
        close 
        ls2 path [watch]
        history 
        listquota path
        setAcl path acl
        getAcl path
        sync path
        redo cmdno
        addauth scheme auth
        delete path [version]
        setquota -n|-b val path
[zk: zookeeper:2181(CONNECTED) 1] ls /
[hbase, zookeeper]
[zk: zookeeper:2181(CONNECTED) 2] 
 
5. Stop the zookeeper process: zookeeper-3.4.3/bin/zkServer.sh stop
 
refer to:
http://zookeeper.apache.org/doc/trunk/zookeeperStarted.html
http://my.oschina.net/cmffire/blog/11282
http://space.itpub.net/8183550/viewspace-683571

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326647937&siteId=291194637