Zookeeper Series: Standalone mode deployment Zookeeper service

Source: Internet
Author: User

First, brief

Standalone mode is the simplest and most basic mode in the three modes of deploying the Zookeeper service, with just one machine, standalone mode is only available for learning, and standalone mode is not recommended for development and production. This article describes the entire process of deploying a zookeeper server in standalone mode and provides some simple commands to verify that it is running.

Second, prerequisites

1, a machine, this article uses the server for CentOS 7.3.

2, zookeeper run on the Java Virtual Machine (JVM), requires JDK1.6 or later, so need to install JDK and configure environment variables, JDK installation network has a lot of tutorials, this is not mentioned here, this article uses the JDK version of JDK1.8.

Third, download zookeeper

Download zookeeper, generally I choose to download the Zookeeper archives, since is the zookeeper archives, that zookeeper of various versions, everything, here offer connection: http://zookeeper.apache.org/releases.html. zookeeper-3.4.0is used here, so download the file zookeeper-3.4.0.tar.gz.

Iv. Standalone mode Deployment Zookeeper services

1, new directory: In the directory with the new directory /data/zookeeper.

2, Upload files: Upload zookeeper-3.4.0.tar.gz to /data/zookeeper directory.

3, Decompression: Unzip the package into the current directory,tar xzf zookeeper-3.4.0.tar.gz.

4. Configure the Zookeeper environment variable: Edit the /etc/profile file and add the following code at the end of the file:

1 Export zookeeper_home=/data/zookeeper/zookeeper-3.4. 0 2 Export path= $PATH: $ZOOKEEPER _home/bin
Configuring Zookeeper Environment variables

As shown in the following:

    

Save the file, execute the command source/etc/profile The Mission order takes effect immediately.

5, Configuration Zookeeper

Before starting the Zookeeper service, we need to create a configuration file to configure the Zookeeper service. This file is customarily named Zoo.cfg, under the extracted zookeeper file under the Conf directory can find zoo.cfg file template file zoo_sample.cfg, As shown in the following:

    

Use the command CP zoo_sample.cfg zoo.cfg to copy the zoo_sample.cfg file and rename it to Zoo.cfg as shown in:

    

Edit the Zoo.cfg file, modify the DataDir property value to /data/zookeeper/zdata, as shown in this property is primarily the directory where the data stored by the zookeeper is configured. It can also be a different directory, provided that the directory already exists and if it does not exist, it is new. Here /data/zookeeper/zdata directory I have been built in advance.

    

Comment out Properties Initlimit and Synclimit.

Careful observation can be found here only 3 properties are set, respectively, ticktime=2000, Datadir=/data/zookeeper/zdata, clientport=2181. Ticktime and ClientPort remain the default, which is the minimum requirement for zookeeper in standalone mode. Detailed parsing of these 3 attributes is enclosed in the appendix.

6. Start Zookeeper: Because the zookeeper system environment variable is configured, the zkserver.sh Start command can be executed under any path to start zookeeper. Of course, if you do not configure environment variables, you can only go to /data/zookeeper/zookeeper-3.4.0/bin under the command ./zkserver.sh start to launch Zookeeper Services. As shown in the success:

    

V. Verification

It is very simple to verify that the Zookeeper service is started (or if the service is normal). You can check whether the zookeeper service is running by using the NC send ruok command to the listening port. The command is as follows:

Echo 2181
Check if the Zookeeper service is running

  Ruok(This command is only valid after the Zookeeper environment variable must be configured) The command is OK, that is, ask the Zookeeper service is good, if it is OK, that is, zookeeper service is running, then print Imok (I am okay), As shown in the following:

Vi. Client Connection Zookeeper service

Execute commands under any path zkcli.sh-server localhost:2181 Connection Zookeeper, if no environment variable is configured, you need to /data/zookeeper/zookeeper-3.4.0/ The bin path executes the ./zkcli.sh-server localhost:2181, as shown in:

After the connection is successful, enter the command LS/ You can see the zookeeper service has created a zookeeper node by default, as shown in:

  

At this point, the deployment of zookeeper service in standalone mode is successful, then you can operate zookeeper! The simple operation of zookeeper is described in the next blog post.

Appendix: Detailed description of variables in the above configuration file

1. The Ticktime property specifies the base event unit in zookeeper, in milliseconds. For example, the second is the basic human unit of events, the human time to 1 seconds, 2 seconds, 3 seconds ..., and zookeeper use we give it to set the timing unit to timing.

2. TheDataDir property specifies the location of the data store generated by zookeeper, it is recommended that you do not use the default location, the path that the property value represents must exist, and the path that is not found when zookeeper starts throws an exception.

3. TheClientPort property specifies the port zookeeper is used to listen to the client

Due to limited capacity, if there are deficiencies and errors, but also hope to point out!

Zookeeper Series: Standalone mode deployment Zookeeper service

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.