Zookeeper注册中心的搭建

来源:互联网 发布:单片机制作电子时钟 编辑:程序博客网 时间:2024/06/07 04:06

操作环境

服务器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]# lszookeeper-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]# lsconfiguration.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]# lsconfiguration.xsl  log4j.properties  zoo.cfg  zoo_sample.cfg

3,修改zoo.cfg文件

[root@jdu4e00u53f7 conf]# vim zoo.cfg 

修改内容如下

# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=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/datadataLogDir=/tmp/frank/zookeeper/zookeeper-3.4.9/log# the port at which the clients will connectclientPort=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 startZooKeeper JMX enabled by defaultUsing config: /tmp/frank/zookeeper/zookeeper-3.4.9/bin/../conf/zoo.cfgStarting zookeeper ... STARTED

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

[root@jdu4e00u53f7 bin]# firewall-cmd --zone=public --add-port=2181/tcp --permanentsuccess[root@jdu4e00u53f7 bin]# firewall-cmd --reloadsuccess

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

[root@jdu4e00u53f7 bin]# netstat -tlpn | grep javatcp6       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
原创粉丝点击