zookeeper installation and use

Zookeeper installation process
1. Download zookeeper-3.4.6
2. The directory after decompression is:




3. Copy zoo_sample.cfg and rename it to: zoo.cfg
Parameter setting description:
# 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. #Save
snapshot file
dataDir=/usr/zookeeper-3.4.6_2/data
### log file Save log file
dataLogDir=/usr/zookeeper-3.4.6_2/logs
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients #Set the maximum number of
connections
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 The default number of snapshot files to retain is 3
autopurge.snapRetainCount =3
# Purge task interval in hours
# Set to "0" to disable auto purge feature 1 hour to clean up logs
autopurge.purgeInterval=1

#2888,3888 are election port Set cluster communication

#server.1=192.168.90.107:2889:3881
#server.2=192.168.6.24:2890:3882
#server.3=192.168.6.24:2891:3883 #Where

,
#2888 port number is the communication between zookeeper services port.

4. Enter: /usr/zookeeper-3.4.6_2/bin directory and execute

[root@localhost bin]# ./zkServer.sh start




to start successfully

6. Client login
Login :
[root@localhost bin]# ./zkCli.sh -server 127.0.0.1:2181
View node:
[zk: 127.0.0.1:2181(CONNECTED) 0] ls /






command format:







establish a pseudo-cluster: configure the
following in zookeeper-3.4.9\conf:
configure the first one:
# cp zoo_sample.cfg zoo1.cfg
# vi zoo1.cfg
Configuration content:
tickTime=2000
clientPort=2181 
initLimit=5
syncLimit=2
dataDir=/zookeeperdata/1 
server.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890

The meaning of each parameter:
tickTime: the time interval of heartbeat detection (milliseconds), Default: 2000
clientPort: port for other applications (such as solr) to access ZooKeeper, default: 2181
 initLimit: the phase of initial synchronization (the phase where followers connect to the leader), the allowed duration (number of ticks), default: 10
syncLimit: The length of time (number of ticks) that followers are allowed to synchronize to ZooKeeper, default: 5
dataDir: The storage path of data (such as the managed configuration file), it should be empty
initially server.X: X is one of the ensemble The id of the server, followed by the hostname of the server, the first port number is used for communication between ZooKeeper, and the second port is used for communication with other applications

Configure the second one:
# cp zoo1.cfg zoo2.cfg
Modify: dataDir=zookeeperdata/2
Modify: clientPort=2182

Configure the third:
# cp zoo1.cfg zoo3.cfg
Modify: dataDir=zookeeperdata/3
Modify: clientPort=2183

is distributed in the directory 1, 2, 3 to create a myid file, and the file is written into 1, 2, 3 according to the directory (write 1 in myid with
directory 1, write 2 in myid with directory 2) )

separately:

#bin/zkServer.sh start ./conf/zoo1.cfg
# bin/zkServer.sh start ./conf/zoo2.cfg
# bin/zkServer.sh start

./conf/zoo3.cfg When starting, look at the log to report an error. After all are started, there will be no error.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326488558&siteId=291194637