[Hadoop] CentOS7安装Zookeeper-3.4.5-cdh5.7.0(单节点)

 

1. Zookeeper下载安装

我的环境使用的套件版本是cdh5.7,所以zookeeper也选择对应的版本下载。

下载解压

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

配置环境变量

[root@hadoop01 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
[root@hadoop01 yum.repos.d]# source /etc/profile

修改zookeeper配置

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

 

2. Zookeeper Server 启动停止

启动

[hadoop@hadoop01 bin]$ ./zkServer.sh start

停止

[hadoop@hadoop01 bin]$ ./zkServer.sh stop

重启

[hadoop@hadoop01 bin]$ ./zkServer.sh restart

查看状态

[hadoop@hadoop01 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运行模式
[hadoop@hadoop01 bin]$ jps
12416 QuorumPeerMain                                           # zk进程名
1668 NodeManager
31557 NameNode
12614 Jps
31692 DataNode
31870 SecondaryNameNode
1551 ResourceManager
[hadoop@hadoop01 bin]$ 

 

3. Zookeeper Client启动

启动一个zk client,连接本地的zk server

[hadoop@hadoop01 bin]$ ./zkCli.sh 
Connecting to localhost:2181
2018-08-24 17:36:40,250 [myid:] - INFO  [main:Environment@100] - 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:Environment@100] - Client environment:host.name=hadoop01
2018-08-24 17:36:40,255 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.8.0_45
2018-08-24 17:36:40,258 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2018-08-24 17:36:40,258 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/usr/java/jdk1.8.0_45/jre
2018-08-24 17:36:40,258 [myid:] - INFO  [main:Environment@100] - 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:Environment@100] - 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:Environment@100] - Client environment:java.io.tmpdir=/tmp
2018-08-24 17:36:40,259 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=
2018-08-24 17:36:40,259 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
2018-08-24 17:36:40,259 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2018-08-24 17:36:40,259 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.10.0-514.el7.x86_64
2018-08-24 17:36:40,259 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=hadoop
2018-08-24 17:36:40,259 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/home/hadoop
2018-08-24 17:36:40,259 [myid:] - INFO  [main:Environment@100] - 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:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@25f38edc
Welcome to ZooKeeper!
2018-08-24 17:36:40,290 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@975] - 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):ClientCnxn$SendThread@852] - 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):ClientCnxn$SendThread@1235] - 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] 

 

你可能感兴趣的:(zookeeper)