Zookeeper super detailed installation cluster deployment


Insert image description here

1. Zookeeper official website download

2. JDK environment installation

  • Directly use yumthe command to install online
yum install -y java-1.8.0-openjdk.x86_64
  • Environment variable configuration
sudo vi /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_291/
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
  • Reload configuration file
sudo source /etc/profile

3. Zookeeper installation

1.zookeeper decompression

  • First upload the downloaded apache-zookeeper-3.5.9-bin.tar.gzto the server
  • Unzip and install to /usr/local/directory
tar -zxvf apache-zookeeper-3.5.9-bin.tar.gz -C /usr/local/
  • As shown belowInsert image description here

  • Rename tozookeeper

mv apache-zookeeper-3.5.9-bin zookeeper
  • As shown belowInsert image description here

2.Zookeeper configuration file introduction

  • Enter zookeeperconfiguration fileusr/local/zookeeper/conf/
  • zoo_sample.cfgRename the configuration file tozoo.cfg
mv zoo_sample.cfg zoo.cfg
  • Configuration file introduction
# 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.
# 配置zookeeper数据存放路径
dataDir=/tmp/zookeeper
# 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
#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=1
  • First, zookeepercreate a directory for storing data and logs under the directory zookeeper, and add file read and write permissions.
mkdir data
sudo chmod 777 data
mkdir logs
sudo chmod 777 logs
  • As shown in the pictureInsert image description here
  • Modify configuration file
dataDir=/usr/local/zookeeper/data
dataLogDir=/usr/local/zookeeper/logs
  • Cluster configuration
# 集群配置 2888:选举端口 3888:投票端口
server.1=server001:2888:3888
server.2=server002:2888:3888
server.3=server003:2888:3888
  • KAFKA001 represents the host name, and you can also write the IP address.
  • View hostnamehostnamectl
  • Set hostname
sudo hostnamectl set-hostname server001
  • /usr/local/zookeeper/dataAdd the unique identifier of this machine cluster to the previously created data directory.
  • write1
  • Note: myidThe data insideservice一致
echo "1" > myid
  • Configuration hostfile vi /etc/hostsadds the host names and IP addresses of the three clusters
192.168.204.130  server001
192.168.204.131  server002
192.168.204.132  server003
  • As shown below
    Insert image description here

Clone server

1. Network check

  • After cloning, check that the three servers can access each other's IP addresses.

2. Cluster configuration

  • Remember to modify the host names of the next two servers
sudo hostnamectl set-hostname server002
sudo hostnamectl set-hostname server003
  • In the previously created /usr/local/zookeeper/datadata directory, add the unique identifier of this machine cluster [modify the last two]
  • The latter two machines write respectively 2,3
echo "2" > myid
echo "3" > myid

3. Start the cluster

  • Enter /usr/local/zookeeper/binthe directory and execute./zkServer.sh start
# 可在三台服务器分别执行
/usr/local/zookeeper/bin/zkServer.sh start
  • check status
# 可在三台服务器分别执行
/usr/local/zookeeper/bin/zkServer.sh status
  • As shown belowInsert image description here

4.Error record

  • In case of abnormalityERROR
  • Execute the command ./zkServer.sh start-foregroundand read the error details in the log to further determine the cause of the error.
/usr/local/zookeeper/bin/zkServer.sh start-foreground

Guess you like

Origin blog.csdn.net/Lance_welcome/article/details/130519119