您的位置:首页 > 运维架构 > Linux

linux中安装zookeper

2016-07-21 10:41 399 查看
Zookeeper是一个协调服务,可以用它来作为配置维护、名字服务、分布式部署;

一、Zookeeper下载

[root@localhost 下载]# wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz  
--2016-01-15 23:15:57--  http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz  
正在解析主机 mirror.bit.edu.cn (mirror.bit.edu.cn)... 114.247.56.117  
正在连接 mirror.bit.edu.cn (mirror.bit.edu.cn)|114.247.56.117|:80... 已连接。  
已发出 HTTP 请求,正在等待回应... 200 OK  
长度:11833706 (11M) [application/octet-stream]  
正在保存至: “zookeeper-3.3.6.tar.gz”  
  
100%[======================================================================================================================================================================================>] 11,833,706   171KB/s 用时 68s      
  
2016-01-15 23:17:07 (170 KB/s) - 已保存 “zookeeper-3.3.6.tar.gz” [11833706/11833706])  

二、解压

[root@localhost local]# tar -zxvf /home/lk/下载/zookeeper-3.3.6.tar.gz   

解压完之后,会在local文件夹下面得到一个zookeeper-3.3.6的文件夹

三、进入到conf目录

[root@localhost local]# cd /usr/local/zookeeper-3.3.6/conf  

四、拷贝zoo_samle.cfg为zoo.cfg

[root@localhost conf]# cp zoo_sample.cfg zoo.cfg  

五、编辑zoo.cfg文件

[root@localhost conf]# 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.  
dataDir=/usr/local/zookeeper  
dataLogDir=/usr/local/zookeeper/log  
# the port at which the clients will connect  
clientPort=2181  
server.1=自己的ip:2888:3888  

六、设置环境变量

[root@localhost conf]# export ZOOKEEPER_INSTALL=/opt/deploy/zookeeper-3.3.6  
[root@localhost conf]# export PATH=$PATH:$ZOOKEEPER_INSTALL/bin  

七、启动

[root@localhost bin]# ./zkServer.sh start  
JMX enabled by default  
Using config: /opt/deploy/zookeeper-3.3.6/bin/../conf/zoo.cfg  
Starting zookeeper ... STARTED  
[root@localhost bin]#   

八、测试zookeeper

[root@localhost bin]# ./zkCli.sh -server 192.168.32.129:2181  

如果是本地连接,那么不需要 -server 192.168.32.129:2181,默认是本地

九、停止

[root@localhost bin]# ./zkServer.sh stop
JMX enabled by default  
Using config: /opt/deploy/zookeeper-3.3.6/bin/../conf/zoo.cfg  
Stoping zookeeper ... STOPED  
[root@localhost bin]#

注意:如果出现拒绝连接,请检查如下:
1、防火墙是否关闭  systemctl stop firewalld

2、需要将192.168.32.129 映射到本地 /etc/hosts文件中,否则无法连接
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: