1.关闭防火墙
查看防火墙状态 firewall-cmd --state 关闭防火墙 systemctl stop firewalld.service
开机禁用
sysemctl disable firewalld.service
2.下载zookeeper3.4.6
http://archive.apache.org/dist/zookeeper/
3.zookeeper安装
tar zxvf zookeeper-3.4.6.tar.gz cd zookeeper-3.4.6 cp conf/zoo_sample.cfg conf/zoo.cfg #把zookeeper加入到环境变量 echo -e "# append zk_env export PATH=$PATH:/opt/soft/zookeeper-3.4.6/bin" >> /etc/profile source /etc/profile
4.集群配置
#修改过后的配置文件zoo.cfg,如下: tickTime=2000 initLimit=10 syncLimit=5 dataLogDir=/opt/soft/zookeeper-3.4.6/logs dataDir=/opt/soft/zookeeper-3.4.6/data clientPort=2181 autopurge.snapRetainCount=500 autopurge.purgeInterval=24 server.1= 192.168.231.128:2888:3888 server.2= 192.168.231.129:2888:3888 server.3= 192.168.231.130:2888:3888
#创建相关目录,三台节点都需要
mkdir -p /opt/soft/zookeeper-3.4.6/{logs,data}
创建myid文件
echo "1">>/opt/soft/zookeeper-3.4.6/data/myid
把zookeeper发送到其他服务器
scp -r zookeeper-3.4.6 root@zto2:$PWD
scp -r zookeeper-3.4.6 root@zto3:$PWD
修改对应的myid
启动zookeeper server:
./zkServer.sh start
查看zookeeper状态
./zkServer.sh status
进客户端
./zkCli.sh -server 192.168.231.130:2181