zookeeper3.X installation

1. Download or upload the downloaded installation package through wget to: /usr/local/src, and decompress it

cd /usr/local/src

tar -zxvf zookeeper-3.4.6.tar.gz

cd zookeeper-3.4.6

2. Create data and log files

mkdir data

mkdir logs

3. Move the installation package to /usr/local

mv /usr/local/src/zookeeper-3.4.6 /usr/local/

rm -rf /usr/local/src/zookeeper-3.4.6.tar.gz

cd /usr/local/zookeeper-3.4.6

4. Copy the configuration file as the default configuration file

cp conf/zoo_sample.cfg conf/zoo.cfg

5. Edit zoo.cfg for configuration settings

saw conf/zoo.cfg

--Specify the data and log directory

dataDir=/usr/local/zookeeper-3.4.6/data

dataLogDir=/usr/local/zookeeper-3.4.6/logs

--server.A=B:C:D: where A is a number, indicating which server this is; B is the service

The IP address of the server or the host name mapped to the IP in the /etc/hosts file; C indicates the port through which
this server exchanges information with the leader server in the cluster; D indicates 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.

server.1=centos201:2888:3888

The settings are shown in the figure: 


  

 6. Create a machine number file

vi data/myid 


The content is the A value in server.A

7. Append environment variables

Add the following at the end:

##Zookeeper_ENV

export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.6

export PATH=$PATH:$ZOOKEEPER_HOME/bin

To make the configuration take effect:

# source /etc/profile

8. Enable firewall whitelist

vi /etc/sysconfig/iptables

Add configuration:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 2181 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 2888 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3888 -j ACCEPT

restart firewall

service iptables restart

9. Start the service

./bin/zkServer.sh start

10. View service status

./bin/zkServer.sh status

 

Precautions:

1. Install the jdk environment on the server in advance

Guess you like

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