Thursday, 31 May 2018

Step by step ZooKeeper setup on CentOS

[root@sankar-devops opt]# wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.12/zookeeper-3.4.12.tar.gz

[root@sankar-devops opt]# ls -ltrh
total 35M
-rw-r--r--. 1 root root 35M Apr 25 21:17 zookeeper-3.4.12.tar.gz
drwxr-xr-x. 3 root root  60 May 31 02:16 jdk

[root@sankar-devops opt]# tar -xvzf zookeeper-3.4.12.tar.gz 
[root@sankar-devops opt]# ls -l
total 35816
drwxr-xr-x.  3 root root       60 May 31 02:16 jdk
drwxr-xr-x. 10 1000 1000     4096 Mar 27 10:06 zookeeper-3.4.12
-rw-r--r--.  1 root root 36667596 Apr 25 21:17 zookeeper-3.4.12.tar.gz
[root@sankar-devops opt]# 

[root@sankar-devops opt]# cd zookeeper-3.4.12

[root@sankar-devops zookeeper-3.4.12]# mkdir data

Create config file::

[root@sankar-devops conf]# pwd
/opt/zookeeper-3.4.12/conf
[root@sankar-devops conf]# vi zoo.cfg

tickTime=2000
dataDir=/opt/zookeeper-3.4.12/data
clientPort=2181
initLimit=5
syncLimit=2

[root@sankar-devops zookeeper-3.4.12]# cd bin

[root@sankar-devops bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.12/bin/../conf/zoo.cfg
grep: /opt/zookeeper-3.4.12/bin/../conf/zoo.cfg: No such file or directory
mkdir: cannot create directory ‘’: No such file or directory
Starting zookeeper ... STARTED

note: i am executed zookeeper in wrong-path. 

[root@sankar-devops bin]# tail zookeeper.out 
2018-05-31 02:41:43,330 [myid:] - INFO  [main:Environment@100] - Server environment:os.arch=amd64
2018-05-31 02:41:43,330 [myid:] - INFO  [main:Environment@100] - Server environment:os.version=3.10.0-514.el7.x86_64
2018-05-31 02:41:43,330 [myid:] - INFO  [main:Environment@100] - Server environment:user.name=root
2018-05-31 02:41:43,330 [myid:] - INFO  [main:Environment@100] - Server environment:user.home=/root
2018-05-31 02:41:43,331 [myid:] - INFO  [main:Environment@100] - Server environment:user.dir=/opt/zookeeper-3.4.12/bin
2018-05-31 02:41:43,347 [myid:] - INFO  [main:ZooKeeperServer@835] - tickTime set to 2000
2018-05-31 02:41:43,347 [myid:] - INFO  [main:ZooKeeperServer@844] - minSessionTimeout set to -1
2018-05-31 02:41:43,347 [myid:] - INFO  [main:ZooKeeperServer@853] - maxSessionTimeout set to -1
2018-05-31 02:41:43,381 [myid:] - INFO  [main:ServerCnxnFactory@117] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
2018-05-31 02:41:43,404 [myid:] - INFO  [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
[root@sankar-devops bin]# 

[root@sankar-devops bin]# netstat -ntlup |grep 2181
tcp6       0      0 :::2181                 :::*                    LISTEN      9442/java           
[root@sankar-devops bin]# 

[root@sankar-devops bin]# ./zkCli.sh 
Connecting to localhost:2181
2018-05-31 02:43:32,917 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.12-e5259e437540f349646870ea94dc2658c4e44b3b, built on 03/27/2018 03:55 GMT
................................
Welcome to ZooKeeper!
JLine support is enabled
......................................
WATCHER::

WatchedEvent state:SyncConnected type:None path:null

[zk: localhost:2181(CONNECTED) 0] 
[zk: localhost:2181(CONNECTED) 0] 

[root@sankar-devops bin]# ./zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper-3.4.12/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
[root@sankar-devops bin]# 


[root@sankar-devops ~]# jps
11064 QuorumPeerMain
11726 Kafka

12062 Jps

Note: where QuorumPeerMain is related to ZooKeeper daemon 

No comments:

Post a Comment