Installation of zookeeper

First of all, Xiaobian here is the installation of zookeeper in the Linux environment.

1. Prepare the environment

(2n-1 linux machines or virtual machines: Since zookeeper's paxos algorithm requires more than half of the survival to be available, it is necessary to prepare a single server to build the environment)

2. Upload

Use the tool to upload the zookeeper installation file to /home/hadoop , and make sure the user book hadoop of the file,

If not, you need to modify the owner of the file with the root user.

Order:

su – root

cd /home/hadoop

chown hadoop:hadoop zookeeper-3.4.5.tar.gz

su - hadoop

3. Unzip

Unzip with hadoop user, if you are not hadoop user, you need su – hadoop

tar –zxvf zookeeper-3.4.5.tar.gz

4. Rename

Need to be hadoop user

mv zookeeper-3.4.5 zookeeper

5. Modify the environment variables (every zookeeper machine in the cluster must be changed)

5.1. Execute on the first machine of zookeeper

1、su – root

2、vi /etc/profile

3. Add content:

export ZOOKEEPER_HOME=/home/hadoop/zookeeper

export PATH=$PATH:$ZOOKEEPER_HOME/bin

4. Recompile

source /etc/profile

5. Switch users

su – hadoop

5.2. Do the same steps on other machines in zookeeper

see above

6. Modify the zookeeper configuration file

1、  su – hadoop

2、  cd /home/hadoop/zookeeper/conf

3. cp zoo_sample.cfg zoo.cfg (copy a backup first)

4 、 vi zoo.cfg

5. Add content, in which the domain name needs to be considered by yourself

dataDir=/home/hadoop/zookeeper/data

dataLogDir=/home/hadoop/zookeeper/log

server.1=slave1:2888:3888

server.2=slave2:2888:3888

server.3=slave3:2888:3888

Simple parsing of configuration files

1. tickTime: This time is used as the time interval for maintaining heartbeats between Zookeeper servers or between clients and servers, that is, a heartbeat will be sent every tickTime.
2. dataDir: As the name suggests, it is the directory where Zookeeper saves data. By default, Zookeeper also saves log files for writing data in this directory.
3. dataLogDir: As the name suggests, it is the directory where Zookeeper saves log files.
4. clientPort: This port is the port through which the client connects to the Zookeeper server. Zookeeper will listen to this port and accept client access requests.

6. Create a folder

cd /home/hadoop/zookeeper

mkdir data

mkdir log

chmod 755 data

chmod 755 log

7. Create myid file and add content

cd /home/hadoop/zookeeper/data

vi myid

Added content:

1

 

7. Transfer zookeeper to other machines

scp –r /home/hadoop/zookeeperhadoop@slave1:/home/hadoop

scp –r /home/hadoop/zookeeperhadoop@slave2:/home/hadoop

scp –r /home/hadoop/zookeeperhadoop@slave3:/home/hadoop

 

8. Modify the configuration files of other machines

8.1. Execute the command on the slave2 machine:

su – hadoop

cd /home/hadoop/zookeeper/data

vi myid

修改内容,将1改为2

2

8.2.  在slave3机器上执行命令:

su – hadoop

cd /home/hadoop/zookeeper/data

vi myid

修改内容,将1改为3

3

 

9.  启动

9.1.  在slave1上执行:

zkServer.sh start(别忘了加上./命令)

9.2.  在slave2上执行:

zkServer.sh start

9.3.  在slave3上执行:

zkServer.sh start

10.     查看

10.1.    在slave1上执行

jps

zkServer.sh status

10.2.    在slave2上执行

jps

zkServer.sh status

10.3.    在slave3上执行

jps

zkServer.sh status



Guess you like

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