Deploying a single Zookeeper

Source: Internet
Author: User

Deployment environment

[Email protected] ~]# UNAME-RM

2.6.32-504.el6.x86_64 x86_64

[Email protected] ~]# cat/etc/redhat-release

CentOS Release 6.6 (Final)

Create a Directory

[[email protected] ~]# mkdir/{softs,app}

Installing the JDK

[Email protected] ~]# cd/softs/

[Email protected] softs]# tar XF jdk-8u77-linux-x64.tar.gz-c/app/

[Email protected] softs]# ln-s/app/jdk1.8.0_77//app/jdk

[Email protected] softs]# Vim/etc/profile

Export JAVA_HOME=/APP/JDK

Export path= $JAVA _home/bin: $JAVA _home/jre/bin: $PATH

Exportclasspath= $CLASSPATH: $JAVA _home/lib: $JAVA _home/$jre/lib: $JAVA _home/lib/tools.jar

[Email protected] softs]# Source/etc/profile

[email protected] softs]# java-version

Java Version "1.8.0_77"

Java (TM) SE runtimeenvironment (build 1.8.0_77-b03)

Java HotSpot (TM) 64-bitserver VM (build 25.77-b03, Mixed mode)

[[Email protected] softs]# CD

Deploying Zookeeper

Installation

[Email protected] ~]# cd/softs/

[Email protected] softs]# wget http://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz

[Email protected] softs]# tar XF zookeeper-3.4.8.tar.gz-c/app/

[Email protected] softs]# ln-s/app/zookeeper-3.4.8//app/zookeeper

[[Email protected] softs]# CD

Configure startup

[Email protected] ~]# cd/app/zookeeper/conf/

[email protected] conf]# CP zoo_sample.cfg ZOO.CFG

[[email protected] conf]# grep ^[a-z] Zoo.cfg

ticktime=2000

Datadir=/data/zookeeper

clientport=2181

[Email protected] ~]# mkdir-p/data/zookeeper

[Email protected] ~]# Vim/etc/profile

Path=/app/zookeeper/bin: $PATH

[Email protected] ~]# Source/etc/profile

[[email protected] ~]# zkserver.sh start

ZooKeeper JMX enabled Bydefault

Using config:/app/zookeeper/bin/. /conf/zoo.cfg

Starting zookeeper ... STARTED

[Email protected] ~]# Netstat-lntp|grep 2181

TCP 0 0::: 2181:::* LISTEN 1286/java

Connection Zookeeper

Java Connection

[Email protected] ~]# Zkcli.sh-server 127.0.0.1:2181

Connecting to localhost:2181

C Connection

[Email protected] ~]# cd/app/zookeeper/src/c

[Email protected] c]#./configure

[[email protected] c]# make

[[email protected] c]# make install

[Email protected] c]#. cli_mt172.0.0.1:2821

[[email protected] c] #LD_LIBRARY_PATH =. CLI_MT 127.0.0.1:2181

Or

[[email protected] c] #LD_LIBRARY_PATH =. Cli_st 127.0.0.1:2181

In the Zookeeper src/c directory, but the client is relatively low in the new version.

Operation Zookeeper

Once connected to zookeeper, you can execute some commands, just like in a file system

List

[zk:127.0.0.1:2181 (CONNECTED) 0] LS/

[Zookeeper]

Create a new Znode

Perform Create/zk_test my_data. This creates a new Znode, and the string my_data is associated with the node

[Zk:127.0.0.1:2181 (CONNECTED) 1] create/zk_test My_data

Created/zk_test

[Zk:127.0.0.1:2181 (CONNECTED) 2] LS/

[Zookeeper, Zk_test]

Verify

You can verify that the data is associated with this znode by command get/zk_test.

[Zk:127.0.0.1:2181 (CONNECTED) 3] Get/zk_test

My_data

Czxid = 0x14

CTime = Sat June 23:41:57CST 2016

Mzxid = 0x14

Mtime = Sat June 23:41:57CST 2016

Pzxid = 0x14

cversion = 0

dataversion = 0

aclversion = 0

Ephemeralowner = 0x0

Datalength = 7

Numchildren = 0

Set up

Changing the data associated with zk_test by the SET command

[Zk:127.0.0.1:2181 (CONNECTED) 4] set/zk_test Kevin

Czxid = 0x14

CTime = Sat June 23:41:57CST 2016

Mzxid = 0x15

Mtime = Sat June 23:49:22CST 2016

Pzxid = 0x14

cversion = 0

Dataversion = 1

aclversion = 0

Ephemeralowner = 0x0

Datalength = 5

Numchildren = 0

[Zk:127.0.0.1:2181 (CONNECTED) 5] Get/zk_test

Kevin

Czxid = 0x14

CTime = Sat June 23:41:57CST 2016

Mzxid = 0x15

Mtime = Sat June 23:49:22CST 2016

Pzxid = 0x14

cversion = 0

Delete

[Zk:127.0.0.1:2181 (CONNECTED) 6] Delete/zk_test

[Zk:127.0.0.1:2181 (CONNECTED) 7] Ls

[Zk:127.0.0.1:2181 (CONNECTED) 8] LS/

[Zookeeper]

Exit

[Zk:127.0.0.1:2181 (CONNECTED)] quit

Quitting ...

Stop Service

[[email protected] ~]# zkserver.sh stop


This article is from the "Chang Jie listen to the Wind People" blog, please make sure to keep this source http://kevinhao.blog.51cto.com/5204735/1787991

Deploying a single Zookeeper

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.