- 安装:
tar -zxvf zookeeper-3.4.6.tar.gz |
(2) conf目录下,修改zoo.cfg dataDir 集群信息,conf目录下(具体配置见下表) cp zoo_sample.cfg zoo.cfg |
新建data目录: mkdir -p /app/zookeeper-3.4.6/data |
# 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. dataDir=/app/zookeeper-3.4.6/data # 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 server.0=192.168.56.101:2888:3888 server.1=192.168.56.102:2888:3888 server.2=192.168.56.103:2888:3888 |
echo "0" > /app/zookeeper-3.4.6/data/myid |
|
- 配置环境变量
(1)vi /etc/profile #set zookeeper environment export ZK_HOME=/app/zookeeper-3.4.6 export PATH=$PATH:$ZK_HOME/bin (2)生效环境变量 source /etc/profile |
- 主要命令脚本
启动zookeeper服务 |
zkServer.sh start |
停止命令: |
zkServer.sh stop |
重启命令: |
zkServer.sh restart |
查看集群节点状态: |
zkServer.sh status |
- 问题
- 需要关闭防火墙
查看防火墙状态: systemctl status firewalld.service 绿的running表示防火墙开启 执行关闭命令: systemctl stop firewalld.service 再次执行查看防火墙命令:systemctl status firewalld.service 执行开机禁用防火墙自启命令 : systemctl disable firewalld.service 启动:systemctl start firewalld.service 防火墙随系统开启启动 : systemctl enable firewalld.service firewall-cmd --permanent --add-port=3306/tcp service firewalld restart |
2,日志文件 zookeeper.out (建议修改目录,否则,日志生产是在当前执行命令的路径下)
(1)修改 ZK_HOME/conf/log4j.properties 文件: zookeeper.log.dir=/app/zookeeper-3.4.6/logs zookeeper.tracelog.dir=/app/zookeeper-3.4.6/logs
if [ "x${ZOO_LOG_DIR}" = "x" ] then ZOO_LOG_DIR="/app/zookeeper-3.4.6/logs" fi |