Refer to the official documentation: zookeeper.apache.org/doc/r3.4.6/…
Zookeeper is installed in distributed mode
3. Edit the configuration file {ZOOKEEPER_HOME/conf/zoo. CFG} dataDir: Specify the directory server.x of the memory database to distinguish the ZooKeeper cluster. When the ZooKeeper cluster starts, the sequence number is found in the myID file.
[chb@TEST conf]$cat zoo. CFG tickTime=2000 dataDir=/usr/local/zookeeper-3.4.6/ Zookeeper clientPort=2181 initLimit=5 syncLimit=2 server.1=TEST:2888:3888 server.2=TEST1:2888:3888 server.3=TEST2:2888:3888 [chb@TEST conf]$Copy the code
tickTime
the basic time unit in milliseconds used by ZooKeeper. It is used to do heartbeats and the minimum session timeout will be twice
dataDir
the location to store the in-memory database snapshots and, unless specified otherwise, the transaction log of updates to the database.
clientPort
the port to listen for client connection
4. Create myID file corresponding to the serial number of server.x
5. Configure ZooKeeper to environment variables
Add as follows:
#zookeeper
export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.6
export PATH=$PATH:$ZOOKEEPER_HOME/bin
Copy the code
To make /etc/profile valid:
source /etc/profile
Copy the code
6. Start the ZooKeeper Server
zkServer.sh start
Copy the code
A zookeeper.out log file will be generated in the current directory:
Make sure there are no errors
8. View the Memory database of ZooKeeper
9 Fault: ZooKeeper error record 1. Always open a channel to 2 at election address s1ave1/192.168.10.225:3888 java.net.Connection.
Modify the ZooKeeper configuration as follows:
port
Server. 1 = 192.168.10.224:2878-3878 for server 2 = 192.168.10.225:2898:3898 server. 3 = 192.168.10.226:2889-3889 clientPort = 3384Copy the code