1. 程式人生 > >[Hadoop] CentOS7安裝Zookeeper-3.4.5-cdh5.7.0(單節點)

[Hadoop] CentOS7安裝Zookeeper-3.4.5-cdh5.7.0(單節點)

 

1. Zookeeper下載安裝

我的環境使用的套件版本是cdh5.7,所以zookeeper也選擇對應的版本下載。

下載解壓

[[email protected] software]$ wget http://archive.cloudera.com/cdh5/cdh/5/zookeeper-3.4.5-cdh5.7.0.tar.gz
[[email protected] software]$ tar -zxvf zookeeper-3.4.5-cdh5.7.0.tar.gz -C ~/app/

配置環境變數

[[email protected] yum.repos.d]# vi /etc/profile
export ZK_HOME=/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0
export PATH=$ZK_HOME/bin:$PATH
[
[email protected]
yum.repos.d]# source /etc/profile

修改zookeeper配置

[[email protected] ~]$ cd ~/app/zookeeper-3.4.5-cdh5.7.0/
[[email protected] zookeeper-3.4.5-cdh5.7.0]$ cp conf/zoo_sample.cfg conf/zoo.cfg 
[[email protected] zookeeper-3.4.5-cdh5.7.0]$ vi conf/zoo.cfg 
dataDir=/home/hadoop/tmp/zookeeper

 

2. Zookeeper Server 啟動停止

啟動

[[email protected] bin]$ ./zkServer.sh start

停止

[[email protected] bin]$ ./zkServer.sh stop

重啟

[[email protected] bin]$ ./zkServer.sh restart

檢視狀態

[[email protected] bin]$ ./zkServer.sh status
JMX enabled by default
Using config: /home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin/../conf/zoo.cfg
Mode: standalone                                               # zk執行模式
[had
[email protected]
bin]$ jps 12416 QuorumPeerMain # zk程序名 1668 NodeManager 31557 NameNode 12614 Jps 31692 DataNode 31870 SecondaryNameNode 1551 ResourceManager [[email protected] bin]$

 

3. Zookeeper Client啟動

啟動一個zk client,連線本地的zk server

[[email protected] bin]$ ./zkCli.sh 
Connecting to localhost:2181
2018-08-24 17:36:40,250 [myid:] - INFO  [main:[email protected]] - Client environment:zookeeper.version=3.4.5-cdh5.7.0--1, built on 03/23/2016 18:31 GMT
2018-08-24 17:36:40,255 [myid:] - INFO  [main:[email protected]] - Client environment:host.name=hadoop01
2018-08-24 17:36:40,255 [myid:] - INFO  [main:[email protected]] - Client environment:java.version=1.8.0_45
2018-08-24 17:36:40,258 [myid:] - INFO  [main:[email protected]] - Client environment:java.vendor=Oracle Corporation
2018-08-24 17:36:40,258 [myid:] - INFO  [main:[email protected]] - Client environment:java.home=/usr/java/jdk1.8.0_45/jre
2018-08-24 17:36:40,258 [myid:] - INFO  [main:[email protected]] - Client environment:java.class.path=/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin/../build/classes:/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin/../build/lib/*.jar:/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin/../share/zookeeper/zookeeper-3.4.5-cdh5.7.0.jar:/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin/../share/zookeeper/slf4j-log4j12-1.7.5.jar:/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin/../share/zookeeper/slf4j-api-1.7.5.jar:/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin/../share/zookeeper/netty-3.2.2.Final.jar:/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin/../share/zookeeper/log4j-1.2.16.jar:/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin/../share/zookeeper/jline-2.11.jar:/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin/../src/java/lib/*.jar:/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin/../conf:
2018-08-24 17:36:40,258 [myid:] - INFO  [main:[email protected]] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2018-08-24 17:36:40,258 [myid:] - INFO  [main:[email protected]] - Client environment:java.io.tmpdir=/tmp
2018-08-24 17:36:40,259 [myid:] - INFO  [main:[email protected]] - Client environment:java.compiler=<NA>
2018-08-24 17:36:40,259 [myid:] - INFO  [main:[email protected]] - Client environment:os.name=Linux
2018-08-24 17:36:40,259 [myid:] - INFO  [main:[email protected]] - Client environment:os.arch=amd64
2018-08-24 17:36:40,259 [myid:] - INFO  [main:[email protected]] - Client environment:os.version=3.10.0-514.el7.x86_64
2018-08-24 17:36:40,259 [myid:] - INFO  [main:[email protected]] - Client environment:user.name=hadoop
2018-08-24 17:36:40,259 [myid:] - INFO  [main:[email protected]] - Client environment:user.home=/home/hadoop
2018-08-24 17:36:40,259 [myid:] - INFO  [main:[email protected]] - Client environment:user.dir=/home/hadoop/app/zookeeper-3.4.5-cdh5.7.0/bin
2018-08-24 17:36:40,261 [myid:] - INFO  [main:[email protected]] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 [email protected]
Welcome to ZooKeeper!
2018-08-24 17:36:40,290 [myid:] - INFO  [main-SendThread(localhost:2181):[email protected]] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2018-08-24 17:36:40,375 [myid:] - INFO  [main-SendThread(localhost:2181):[email protected]] - Socket connection established, initiating session, client: /0:0:0:0:0:0:0:1:36280, server: localhost/0:0:0:0:0:0:0:1:2181
[zk: localhost:2181(CONNECTING) 0] 2018-08-24 17:36:40,431 [myid:] - INFO  [main-SendThread(localhost:2181):[email protected]] - Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x1656b3a2ff70000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

[zk: localhost:2181(CONNECTED) 0]