官网地址Apache ZooKeeper最新版本3.9.5 发布时间6 Mar, 2026软件下载地址Apache Download Mirrors1、解压cd /usr/local/soft/ tar -zxvf apache-zookeeper-3.9.5-bin.tar.gz2、创建数据文件和目录文件在zookeeper的跟目录下创建两个文件夹data和logcd /usr/local/soft/apache-zookeeper-3.9.5-bin/ mkdir data mkdir log3、拷贝配置文件cd /usr/local/soft/apache-zookeeper-3.9.5-bin/conf/ cp zoo_sample.cfg zoo.cfg配置文件更改# The number of milliseconds of each tick tickTime2000 # The number of ticks that the initial # synchronization phase can take initLimit10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir/usr/local/soft/apache-zookeeper-3.9.5-bin/data dataLogDir/usr/local/soft/apache-zookeeper-3.9.5-bin/log # the port at which the clients will connect clientPort2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns60 # # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # https://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # The number of snapshots to retain in dataDir #autopurge.snapRetainCount3 # Purge task interval in hours # Set to 0 to disable auto purge feature #autopurge.purgeInterval1 server.1node11:2888:3888 server.2node12:2888:3888 server.3node13:2888:3888 ## Metrics Providers # # https://prometheus.io Metrics Exporter #metricsProvider.classNameorg.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider #metricsProvider.httpHost0.0.0.0 #metricsProvider.httpPort7000 #metricsProvider.exportJvmInfotrue4、创建服务器myid在data目录下创建一个myid的文件里面的值可以给个任意的值但要和上述服务起server.x对应cd /usr/local/soft/apache-zookeeper-3.9.5-bin/data/ touch myid内容添加1集群系统环境变量添加vi /etc/profileexport ZOOKEEPER_HOME/usr/local/soft/apache-zookeeper-3.9.5-bin export PATH$PATH:$ZOOKEEPER_HOME/bin保存系统环境变量source /etc/profile5、集群拷贝拷贝文件scp -r /usr/local/soft/apache-zookeeper-3.9.5-bin rootnode12:/usr/local/soft/apache-zookeeper-3.9.5-bin scp -r /usr/local/soft/apache-zookeeper-3.9.5-bin rootnode13:/usr/local/soft/apache-zookeeper-3.9.5-bin拷贝环境变量scp /etc/profile rootnode12:/etc/profile scp /etc/profile rootnode13:/etc/profile6、集群myid更改进入到每个节点修改/usr/local/soft/apache-zookeeper-3.9.5-bin/data/myid值vi /usr/local/soft/apache-zookeeper-3.9.5-bin/data/myid其中node12节点中myid文件内容改成2其中node13节点中myid文件内容改成3并执行source /etc/profile关闭集群防火墙7、集群启动推荐8进入到每个节点启动cd /usr/local/soft/apache-zookeeper-3.9.5-bin bin/zkServer.sh start bin/zkServer.sh status8、集群设置脚本启动cd /usr/local/soft/apache-zookeeper-3.9.5-bin/bin/执行文件创建及授权创建文件touch zkStart.sh touch zkStop.sh touch zkStatus.sh授权chmod x zkStart.sh chmod x zkStop.sh chmod x zkStatus.shzkStart.sh中添加#!/bin/bash echo zookeeper start 11,12,13... ssh node11 source /etc/profile;zkServer.sh start ssh node12 source /etc/profile;zkServer.sh start ssh node13 source /etc/profile;zkServer.sh startzkStop.sh中添加#!/bin/bash echo zookeeper start 11,12,13... ssh node11 source /etc/profile;zkServer.sh stop ssh node12 source /etc/profile;zkServer.sh stop ssh node13 source /etc/profile;zkServer.sh stopzkStatus.sh中添加#!/bin/bash echo zookeeper start 11,12,13... ssh node11 source /etc/profile;zkServer.sh status ssh node12 source /etc/profile;zkServer.sh status ssh node13 source /etc/profile;zkServer.sh status9、启动集群集群启动:zkStart.sh集群关闭zkStop.sh集群状态查看zkStatus.sh验证集群启动情况注意启动的时候出现Client SSL: false.这并不是错误。可以忽略在 ZooKeeper 中启动时看到 Client SSL: false 的信息意味着 ZooKeeper 服务器没有启用客户端 SSL/TLS 加密。这意味着客户端与 ZooKeeper 服务器之间的通信不是加密的这可能会带来安全风险尤其是在生产环境中。学习阶段可以不用配置如果配置了会导致后续连接复杂不建议配置如果想配置可参考本文FAQ 问题210、zkCli连接验证zkCli.sh -server 192.168.1.11:2181FAQ1、-bash: /usr/local/soft/apache-zookeeper-3.9.5-bin/bin/zkStop.sh: /bin/bash^M: bad interpreter: No such file or directorysudo yum install dos2unix cd /usr/local/soft/apache-zookeeper-3.9.5-bin/bin/ dos2unix zkStart.sh dos2unix zkStop.sh dos2unix zkStatus.sh2、启动脚本被占用/bin/bash: bad interpreter: Text file busy解决办法fuser 命令名称找到进程号kill查杀3、Client SSL: false解析在 ZooKeeper 中启动时看到 Client SSL: false 的信息意味着 ZooKeeper 服务器没有启用客户端 SSL/TLS 加密。这意味着客户端与 ZooKeeper 服务器之间的通信不是加密的这可能会带来安全风险尤其是在生产环境中。如果你希望启用客户端 SSL/TLS 加密来增强安全性你需要进行以下几步操作初学者不建议操作具体可参照zookeeper开启ssl_清晨的技术博客_51CTO博客生成密钥库和信任库你需要生成一个 Java 密钥库keystore来存储服务器的私钥和证书以及一个信任库truststore来存储客户端信任的 CA 证书。这些证书可以是自签名的也可以是由受信任的证书颁发机构CA签发的。配置 ZooKeeper 服务器在 ZooKeeper 的配置文件通常是zoo.cfg中你需要设置几个属性来启用 SSL。这些属性包括secureClientPort一个用于 SSL/TLS 通信的端口号通常是不同于非加密通信的端口ssl.keystore.location密钥库的路径ssl.keystore.password访问密钥库的密码ssl.truststore.location信任库的路径以及ssl.truststore.password访问信任库的密码。secureClientPort2182ssl.keystore.location/path/to/keystore.jksssl.keystore.passwordkeystore_passwordssl.truststore.location/path/to/truststore.jksssl.truststore.passwordtruststore_password
Linux环境下部署Zookeeper3.9.5(最新版)集群部署
发布时间:2026/6/24 12:26:52
官网地址Apache ZooKeeper最新版本3.9.5 发布时间6 Mar, 2026软件下载地址Apache Download Mirrors1、解压cd /usr/local/soft/ tar -zxvf apache-zookeeper-3.9.5-bin.tar.gz2、创建数据文件和目录文件在zookeeper的跟目录下创建两个文件夹data和logcd /usr/local/soft/apache-zookeeper-3.9.5-bin/ mkdir data mkdir log3、拷贝配置文件cd /usr/local/soft/apache-zookeeper-3.9.5-bin/conf/ cp zoo_sample.cfg zoo.cfg配置文件更改# The number of milliseconds of each tick tickTime2000 # The number of ticks that the initial # synchronization phase can take initLimit10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir/usr/local/soft/apache-zookeeper-3.9.5-bin/data dataLogDir/usr/local/soft/apache-zookeeper-3.9.5-bin/log # the port at which the clients will connect clientPort2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns60 # # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # https://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # The number of snapshots to retain in dataDir #autopurge.snapRetainCount3 # Purge task interval in hours # Set to 0 to disable auto purge feature #autopurge.purgeInterval1 server.1node11:2888:3888 server.2node12:2888:3888 server.3node13:2888:3888 ## Metrics Providers # # https://prometheus.io Metrics Exporter #metricsProvider.classNameorg.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider #metricsProvider.httpHost0.0.0.0 #metricsProvider.httpPort7000 #metricsProvider.exportJvmInfotrue4、创建服务器myid在data目录下创建一个myid的文件里面的值可以给个任意的值但要和上述服务起server.x对应cd /usr/local/soft/apache-zookeeper-3.9.5-bin/data/ touch myid内容添加1集群系统环境变量添加vi /etc/profileexport ZOOKEEPER_HOME/usr/local/soft/apache-zookeeper-3.9.5-bin export PATH$PATH:$ZOOKEEPER_HOME/bin保存系统环境变量source /etc/profile5、集群拷贝拷贝文件scp -r /usr/local/soft/apache-zookeeper-3.9.5-bin rootnode12:/usr/local/soft/apache-zookeeper-3.9.5-bin scp -r /usr/local/soft/apache-zookeeper-3.9.5-bin rootnode13:/usr/local/soft/apache-zookeeper-3.9.5-bin拷贝环境变量scp /etc/profile rootnode12:/etc/profile scp /etc/profile rootnode13:/etc/profile6、集群myid更改进入到每个节点修改/usr/local/soft/apache-zookeeper-3.9.5-bin/data/myid值vi /usr/local/soft/apache-zookeeper-3.9.5-bin/data/myid其中node12节点中myid文件内容改成2其中node13节点中myid文件内容改成3并执行source /etc/profile关闭集群防火墙7、集群启动推荐8进入到每个节点启动cd /usr/local/soft/apache-zookeeper-3.9.5-bin bin/zkServer.sh start bin/zkServer.sh status8、集群设置脚本启动cd /usr/local/soft/apache-zookeeper-3.9.5-bin/bin/执行文件创建及授权创建文件touch zkStart.sh touch zkStop.sh touch zkStatus.sh授权chmod x zkStart.sh chmod x zkStop.sh chmod x zkStatus.shzkStart.sh中添加#!/bin/bash echo zookeeper start 11,12,13... ssh node11 source /etc/profile;zkServer.sh start ssh node12 source /etc/profile;zkServer.sh start ssh node13 source /etc/profile;zkServer.sh startzkStop.sh中添加#!/bin/bash echo zookeeper start 11,12,13... ssh node11 source /etc/profile;zkServer.sh stop ssh node12 source /etc/profile;zkServer.sh stop ssh node13 source /etc/profile;zkServer.sh stopzkStatus.sh中添加#!/bin/bash echo zookeeper start 11,12,13... ssh node11 source /etc/profile;zkServer.sh status ssh node12 source /etc/profile;zkServer.sh status ssh node13 source /etc/profile;zkServer.sh status9、启动集群集群启动:zkStart.sh集群关闭zkStop.sh集群状态查看zkStatus.sh验证集群启动情况注意启动的时候出现Client SSL: false.这并不是错误。可以忽略在 ZooKeeper 中启动时看到 Client SSL: false 的信息意味着 ZooKeeper 服务器没有启用客户端 SSL/TLS 加密。这意味着客户端与 ZooKeeper 服务器之间的通信不是加密的这可能会带来安全风险尤其是在生产环境中。学习阶段可以不用配置如果配置了会导致后续连接复杂不建议配置如果想配置可参考本文FAQ 问题210、zkCli连接验证zkCli.sh -server 192.168.1.11:2181FAQ1、-bash: /usr/local/soft/apache-zookeeper-3.9.5-bin/bin/zkStop.sh: /bin/bash^M: bad interpreter: No such file or directorysudo yum install dos2unix cd /usr/local/soft/apache-zookeeper-3.9.5-bin/bin/ dos2unix zkStart.sh dos2unix zkStop.sh dos2unix zkStatus.sh2、启动脚本被占用/bin/bash: bad interpreter: Text file busy解决办法fuser 命令名称找到进程号kill查杀3、Client SSL: false解析在 ZooKeeper 中启动时看到 Client SSL: false 的信息意味着 ZooKeeper 服务器没有启用客户端 SSL/TLS 加密。这意味着客户端与 ZooKeeper 服务器之间的通信不是加密的这可能会带来安全风险尤其是在生产环境中。如果你希望启用客户端 SSL/TLS 加密来增强安全性你需要进行以下几步操作初学者不建议操作具体可参照zookeeper开启ssl_清晨的技术博客_51CTO博客生成密钥库和信任库你需要生成一个 Java 密钥库keystore来存储服务器的私钥和证书以及一个信任库truststore来存储客户端信任的 CA 证书。这些证书可以是自签名的也可以是由受信任的证书颁发机构CA签发的。配置 ZooKeeper 服务器在 ZooKeeper 的配置文件通常是zoo.cfg中你需要设置几个属性来启用 SSL。这些属性包括secureClientPort一个用于 SSL/TLS 通信的端口号通常是不同于非加密通信的端口ssl.keystore.location密钥库的路径ssl.keystore.password访问密钥库的密码ssl.truststore.location信任库的路径以及ssl.truststore.password访问信任库的密码。secureClientPort2182ssl.keystore.location/path/to/keystore.jksssl.keystore.passwordkeystore_passwordssl.truststore.location/path/to/truststore.jksssl.truststore.passwordtruststore_password