zookeeper-cluster build

1. Installation environment (java environment does not indicate that you install jdk1.8 yourself)

[root @ linux-node1 ~] # cat / etc / redhat-release 
CentOS Linux release 7.4.1708 (Core) 
#ip address 
192.168.56.11 
192.168.56.12 
192.168.56.13

2. Download the installation package

[root@linux-node1 ~]# cd /data/
[root@linux-node1 data]# wget http://archive.cloudera.com/cdh5/cdh/5/zookeeper-3.4.5-cdh5.7.0.tar.gz
[root@linux-node1 data]# tar xf zookeeper-3.4.5-cdh5.7.0.tar.gz 

3. Edit the configuration file

[root@linux-node1 zookeeper-3.4.5-cdh5.7.0]# cat /usr/local/zookeeper/conf/zoo.cfg 

tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/
clientPort=2181
maxClientCnxns=50
server.1=192.168.56.11:2888:3888
server.2=192.168.56.12:2888:3888
server.3=192.168.56.13:2888:3888

Description:

maxClientCnxns The maximum number of connections 
server.A = B: C: D 
A is a number, indicating that this is the server number and myid file corresponding to 
B is the IP address of this server, the 
first port of C is used for cluster member information Exchange refers to the port where this server exchanges information with the leader server in the cluster. 
D is the port used for leader election when the leader hangs up.
Port description: 1, 
2181: provide services to the cline side 2, 
3888: use of election leader 3, 
2888: use of machine communication within the cluster (Leader listens to this port)

3. Create a myid file

[root@linux-node1 zookeeper-3.4.5-cdh5.7.0]# cd /usr/local/zookeeper/
[root@linux-node1 zookeeper]# echo 1 > myid 

4. I directly copy the configured zookeeper to the other two servers. The value needs to be changed in the myid file (1 corresponds to 192.168.56.11,2 corresponds to 192.168.56.12, and 3 corresponds to 192.168.56.13)

[root@linux-node1 zookeeper]# pwd
/usr/local/zookeeper
[root@linux-node1 zookeeper]# scp -r zookeeper-3.4.5-cdh5.7.0 [email protected]:/data/

[root@linux-node1 zookeeper]# pwd
/usr/local/zookeeper
[root@linux-node1 zookeeper]# scp -r zookeeper-3.4.5-cdh5.7.0 [email protected]:/data/

5. Add environment variables (all need to be executed)

cat<<EOF>>/etc/profile
export ZK_HOME=/usr/local/zookeeper
export PATH=\$ZK_HOME/bin:$PATH
EOF
source /etc/profile

6. Start zookeeper

[root@linux-node1 zookeeper]#  /usr/local/zookeeper/bin/zkServer.sh start

7. Each one is successfully started or viewed

 

 

 At this point, the cluster is built.

If you want to change the log storage path, refer to the following:

修改log位置
mkdir -p /data/zookeeper/logs
vi /usr/local/zookeeper/bin/zkEnv.sh
ZOO_LOG_DIR="/data/zookeeper/logs"
ZOO_LOG4J_PROP="INFO,ROLLINGFILE"
vi /usr/local/zookeeper/conf/log4j.properties
zookeeper.root.logger=INFO, ROLLINGFILE
zookeeper.log.dir=/data/zookeeper/logs

 

  

Guess you like

Origin www.cnblogs.com/zhaojingyu/p/12721435.html