Zookeeper Distributed Service Framework is used to solve some data management problems commonly encountered in distributed applications, such as: Unified Naming Service, State Synchronization service, cluster management, distributed application configuration item management, etc. This paper mainly introduces the installation, configuration and application of zookeeper from the angle of users.
Stand-alone mode
Zookeeper can be installed in a single machine, this application mode is mainly used in the test or demo case, in the production environment is generally not used.
1. You can first download the latest installation package from Zookeeper's official website: http://www.apache.org/dist/zookeeper/
2. Upload the zookeeper-3.4.8.tar.gz to the/home/hadoop directory that you just downloaded
3, Decompression:
TAR-ZXVF zookeeper-3.4.8.tar.gz
4. Rename:
MV Zookeeper-3.4.8.tar.gz Zookeeper
5. Modify Environment variables:
Vim/etc/profile
At the end of the file add:
Export Zookeeper_home=/home/hadoop/zookeeperexport path= $PATH: $ZOOKEEPER _home/bin
Recompile the file:
Source/etc/profile
6, modify the Zookeeper configuration file
CD/HOME/HADOOP/ZOOKEEPER/CONFCP zoo_sample.cfg Zoo.cfgvim zoo.cfg
Modify:
Datadir=/home/hadoop/zookeeper/data
(Create the Data directory under the/home/hadoop/zookeeper/directory)
7. Start Zookeeper:
zkserver.sh
zkserver.sh status #可查看zookeeper是否正常启动, if normal startup should be as
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/8A/9F/wKiom1g1XLGCy55oAAAocIgiWTA665.png "title=" 2.png " alt= "Wkiom1g1xlgcy55oaaaocigiwta665.png"/>
8. Client Connection Zookeeper
zkcli.sh
Connect to Zkserver after a few seconds:
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/8A/9C/wKioL1g1XXrSxDgJAACvOq9LslU664.png "title=" 333. PNG "alt=" Wkiol1g1xxrsxdgjaacvoq9lslu664.png "/>
To this zookeeper has been installed and started to complete 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0028.gif "alt=" J_0028.gif "/>
Zookeeper command-line operations:
Run zkcli.sh– Server <ip> go to command line tool
650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>650 "this.width=650;" src= "http ://s3.51cto.com/wyfs02/m02/8a/a0/wkiom1g1y5md_bxjaaswx2hnsqw153.png "title=" 33311.png "alt=" wKiom1g1Y5mD_ Bxjaaswx2hnsqw153.png "/>
Analysis Creation Node:
-S: Serialization
-E: Short.
Type:
To create a transient non-serialized node:-E
Create short Serialization:-S – e
Create persistent non-serialization: Empty
Create persistent Serialization:-S
1. Use ls command to view the current ZooKeeper What is included in the:
[Zk:202.115.36.251:2181 (CONNECTED) 1] LS/
2. Create a new Znode , using Create/zk MyData . This command creates a new Znode node " ZK " and the string associated with it:
[Zk:202.115.36.251:2181 (CONNECTED) 2] Create/zk MyData
3. We run Get command to confirm Znode whether to include the string we created:
[Zk:202.115.36.251:2181 (CONNECTED) 3] Get/zk
4, below we pass Set command to ZK to set the associated string:
[Zk:202.115.36.251:2181 (CONNECTED) 4] set/zk "ZSL"
5, below we will just create the Znode Delete:
[Zk:202.115.36.251:2181 (CONNECTED) 5] Delete/zk
This article is from the "Simplelife" blog, make sure to keep this source http://simplelife.blog.51cto.com/9954761/1875882
Install zookeeper under Linux (standalone version)