Zookeeper 3.4.x installation and configuration -- Linux articles

Read the table of contents:

1. Turn off firewall and Selinux

2. Install the required environment JDK

3. Download Zookeeper 3.4.x version

4. Configure and start Zookeeper

5. Verify and configure autostart

6. Description

1. Turn off firewall and Selinux

        The firewall of Linux is a nightmare for us newbies. In many cases, it can be pinged, but the Web page cannot be accessed. So start killing it!

    1.1 Turn off the firewall

    [root@localhost ~]# /etc/init.d/iptables stop
    iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
    iptables: Flushing firewall rules:                         [  OK  ]
    iptables: Unloading modules:                               [  OK  ]

    1.2 Turn off the firewall automatically after booting

    [root@localhost ~]# chkconfig iptables off

    1.3 View Selinux status

    [root@localhost ~]# sestatus
    SELinux status: enabled 
    SELinuxfs mount: /sys/fs/selinux 
    SELinux root directory: /etc/selinux 
    Loaded policy name: targeted 
    Current mode: enforcing 
    Mode from config file: enforcing 
    Policy MLS status: enabled 
    Policy deny_unknown status: allowed 
    Max kernel policy version: 28

    1.4 Turn off selinux

    [root@localhost ~]# vim /etc/selinux/config 

Modify SELINUX=disabled 
Note: Permanently open -> change to: SELINUX=enforcing

2. Install the required environment JDK

    Direct reference to this article: https://my.oschina.net/u/3209432/blog/1576928

3. Download Zookeeper 3.4.x version

    Note: Create two directories to store log logs and data data

    [root@localhost /]# mkdir /usr/local/zookeeper
    [root@localhost /]# mkdir /usr/local/zookeeper/data
    [root@localhost /]# mkdir /usr/local/zookeeper/dataLog

    3.1 Download Zookeeper 3.4.x

    [root@localhost /]# cd /usr/local/zookeeper
    [root@localhost zookeeper]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz

    3.2 Decompression

    [root@localhost zookeeper]# tar -zxvf zookeeper-3.4.11.tar.gz

4. Configure and start Zookeeper

    4.1 Enter the configuration folder of Zookeeper 3.4.x

    [root@localhost zookeeper]# cd /usr/local/zookeeper/zookeeper-3.4.11/conf

    4.2 Backup configuration file (for modification)

    [root@localhost conf]# mv zoo_sample.cfg zoo.cfg

    4.3 Modify the configuration file zoo.cfg

    [root@localhost conf]# vim zoo.cfg

    Add two lines marked in red

# The number of ticks that can pass between 
# 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 
# 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.
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

dataDir=/usr/local/zookeeper/data
dataLogDir=/usr/local/zookeeper/dataLog

    4.4 Configure zookeeper environment variables

    [root@localhost conf]# vim /etc/profile

    Add the following code to the last line at the end of the text:

export ZOOKEEPER_HOME=/usr/local/zookeeper/zookeeper-3.4.11

export PATH=$ZOOKEEPER_HOME/bin:$PATH

Save and exit.

    4.5 Make the configuration take effect immediately

    [root@localhost conf]# source /etc/profile

    4.6 Start Zookeeper

    [root@localhost conf]# /usr/local/zookeeper/zookeeper-3.4.11/bin/zkServer.sh start
    ZooKeeper JMX enabled by default
    Using config: /usr/local/zookeeper/zookeeper-3.4.11/bin/../conf/zoo.cfg
    Starting zookeeper ... STARTED

5. Verify and configure autostart

    5.1 Verification

    [root@localhost conf]# /usr/local/zookeeper/zookeeper-3.4.11/bin/zkServer.sh status
    ZooKeeper JMX enabled by default
    Using config: /usr/local/zookeeper/zookeeper-3.4.11/bin/../conf/zoo.cfg
    Mode: standalone

    5.2 Create and edit self-starting files

    [root@localhost conf]# vim /etc/rc.d/init.d/zookeeper

#!/bin/bash  
##chkconfig:2345 20 90  
#description:zookeeper  
#processname:zookeeper  
export JAVA_HOME=/usr/java/jdk1.8.0_144
case $1 in
        start) su root /usr/local/zookeeper/zookeeper-3.4.11/bin/zkServer.sh start;;
        stop) su root /usr/local/zookeeper/zookeeper-3.4.11/bin/zkServer.sh stop;;
        status) su root /usr/local/zookeeper/zookeeper-3.4.11/bin/zkServer.sh status;;
        restart) su /usr/local/zookeeper/zookeeper-3.4.11/bin/zkServer.sh restart;;
        *) echo "require start|stop|status|restart" ;;
esac

    5.3 Granting file permissions

    [root@localhost conf]# chmod +x /etc/rc.d/init.d/zookeeper

6. Description

    Description: this use

       Operating System: CentOS 6.8 64-bit

       Zookeeper version: 3.4.11

    Note: If the download link fails, you can try to visit: https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper

Guess you like

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