Linux下安装Zookeeper

Zookeeper是一个协调服务,可以用它来作为配置维护、名字服务、分布式部署;

下面,我来分享一下在Linux下安装Zookeeper的整个步骤,让大家少走弯路。


一、Zookeeper下载

官网下载:http://www.apache.org/dyn/closer.cgi/zookeeper/


二、解压


解压完之后,将文件复制到linux服务器上面的指定路径:/usr/local


三、进入到conf目录

四、拷贝zoo_samle.cfg为zoo.cfg

cp zoo_sample.cfg zoo.cfg  


五、编辑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=192.168.32.129:2888:3888  




六、设置环境变量

vim /etc/profile

#zookeeper
export ZOOKEEPER_HOME = /usr/local/zookeeper/
export PATH = $ZOOKEEPER_HOME/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  
八、测试zookeeper

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

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


注意:如果出现拒绝连接,请检查如下:

1、防火墙是否关闭  systemctl stop firewalld

2、需要将192.168.32.129 映射到本地 /etc/hosts文件中,否则无法连接





-----------------------------------------------------------------------------------------------------

完成单机版的zk部署之后,我又用三台阿里云服务ECS搭建一个zk的集群,启动完成之后,查看启动状态./zkServer.sh status老是报错:

Cannot open channel to 2 at election address hadoop1/10.0.0.17:3888                                                    
最后是集群的配置中,我用的是公网地址,之后改成私有地址,问题解决。



                
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值