- 1. 安装
- 2. 配置
- 3. 启动zookeeper集群
- 4. 查看启动情况
创建3个ecs实例,在每台机器上下载zookeeper
下载地址:
https://mirrors.cnnic.cn/apache/zookeeper/stable/apache-zookeeper-3.6.3-bin.tar.gz
http://mirrors.cnnic.cn/apache 1. 安装
# 解压gz包 tar -zxvf apache-zookeeper-3.6.3-bin.tar.gz2. 配置
- 创建一个数据目录和日志目录
mkdir /root/data mkdir /root/log
- 在创建的数据目录下创建myid文件
touch /root/data/myid ehoc 1 >> /root/data/myid # 每个节点的编号不一样
- 复制zoo_sample.cfg文件
# 在zookeeper解压后的conf目录下 cp zoo_sample.cfg zoo.cfg
- 增加集群节点信息
# server.1 这里的数字和之前创建的myid文件中写入的编号一致 quorumListenOnAllIPs=true server.1=ip:2888:3888 server.2=ip:2888:3888 server.3=ip:2888:3888
- 最终的配置文件
# 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=/root/data dataLogDir=/root/log # 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 ## Metrics Providers # # https://prometheus.io Metrics Exporter #metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider #metricsProvider.httpPort=7000 #metricsProvider.exportJvmInfo=true quorumListenOnAllIPs=true server.1=ip1:2888:3888 server.2=ip2:2888:3888 server.3=ip3:2888:38883. 启动zookeeper集群
./bin/zkServer.sh start4. 查看启动情况
./bin/zkServer.sh status netstat -nltp 查看端口监听情况



