zookeeper手动安装-ubuntu2204 1.首先去官网下载最新的zookeeper二进制软件包 https://zookeeper.apache.org/ 2.官网文档 https://zookeeper.apache.org/doc/r3.6.2/zookeeperStarted.html#sc_InstallingSingleMode 3.官方依赖介绍 https://zookeeper.apache.org/doc/r3.8.4/zookeeperAdmin.html#sc_systemReq https://zookeeper.apache.org/doc/r3.6.4/zookeeperAdmin.html#sc_requiredSoftware 4.历史版本下载地址 https://archive.apache.org/dist/zookeeper/ 5.下载zookerrper二进制软件包 wget wget -P /usr/local/src https://archive.apache.org/dist/zookeeper/zookeeper-3.8.4/apache-zookeeper-3.8.4-bin.tar.gz 6.解压软件到/usr/local/下 tar -xf /usr/local/src/apache-zookeeper-3.8.4-bin.tar.gz -C /usr/local/ 7.创建软连接方便后期更新版本使用 ln -sv /usr/local/apache-zookeeper-3.8.4-bin/ /usr/local/zookeeper 8.添加环境变量方便后期命令调用 8.1添加环境变量 echo "PATH=/usr/local/zookeeper/bin:$PATH" > /etc/profile.d/zookeeper.sh 8.2让环境变量生效 source /etc/profile.d/zookeeper.sh 9.默认临时配置文件重命名,修改为zoo.cfg可使用名称 cp /usr/local/zookeeper/conf/zoo_sample.cfg /usr/local/zookeeper/conf/zoo.cfg 10.过滤zoo.cfg配置内的可用文件配置 grep -Ev "#|^$" /usr/local/zookeeper/conf/zoo.cfg 解释: tickTime=2000 #服务器与服务器之间的单次心跳检测时间间隔,单位为毫秒 initLimit=10 #集群中leader 服务器与follower服务器初始连接心跳次数,即多少个 2000 毫秒 syncLimit=5 #leader 与follower之间检测发送和应答的心跳次数,如果该follower在时间段5*2000不能与leader进行通信,此follower将不可用 dataDir=/var/lib/zookeeper #自定义的zookeeper保存数据的目录 clientPort=2181 #客户端连接 Zookeeper 服务器的端口,Zookeeper会监听这个端口,接受客户端的访问请求 11.安装JDK,生成环境建议用oracle的JDK apt update && apt install openjdk-11-jdk -y 12.启动 ZooKeeper 12.1#查看选项帮助 root@zookeeper-1:~# zkServer.sh --help /usr/bin/java ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Usage: /usr/local/zookeeper/bin/zkServer.sh [--config <conf-dir>] {start|start-foreground|stop|version|restart|status|print-cmd} 12.2后台启动,#注意:如果配置service,zkServer.sh和systemctl不要混用,否则无法启动 root@zookeeper-1:~# zkServer.sh start /usr/bin/java ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Starting zookeeper ... STARTED 12.3验证ZooKeeper服务状态 root@zookeeper-1:~# zkServer.sh status /usr/bin/java ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Client port found: 2181. Client address: localhost. Client SSL: false. Mode: standalone 12.4查看zookeeper端口 root@zookeeper-1:~# ss -ntpl|grep 2181 LISTEN 0 50 *:2181 *:* users:(("java",pid=4294,fd=56))