Zookeeper installed on centos7

Zookeeper installed on centos7

1 Preparations

  • 1, ready to server, this installation uses centos7 system memory 2G, 60G stores a virtual machine server;
  • 2, server installation java environment: refer to the article "Installing jdk8 on centos7" Bowen;
  • 3, the installation package zookeeper prepared, using this version of the package zookeeper-3.4.11.tar.gz

2 Installation zookeeper

2.1, zookeeper extracting installation package, use tar:

tar -zxvf zookeeper-3.4.11.tar.gz

We look after the extraction is completed, the contents of the folder zookeeper:

2.2, modify the configuration file:

  • 1, we enter the confnext folder, you can see the contents of the folder is as follows:

  • 2, here, we will zoo_sample.cfg copy and named zoo.cfg

cp zoo_sample.cfg zoo.cfg

  • 3, using the vi command to open and modify configuration zoo.cfg:

Here, we need to note icon on white dataDir position corresponding directory if the corresponding directory does not exist, we need to modify the path, we first create a new folder in the data extraction path of zookeeper.

We will then file you just created folder path is set to the next dataDir:

Wherein, by modifying the value clientPort later, start modifying zookeeper port 2181 by default.

  • 4, start zookeeper
    in the bin directory of the files in the folder zookeeper, use the following command to start the zookeeper:

./zkServer.sh start

-5 zookeeper start checking cases
we can use the following command to view the status zookeeper's start:

./zkServer.sh status

In addition, we can also be judged by looking at the zookeeper process if it started successfully!

ps -ef | grep zookeeper

3 Set zookeeper boot from the start

We can serve as a zookeeper, set it to boot from the start, so every time we turn on the virtual machine can be turned zookeeper, completely hands! Set zookeeper boot from Kai requires the following steps:

  • 1, enter the /etc/init.ddirectory:

  • 2, create a file zookeeper, and add the script:

vi zookeeper

Script reads:

#!/bin/bash
#chkconfig:2345 20 90
#description:zookeeper
#processname:zookeeper
ZK_PATH=/opt/soft/zookeeper-3.4.11
export JAVA_HOME=/opt/soft/jdk1.8.0_152
case $1 in
         start) sh  $ZK_PATH/bin/zkServer.sh start;;
         stop)  sh  $ZK_PATH/bin/zkServer.sh stop;;
         status) sh  $ZK_PATH/bin/zkServer.sh status;;
         restart) sh $ZK_PATH/bin/zkServer.sh restart;;
         *)  echo "require start|stop|status|restart"  ;;
esac

Note: The figure in the script to modify and correct zk jdk installation path!

  • 3, then save the script, follow these instructions to register for the service:

chkconfig --add zookeeper

  • 4, test whether its entry into force, the use of this service first stop, then use the command to start, attention needs to be modified to create a zookeeper service rights:
[root@zhiyou init.d]# service zookeeper start
env: /etc/init.d/zookeeper: 权限不够
[root@zhiyou init.d]# 
[root@zhiyou init.d]# chmod +x zookeeper 
[root@zhiyou init.d]# 
[root@zhiyou init.d]# service zookeeper start
ZooKeeper JMX enabled by default
Using config: /opt/soft/zookeeper-3.4.11/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@zhiyou init.d]# 
[root@zhiyou init.d]# service zookeeper status
ZooKeeper JMX enabled by default
Using config: /opt/soft/zookeeper-3.4.11/bin/../conf/zoo.cfg
Mode: standalone
[root@zhiyou init.d]# 
[root@zhiyou init.d]# ps -ef|grep zookeeper

So far, we have completed all the steps to install zookeeper at centos7, and set up a zookeeper boot from the start!


Blog:

  • Jane book: https://www.jianshu.com/u/91378a397ffe
  • CSDN: https://blog.csdn.net/ZhiyouWu
  • Open Source China: https://my.oschina.net/u/3204088
  • Nuggets: https://juejin.im/user/5b5979efe51d451949094265
  • Park blog: https://www.cnblogs.com/zhiyouwu/
  • Micro letter: WZY1782357529 (welcome communication)

Guess you like

Origin www.cnblogs.com/zhiyouwu/p/11546097.html