Install zookeeper on Linux and set boot boot (centos7+zookeeper3.4.10) __linux

Source: Internet
Author: User
Tags gz file zookeeper zookeeper set

1 Download Zookeeper

2 Install start test

2.1 Upload compressed files and unzip

2.2 New Zookeeper configuration file

2.3 Installing JDK

2.4 Start Zookeeper

2.5 View the status of the zookeeper

3 Set Zookeeper to boot (optional)

3.1 Create a new script file in the INIT.D directory

The first scheme of 3.1.1 file content (recommended)

The second scenario for 3.1.2 file content

3.1.3 Other Notes

3.2 Execute a series of commands

3.3 Perform test to see if boot up

4 Error and resolution

4.1service Zookeeper does not support Chkconfig

4.2 Error Contacting service. It is probably not running

5 Downloads related to this blog

keywords: CentOS7 zookeeper3.4.10 java 1 Download Zookeeper

Address: http://mirror.bit.edu.cn/apache/zookeeper/



2 Install start test

Description: (all of the following actions are made by the Staff Administrator account) 2.1 Upload Compressed files and unzip

The CENTOS7 operating system is used here. Create a new directory named Zookeeper in opt directory and upload the downloaded zookeeper-3.4.10.tar.gz file.

as shown in figure:

To enter the directory, the command is:

Cd/opt/zookeeper

To perform the decompression command:

TAR-ZXVF zookeeper-3.4.10.tar.gz

as shown in figure:

      

2.2 New Zookeeper configuration file

Zookeeper need a configuration file named Zoo.cfg, we unzipped, get the official sample file, named Zoo_sample.cfg, this file in the Zookeeper root directory of the Conf subdirectory. If we want to use the default configuration, copy and rename the file directly. The inside can configure the port number, whether the cluster is enabled, and so on, here does not expand, directly perform CP replication rename.

Command is:

CP/OPT/ZOOKEEPER/ZOOKEEPER-3.4.10/CONF/ZOO_SAMPLE.CFG/OPT/ZOOKEEPER/ZOOKEEPER-3.4.10/CONF/ZOO.CFG

As shown in figure:

The above command generates the ZOO.CFG

as shown in figure:

Description: Zoo.cfg can configure things, if you want to build zookeeper cluster, please see this blog: HTTP://BLOG.CSDN.NET/PUCAO_CUG/ARTICLE/DETAILS/7 2228973
2.3 Installing JDK

Installing the JDK on Linux is the same, although we use the CENTOS7 operating system here, but we can still install the JDK on Unbuntu, please refer to this blog:

http://blog.csdn.net/pucao_cug/article/details/68948639

Description: Your JDK installation path and zookeeper installation path can not be the same as mine, but if your path is the same as mine, in the third chapter of this blog, the zookeeper set to boot-related configuration, you can not modify those configuration content, direct replication use. 2.4 Start Zookeeper

Go to Zookeeper's Bin directory and command:

Cd/opt/zookeeper/zookeeper-3.4.10/bin

Execute the zkserver.sh script to start the command:

./zkserver.sh Start

as shown in figure:

    

2.5 View the status of the zookeeper

If you are not in the Zookeeper Bin directory at this time, go to the directory first:

Cd/opt/zookeeper/zookeeper-3.4.10/bin

To perform a command to view the zookeeper status:

./zkserver.sh Status

as shown in figure:

    

Standalone is a stand-alone mode. 3 Set Zookeeper to boot (optional) 3.1 Create a new script file in the INIT.D directory

To enter the/ETC/RC.D/INIT.D directory, the command is:

CD/ETC/RC.D/INIT.D

Create a new file named Zookeeper, and the command is:

Touch Zookeeper

as shown in figure:

      

3.1.1 The first option of the content of the document (recommended)

using the VIM command to modify the contents of the file, the contents of the file are written in a number of ways, in addition to the first scenario above, use the following:

[plain] view plain copy #!/bin/bash #chkconfig: 2345 #description: Service Zookeeper Export Java_ home=/opt/java/jdk1.8.0_121 Export Zoo_log_dir=/opt/zookeeper/log zookeeper_home=/opt/zookeeper/zookeeper-3.4.10 s U root ${zookeeper_home}/bin/zkserver.sh "$"

3.1. The second option of the content of the 2 document

use the VIM command to modify the contents of the file:

[Plain]  View plain  copy #!/bin/bash   #chkconfig: 2345 10 90   #description:  service zookeeper   export    java_home=/opt/java/jdk1.8.0_121    export     zoo_log_dir=/opt/zookeeper/log   ZOOKEEPER_HOME=/opt/ zookeeper/zookeeper-3.4.10   case   "$"    in              start)   su  root   ${zookeeper_ home}/bin/zkserver.sh   start;;              start-foreground)   su   root  ${ZOOKEEPER_HOME}/bin/zkServer.sh    start-foreground;;              stop)   su  root    ${ZOOKEEPER_HOME}/bin/zkServer.sh   stop;;    &NBsp;         status)   su root  ${ zookeeper_home}/bin/zkserver.sh    status;;              restart)   su root    ${ZOOKEEPER_HOME}/bin/zkServer.sh   restart;;              upgrade) su root    ${zookeeper_home}/bin/zkserver.sh   upgrade;;              print-cmd) su root    ${ZOOKEEPER_HOME}/bin/zkServer.sh   print-cmd;;              *)   echo   " Requirestart|start-foreground|stop|status|restart|print-cmd ";;    esac  


3.1.3 Other Notes

Note 1: The command to create a new file is touch, and the command to edit the file with VI and VIM is OK. If you don't use the VI and VIM commands, edit the files directly locally and upload them with remote tools, but be aware that if you use a local Windows system, you need to convert the files to UNIX format. There are many conversion tools, such as using notepad++

as shown in figure:

  

NOTE 2: The portion of the file head # annotation in the two scenarios is not less, and the zookeeper path needs to be modified for your own in the file, such as the JDK path. 3.2 Execute a series of commands

To add executable permissions for the new/etc/rc.d/init.d/zookeeper file, the command is:

chmod +x/etc/rc.d/init.d/zookeeper

Add the zookeeper script to the boot entry, and the command is:

chkconfig--add Zookeeper

as shown in figure:

     

If you want to see if you added success, the command is:

chkconfig--list

as shown in figure:

3.3 Perform test to see if boot up

Restart the machine using the command:

reboot

Method One

View the status of zookeeper

Restart the machine, and then execute the command without manually starting the zookeeper:

Service Zookeeper Status

As shown in figure:

Method Two

to see if Port 2181 is enabled, execute the command:

lsof-i:2181

As shown in figure:

Method Three

To view the network status, execute the command:

Netstat-lntup

As shown in figure:

4 Error and resolution 4.1 service zookeeper does not support Chkconfig

Perform chkconfig--add zookeeper error :

Servicezookeeper does not support Chkconfig

problem Reason and resolution:

The header in the/etc/rc.d/init.d/zookeeper script does not add the following words (description can be written casually):

[plain] view plain copy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.