zookeeper叢集安裝

NO IMAGE

zookeeper叢集安裝

機器

IPhost
172.16.185.68hadoop1
172.16.185.69hadoop2
72.16.185.70hadoop3

上傳zk安裝包

進入官網下載,當前使用 zookeeper-3.4.6.tar.gz 版本

解壓

[[email protected] zookeeper-3.4.6]$ tar -zxvf zookeeper-3.4.6.tar.gz -C /data/

配置(先在一臺節點上配置)

3.1新增一個zoo.cfg配置檔案
$ZOOKEEPER/conf
mv zoo_sample.cfg zoo.cfg

3.2修改配置檔案(zoo.cfg)
dataDir=/data/zookeeper-3.4.6/data

server.1=hadoop1:2888:3888
server.2=hadoop2:2888:3888
server.3=hadoop3:2888:3888

3.3在(dataDir=/data/zookeeper-3.4.6/data)建立一個myid檔案,裡面內容是server.N中的N(server.2裡面內容為2)
echo "1" > myid

3.4將配置好的zk拷貝到其他節點
scp -r /data/zookeeper-3.4.6/ hadoop2:/data/
scp -r /data/zookeeper-3.4.6/ hadoop3:/data/

3.5注意:在其他節點上一定要修改myid的內容
在hadoop2應該講myid的內容改為2 (echo "2" > /data/zookeeper-3.4.6/data/myid)
在hadoop3應該講myid的內容改為3 (echo "3" > /data/zookeeper-3.4.6/data/myid)

啟動叢集

分別啟動zk
/data/zookeeper-3.4.6/bin/zkServer.sh start
檢查啟動狀態
[[email protected] data]$ /data/zookeeper-3.4.6/bin/zkServer.sh status
JMX enabled by default
Using config: /data/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: leader

本地連線

[[email protected] software]$ /data/zookeeper-3.4.6/bin/zkCli.sh 
Connecting to localhost:2181
2018-04-08 15:45:46,561 [myid:] - INFO  [main:[email protected]] - Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2018-04-08 15:45:46,568 [myid:] - INFO  [main:[email protected]] - Client environment:host.name=hadoop1
2018-04-08 15:45:46,568 [myid:] - INFO  [main:[email protected]] - Client environment:java.version=1.8.0_144
2018-04-08 15:45:46,571 [myid:] - INFO  [main:[email protected]] - Client environment:java.vendor=Oracle Corporation
2018-04-08 15:45:46,571 [myid:] - INFO  [main:[email protected]] - Client environment:java.home=/data/java/jre
2018-04-08 15:45:46,571 [myid:] - INFO  [main:[email protected]] - Client environment:java.class.path=/data/zookeeper-3.4.6/bin/../build/classes:/data/zookeeper-3.4.6/bin/../build/lib/*.jar:/data/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/data/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/data/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/data/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/data/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/data/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/data/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/data/zookeeper-3.4.6/bin/../conf:.:/data/java/jre/lib/rt.jar:/data/java/lib/dt.jar:/data/java/lib/tools.jar
2018-04-08 15:45:46,572 [myid:] - INFO  [main:[email protected]] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2018-04-08 15:45:46,572 [myid:] - INFO  [main:[email protected]] - Client environment:java.io.tmpdir=/tmp
2018-04-08 15:45:46,572 [myid:] - INFO  [main:[email protected]] - Client environment:java.compiler=<NA>
2018-04-08 15:45:46,572 [myid:] - INFO  [main:[email protected]] - Client environment:os.name=Linux
2018-04-08 15:45:46,572 [myid:] - INFO  [main:[email protected]] - Client environment:os.arch=amd64
2018-04-08 15:45:46,572 [myid:] - INFO  [main:[email protected]] - Client environment:os.version=2.6.32-358.14.1.el6.mz150203.x86_64
2018-04-08 15:45:46,572 [myid:] - INFO  [main:[email protected]] - Client environment:user.name=hadoop
2018-04-08 15:45:46,573 [myid:] - INFO  [main:[email protected]] - Client environment:user.home=/home/hadoop
2018-04-08 15:45:46,573 [myid:] - INFO  [main:[email protected]] - Client environment:user.dir=/data/software
2018-04-08 15:45:46,575 [myid:] - INFO  [main:[email protected]] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 [email protected]
Welcome to ZooKeeper!
2018-04-08 15:45:46,630 [myid:] - INFO  [main-SendThread(localhost:2181):[email protected]] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2018-04-08 15:45:46,719 [myid:] - INFO  [main-SendThread(localhost:2181):[email protected]] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2018-04-08 15:45:46,734 [myid:] - INFO  [main-SendThread(localhost:2181):[email protected]] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x16270e61c81000d, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] ls /
[zookeeper, yarn-leader-election, hadoop-ha, hbase]