1、文件下载
本文档演示安装zookeeper-3.7.2版本。
进入官网下载:https://downloads.apache.org/zookeeper/zookeeper-3.7.2/
使用wget命令下载:
su root
mkdir /data/zookeeper
cd /data/zookeeper
wget https://downloads.apache.org/zookeeper/zookeeper-3.7.2/apache-zookeeper-3.7.2-bin.tar.gz
(如果没有安装wget,先安装yum install -y wget
)
直接使用浏览器访问下载地址:https://downloads.apache.org/zookeeper/zookeeper-3.7.2/apache-zookeeper-3.7.2-bin.tar.gz
2、环境准备
zookeeper是java语言编写的,需提前安装配置JDK环境,此版本zookeeper使用JDK8环境即可。
可参考:https://blog.csdn.net/xiao_yu_gan/article/details/124015831
3、安装配置
将下载好的zookeeper压缩包上传到服务器指定目录,这里以 /data/zookeeper 为例。
①解压压缩包
tar -zxvf apache-zookeeper-3.7.2-bin.tar.gz
②新建存放节点、日志的文件夹
cd /data/zookeeper/apache-zookeeper-3.7.2-bin
mkdir data
mkdir logs
③编辑配置文件
cd /data/zookeeper/apache-zookeeper-3.7.2-bin/conf
复制zoo_sample.cfg文件,命名为zoo.cfg
cp zoo_sample.cfg zoo.cfg
使用vi zoo.cfg
命令编辑此配置文件,按照下面指示修改:
存放数据节点的目录,根据自己实际情况配置
dataDir=/data/zookeeper/apache-zookeeper-3.7.2-bin/data
存放日志信息的目录,根据自己实际情况配置
dataLogDir=/data/zookeeper/apache-zookeeper-3.7.2-bin/logs
4、启动验证
①启动服务端
cd /data/zookeeper/apache-zookeeper-3.7.2-bin/bin
./zkServer.sh start
控制台出现下面信息,则启动成功:
ZooKeeper JMX enabled by default
Using config: /data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
查看服务端状态:
[root@localhost bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: standalone
②启动客户端
cd /data/zookeeper/apache-zookeeper-3.7.2-bin/bin
./zkCli.sh
控制台信息:
[root@localhost bin]# ./zkCli.sh
Connecting to localhost:2181
2022-04-25 16:31:54,777 [myid:] - INFO [main:Environment@98] - Client environment:zookeeper.version=3.7.2--6401e4ad2087061bc6b9f80dec2d69f2e3c8660a, built on 04/08/2021 16:35 GMT
2022-04-25 16:31:54,785 [myid:] - INFO [main:Environment@98] - Client environment:host.name=localhost
2022-04-25 16:31:54,785 [myid:] - INFO [main:Environment@98] - Client environment:java.version=1.8.0_161
2022-04-25 16:31:54,786 [myid:] - INFO [main:Environment@98] - Client environment:java.vendor=Oracle Corporation
2022-04-25 16:31:54,786 [myid:] - INFO [main:Environment@98] - Client environment:java.home=/data/zookeeper/jdk1.8.0_161/jre
2022-04-25 16:31:54,786 [myid:] - INFO [main:Environment@98] - Client environment:java.class.path=/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../zookeeper-server/target/classes:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../build/classes:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../zookeeper-server/target/lib/*.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../build/lib/*.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/zookeeper-prometheus-metrics-3.7.2.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/zookeeper-jute-3.7.2.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/zookeeper-3.7.2.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/snappy-java-1.1.7.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/slf4j-log4j12-1.7.25.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/slf4j-api-1.7.25.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/simpleclient_servlet-0.6.0.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/simpleclient_hotspot-0.6.0.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/simpleclient_common-0.6.0.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/simpleclient-0.6.0.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/netty-transport-native-unix-common-4.1.63.Final.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/netty-transport-native-epoll-4.1.63.Final.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/netty-transport-4.1.63.Final.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/netty-resolver-4.1.63.Final.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/netty-handler-4.1.63.Final.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/netty-common-4.1.63.Final.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/netty-codec-4.1.63.Final.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/netty-buffer-4.1.63.Final.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/metrics-core-3.2.5.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/log4j-1.2.17.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/json-simple-1.1.1.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/jline-2.14.6.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/jetty-util-ajax-9.4.39.v20210325.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/jetty-util-9.4.39.v20210325.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/jetty-servlet-9.4.39.v20210325.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/jetty-server-9.4.39.v20210325.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/jetty-security-9.4.39.v20210325.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/jetty-io-9.4.39.v20210325.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/jetty-http-9.4.39.v20210325.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/jackson-databind-2.10.5.1.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/jackson-core-2.10.5.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/jackson-annotations-2.10.5.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/commons-cli-1.2.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../lib/audience-annotations-0.5.0.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../zookeeper-*.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/data/zookeeper/apache-zookeeper-3.7.2-bin/bin/../conf:.:/data/zookeeper/jdk1.8.0_161/lib/dt.jar:/data/zookeeper/jdk1.8.0_161/lib/tools.jar
2022-04-25 16:31:54,787 [myid:] - INFO [main:Environment@98] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2022-04-25 16:31:54,787 [myid:] - INFO [main:Environment@98] - Client environment:java.io.tmpdir=/tmp
2022-04-25 16:31:54,787 [myid:] - INFO [main:Environment@98] - Client environment:java.compiler=<NA>
2022-04-25 16:31:54,787 [myid:] - INFO [main:Environment@98] - Client environment:os.name=Linux
2022-04-25 16:31:54,787 [myid:] - INFO [main:Environment@98] - Client environment:os.arch=amd64
2022-04-25 16:31:54,787 [myid:] - INFO [main:Environment@98] - Client environment:os.version=3.10.0-693.el7.x86_64
2022-04-25 16:31:54,787 [myid:] - INFO [main:Environment@98] - Client environment:user.name=root
2022-04-25 16:31:54,787 [myid:] - INFO [main:Environment@98] - Client environment:user.home=/root
2022-04-25 16:31:54,787 [myid:] - INFO [main:Environment@98] - Client environment:user.dir=/data/zookeeper/apache-zookeeper-3.7.2-bin/bin
2022-04-25 16:31:54,787 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.free=23MB
2022-04-25 16:31:54,788 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.max=247MB
2022-04-25 16:31:54,789 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.total=29MB
2022-04-25 16:31:54,792 [myid:] - INFO [main:ZooKeeper@1006] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@5aaa6d82
2022-04-25 16:31:54,798 [myid:] - INFO [main:X509Util@77] - Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation
2022-04-25 16:31:54,805 [myid:] - INFO [main:ClientCnxnSocket@239] - jute.maxbuffer value is 1048575 Bytes
2022-04-25 16:31:54,820 [myid:] - INFO [main:ClientCnxn@1736] - zookeeper.request.timeout value is 0. feature enabled=false
2022-04-25 16:31:54,827 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1181] - Opening socket connection to server localhost/127.0.0.1:2181.
2022-04-25 16:31:54,827 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - SASL config status: Will not attempt to authenticate using SASL (unknown error)
Welcome to ZooKeeper!
JLine support is enabled
2022-04-25 16:31:54,963 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1013] - Socket connection established, initiating session, client: /127.0.0.1:42174, server: localhost/127.0.0.1:2181
2022-04-25 16:31:55,005 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1448] - Session establishment complete on server localhost/127.0.0.1:2181, session id = 0x100015a1b180002, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0]
标签:bin,..,zookeeper,centos7,3.7,apache,data
From: https://www.cnblogs.com/sili-future/p/17845742.html