您的位置:首页 > 其它

阿里dubbo框架使用系列:开发环境搭建之zookeeper注册中心(单节点)

2016-05-10 02:24 741 查看
dubbo框架需要在注册中心上面登记服务之后才可以进行调用,所以我们必须要先安装注册中心,这里我选择用zookeeper来做注册中心

   首先先下载zookeeper的安装包



linux上我们可以通过命令

wget http://apache.fayea.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz


当然我们也可以直接访问连接    http://apache.fayea.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
下载到windows本地



然后通过flashfxp上传到linux



安装包下载完之后我们解压

<span style="white-space:pre"> </span>tar -zxvf zookeeper-3.4.6.tar.gz



解压完之后我们可以看到解压出来的文件



cd 进入zookeeper文件夹下,创建两个文件夹

<span style="white-space:pre"> </span>mkdir data
<span style="white-space:pre"> </span>mkdir logs



cd 进入conf目录,备份一份zoo_sample.cfg

<span style="white-space:pre"> </span> cp zoo_sample.cfg zoo.cfg



编辑zoo.cfg文件

<span style="white-space:pre"> </span>vi 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.
<pre name="code" class="html"># 这里两个路径就配置我们刚刚创建文件夹的那个路径dataDir=/root/zookeeper-3.4.6/datadataLogDir=/root/zookeeper-3.4.6/logs# 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
#解释一下192.168.1.10是我本机的ip,不知道自己ip的可以在linux里面输入命令ifconfig查看
server.1=192.168.1.10:2888:3888
在/root/zookeeper-3.4.6/data 目录下面创建文件myid 内容为1



进入/etc目录下,打开profile,在文件最末尾添加环境变量





退出保存过后,输入以下命令使修改立即生效

<span style="white-space:pre"> </span>source /etc/profile
修改防火墙使得zookeeper的端口可以被外界访问

<span style="white-space:pre"> </span>vi /etc/sysconfig/iptables



保存完后输入以下命令重启防火墙

<span style="white-space:pre"> </span>service iptables restart
进入zookeeper的安装路径的bin/目录下,启动zk服务

<span style="white-space:pre"> </span>./zkServer.sh start



好了到此zookeeper的安装完毕
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: