Zookeeper注册中心的搭建

操作环境

服务器centos7.3

下载安装zookeeper

1,下载解压zookeeper

[root@jdu4e00u53f7 zookeeper]# wget http://mirrors.shuosc.org/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz
[root@jdu4e00u53f7 zookeeper]# tar -zxvf zookeeper-3.4.9.tar.gz
[root@jdu4e00u53f7 zookeeper]# ls
zookeeper-3.4.9  zookeeper-3.4.9.tar.gz

2,拷贝zookeeper-3.4.9/conf/zoo_sample.cfg文件重命名为 zoo.cfg

[root@jdu4e00u53f7 zookeeper]# cd zookeeper-3.4.9
[root@jdu4e00u53f7 zookeeper-3.4.9]# cd conf/
[root@jdu4e00u53f7 conf]# ls
configuration.xsl  log4j.properties  zoo_sample.cfg
[root@jdu4e00u53f7 conf]# cp /tmp/frank/zookeeper/zookeeper-3.4.9/conf/zoo_sample.cfg zoo.cfg
[root@jdu4e00u53f7 conf]# ls
configuration.xsl  log4j.properties  zoo.cfg  zoo_sample.cfg

3,修改zoo.cfg文件

[root@jdu4e00u53f7 conf]# vim zoo.cfg 

修改内容如下

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/tmp/frank/zookeeper/zookeeper-3.4.9/data
dataLogDir=/tmp/frank/zookeeper/zookeeper-3.4.9/log
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

4,启动zookeeper

[root@jdu4e00u53f7 bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /tmp/frank/zookeeper/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

5,开启端口,2181如果有安全组,也需要在安全组中开启,并刷新防火墙

[root@jdu4e00u53f7 bin]# firewall-cmd --zone=public --add-port=2181/tcp --permanent
success
[root@jdu4e00u53f7 bin]# firewall-cmd --reload
success

6,查看是否启动成功,查看2181端口是否已经在监听

[root@jdu4e00u53f7 bin]# netstat -tlpn | grep java
tcp6       0      0 :::8080                 :::*                    LISTEN      871/java            
tcp6       0      0 :::18178                :::*                    LISTEN      5111/java           
tcp6       0      0 :::2181                 :::*                    LISTEN      5111/java           
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      871/java            
tcp6       0      0 :::8009                 :::*                    LISTEN      871/java   

7,测试zookeeper

[root@jdu4e00u53f7 bin]# ./zkCli.sh -server 116.196.65.198:2181

你可能感兴趣的:(Zookeeper注册中心的搭建)