CentOS6.7 build Zookeeper

 

Article Directory

 


Preface

I have three major majors in data. Last week I learned how to build a hadoop environment. After configuring the static ip and building the hadoop distributed cluster, start to build the Zookeeper software, and then build the hbase environment ( https://blog.csdn.net/master_hunter/article/details/108704148 ). I have many unclear questions in this field, and there may be some errors in the article. I hope you can correct me in the comment area. The errors in this article will be continuously corrected and maintained.

Specific reference https://www.cnblogs.com/Genesis2018/p/8304708.html

The installation steps of this big guy.


 

1. What is Zookeeper?

In order to achieve data synchronization and consistency in distributed services, group management monitoring, distributed voting and locking, and named addressing, it is necessary to provide distributed coordination services in the cluster. For this reason Zookeeper was born.

 

Two, installation steps

Zookeeper adopts a clustered deployment method, which is generally deployed on multiple servers to prevent a single point of failure. In order to facilitate the convergence during voting, an odd number of servers are generally deployed. The specific architecture and storage structure are not elaborated in this article, only deployment.

1. Mirror download

 I use the Tsinghua mirror to download Zookeeper version 3.4.14. It is recommended to use the tar package with the bin suffix to download. Without the bin suffix, the source code is not compiled. After the installation, the bin directory is missing and an error will be reported.

wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper- 3.4.14/apache-zookeeper- 3.4.14.tar.gz

tar unzip the downloaded file

tar -zxvf apache-zookeeper-3.4.14.bin.tar.gz

Move zookeeper to the local directory

mv zookeeper- 3.4.14 /usr/local/

创建zookeeper的数据目录

mkdir -p /usr/local/zookeeper- 3.4.14/data

Edit configuration environment

cp /usr/local/zookeeper- 3.4.14/conf/zoo_sample.cfg /usr/local/zookeeper- 3.4.14/conf/zoo.cfg

vi /usr/local/zookeeper- 3.4.14/conf/zoo.cfg

Add the deployed virtual machine address in zoo.cfg

dataDir=/usr/local/zookeeper- 3.4.14/data
server.1=hadoop1:2888:3888
server.2=hadoop2:2888:3888
server.3=hadoop3:2888:3888

The 2888 port number is the port for communication between ZooKeeper services, and 3888 is the port for ZooKeeper to communicate with other applications.

Configure the environment variables of zookeeper

vi /etc/profile.d/zookeeper.sh

Add to

export ZOOKEEPER_HOME=/usr/local/zookeeper- 3.4.14
export PATH=$PATH:$ZOOKEEPER_HOME/bin

Remember to take effect

source /etc/profile.d/zookeeper.sh

Pass to other virtual machines

scp -r /etc/profile.d/zookeeper.sh hadoopxx:/etc/profile.d/

scp -r /usr/local/zookeeper- 3.4.14 hadoopxx:/usr/local/

Check whether the command is executed successfully or not

echo $?
0

On other nodes

vi /usr/local/zookeeper- 3.4.14/data/myid

Add to

1

According to the number of nodes

The file contains only one line, and the content is the idnumber in the subordinate node corresponding to the node . The values ​​in the myid file corresponding to the master node and the slave node are 1 and 2....

Execute save

 source /etc/profile.d/zookeeper.sh

Go back to the master and start zookeeper

/usr/local/zookeeper- 3.4.14/bin/zkServer.sh start

ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper- 3.4.14/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

Use zkCli.sh to link zookeepe 

/usr/local/zookeeper- 3.4.14/bin/zkCli.sh -server hadoop1:2181
[zk: localhost:2181(CONNECTED) 0] help
[zk: localhost::2181(CLOSED) 3] quit

Start services on other nodes

# /usr/local/zookeeper- 3.4.14/bin/zkServer.sh start

ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper- 3.4.14/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

# /usr/local/zookeeper- 3.4.14/bin/zkCli.sh -server hadoopxx:2181
[zk:hadoopxx:2181(CONNECTED) 0] quit
 

 

1. Start the test

Start zkserver on all nodes

View the status of each node

/zkServer.sh status

If it is successfully started, it will show that the node selection result is leader or follower


to sum up

You need to adjust yourself according to the errors reported in the log. Later, I will post some solutions to common errors in configuring zookeeper. I hope to help you!

Guess you like

Origin blog.csdn.net/master_hunter/article/details/108704148