Zookeeper篇:本地安装

这篇具有很好参考价值的文章主要介绍了Zookeeper篇:本地安装。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

官方文档

https://zookeeper.apache.org/doc/current/zookeeperStarted.html

下载Zookeeper

在下面的地址内下载最新的稳定版本:https://zookeeper.apache.org/releases.html
Zookeeper篇:本地安装
Zookeeper篇:本地安装
在linux服务器上执行下面的命令:

wget https://dlcdn.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz

king@king-server:~/workspace/zookeeper$ wget https://dlcdn.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz
--2023-04-01 15:33:03--  https://dlcdn.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz
Resolving dlcdn.apache.org (dlcdn.apache.org)... 2a04:4e42::644, 151.101.2.132
Connecting to dlcdn.apache.org (dlcdn.apache.org)|2a04:4e42::644|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12649765 (12M) [application/x-gzip]
Saving to: ‘apache-zookeeper-3.7.1-bin.tar.gz’

apache-zookeeper-3.7.1-bin.tar.gz            100%[==============================================================================================>]  12.06M  13.5KB/s    in 11m 30s 

2023-04-01 15:44:43 (17.9 KB/s) - ‘apache-zookeeper-3.7.1-bin.tar.gz’ saved [12649765/12649765]

下载asc和sha512

使用下面的命令分别下载:

wget https://downloads.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz.asc

king@king-server:~/workspace/zookeeper$ wget https://downloads.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz.asc
--2023-04-01 16:05:48--  https://downloads.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz.asc
Resolving downloads.apache.org (downloads.apache.org)... 2a01:4f8:10a:201a::2, 2a01:4f9:3a:2c57::2, 135.181.214.104, ...
Connecting to downloads.apache.org (downloads.apache.org)|2a01:4f8:10a:201a::2|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 833 [text/plain]
Saving to: ‘apache-zookeeper-3.7.1-bin.tar.gz.asc’

apache-zookeeper-3.7.1-bin.tar.gz.asc        100%[==============================================================================================>]     833  --.-KB/s    in 0s       

2023-04-01 16:05:50 (303 MB/s) - ‘apache-zookeeper-3.7.1-bin.tar.gz.asc’ saved [833/833]
wget https://downloads.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz.sha512

king@king-server:~/workspace/zookeeper$ wget https://downloads.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz.sha512
--2023-04-01 16:06:29--  https://downloads.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz.sha512
Resolving downloads.apache.org (downloads.apache.org)... 2a01:4f9:3a:2c57::2, 2a01:4f8:10a:201a::2, 88.99.95.219, ...
Connecting to downloads.apache.org (downloads.apache.org)|2a01:4f9:3a:2c57::2|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 163 [text/plain]
Saving to: ‘apache-zookeeper-3.7.1-bin.tar.gz.sha512’

apache-zookeeper-3.7.1-bin.tar.gz.sha512     100%[==============================================================================================>]     163  --.-KB/s    in 0s       

2023-04-01 16:06:30 (46.2 MB/s) - ‘apache-zookeeper-3.7.1-bin.tar.gz.sha512’ saved [163/163]

验证文件的完整性

官方要求必须使用 PGP 签名(.asc文件)或散列(.md5或.sha*文件)验证下载文件的完整性

king@king-server:~/workspace/zookeeper$ ls
apache-zookeeper-3.7.1-bin.tar.gz  apache-zookeeper-3.7.1-bin.tar.gz.asc  apache-zookeeper-3.7.1-bin.tar.gz.sha512

验证文件的哈希值

king@king-server:~/workspace/zookeeper$ sha512sum apache-zookeeper-3.7.1-bin.tar.gz
9103628a50745fa1a289bca666fda4a9c08ec17c55cf13e66887e7ba76e93dbae60a1f1ffd6c10798be3a16069344ecbc00cebb29bf03d9cd7096ccd098ed011  apache-zookeeper-3.7.1-bin.tar.gz

与下载的sha512对比下

king@king-server:~/workspace/zookeeper$ sha512sum apache-zookeeper-3.7.1-bin.tar.gz
9103628a50745fa1a289bca666fda4a9c08ec17c55cf13e66887e7ba76e93dbae60a1f1ffd6c10798be3a16069344ecbc00cebb29bf03d9cd7096ccd098ed011  apache-zookeeper-3.7.1-bin.tar.gz

king@king-server:~/workspace/zookeeper$ cat apache-zookeeper-3.7.1-bin.tar.gz.sha512 
9103628a50745fa1a289bca666fda4a9c08ec17c55cf13e66887e7ba76e93dbae60a1f1ffd6c10798be3a16069344ecbc00cebb29bf03d9cd7096ccd098ed011  apache-zookeeper-3.7.1-bin.tar.gz

单机部署

先将压缩包解压:

tar -zxvf apache-zookeeper-3.7.1-bin.tar.gz

king@king-server:~/workspace/zookeeper$ ls
apache-zookeeper-3.7.1-bin  apache-zookeeper-3.7.1-bin.tar.gz  apache-zookeeper-3.7.1-bin.tar.gz.asc  apache-zookeeper-3.7.1-bin.tar.gz.sha512

进入conf目录:

king@king-server:~/workspace/zookeeper$ cd apache-zookeeper-3.7.1-bin/conf/
king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin/conf$ ls
configuration.xsl  log4j.properties  zoo_sample.cfg

其中zoo_sample.cfg是官方给出的示例文件

官方建议三个主要的配置:

tickTime=2000
dataDir=/var/lib/zookeeper
clientPort=2181

在给出实例中是:

tickTime=2000
dataDir=/tmp/zookeeper
clientPort=2181

可以使用实例默认的配置就可以。

tickTime:ZooKeeper 使用的基本时间单位,以毫秒为单位。它用于执行心跳,最小会话超时将是 tickTime 的两倍。
dataDir:存储内存数据库快照的位置,除非另有说明,否则存储更新数据库的事务日志。
clientPort:侦听客户端连接的端口

这里要在conf目录下新增文件zoo.cfg,然后将zoo_sample.cfg内的配置复制进去,因为启动时读取的配置是zoo_sample.cfg

启动

使用下面的命令启动:

../bin/zkServer.sh start

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin/conf$ ls ../
bin  conf  docs  lib  LICENSE.txt  NOTICE.txt  README.md  README_packaging.md
king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin/conf$ ../bin/zkServer.sh start
Error: JAVA_HOME is not set and java could not be found in PATH.

可以发现这里出现了一个错误,没有找到JAVA_HOME,这里还要安装下jdk。

安装jdk:

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin/conf$ java -version

Command 'java' not found, but can be installed with:

sudo apt install openjdk-11-jre-headless  # version 11.0.18+10-0ubuntu1~20.04.1, or
sudo apt install default-jre              # version 2:1.11-72
sudo apt install openjdk-16-jre-headless  # version 16.0.1+9-1~20.04
sudo apt install openjdk-17-jre-headless  # version 17.0.6+10-0ubuntu1~20.04.1
sudo apt install openjdk-8-jre-headless   # version 8u362-ga-0ubuntu1~20.04.1
sudo apt install openjdk-13-jre-headless  # version 13.0.7+5-0ubuntu1~20.04

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin/conf$ sudo apt install openjdk-8-jre-headless
[sudo] password for king:
...

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin/conf$ java -version
openjdk version "1.8.0_362"
OpenJDK Runtime Environment (build 1.8.0_362-8u362-ga-0ubuntu1~20.04.1-b09)
OpenJDK 64-Bit Server VM (build 25.362-b09, mixed mode)

再次尝试启动:

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin/conf$ ../bin/zkServer.sh start
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../conf/zoo.cfg
Starting zookeeper ... FAILED TO START
king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin/conf$

测试连接

使用下面的命令进行测试:

bin/zkCli.sh -server 127.0.0.1:2181

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin/conf$ ../bin/zkCli.sh -server 127.0.0.1:2181

2023-04-05 04:36:34,559 [myid:127.0.0.1:2181] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1171] - Opening socket connection to server localhost/127.0.0.1:2181.  2023-04-05 04:36:34,559 [myid:127.0.0.1:2181] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1173] - SASL config status: Will not attempt to authenticate using SASL (unknown error)2023-04-05 04:36:34,559 [myid:127.0.0.1:2181] - WARN  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1294] - Session 0x0 for server localhost/127.0.0.1:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException.java.net.ConnectException: Connection refused        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)        at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:716)        at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:344)        at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1283)

发现大量的报错。。。

将配置文件内dataDir修改为:/opt/zkData再次启动:

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin$ bin/zkServer.sh start
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../conf/zoo.cfg
mkdir: cannot create directory ‘/opt/zkData’: Permission denied
Starting zookeeper ... bin/zkServer.sh: line 175: /opt/zkData/zookeeper_server.pid: No such file or directory
FAILED TO WRITE PID

看来并不会自动创建目录(也可能是权限不够用)

创建并修改权限(自行设置权限就好,我这里贪图方便直接777了):

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin$ mkdir /opt/zkData
mkdir: cannot create directory ‘/opt/zkData’: Permission denied
king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin$ sudo mkdir /opt/zkData
king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin$ sudo chmod 777 /opt/zkData/

再次运行:

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin$ bin/zkServer.sh start
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../conf/zoo.cfg
Starting zookeeper ... FAILED TO START

检查日志:

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin$ cd logs
king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin/logs$ ls
zookeeper_audit.log  zookeeper-king-server-king-server.out
king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin/logs$ less zookeeper-king-server-king-server.out

发现错误日志:

2023-04-05 04:50:54,373 [myid:1] - INFO  [main:DefaultSessionIdManager@334] - DefaultSessionIdManager workerName=node0
2023-04-05 04:50:54,374 [myid:1] - INFO  [main:DefaultSessionIdManager@339] - No SessionScavenger set, using defaults
2023-04-05 04:50:54,374 [myid:1] - INFO  [main:HouseKeeper@132] - node0 Scavenging every 660000ms
2023-04-05 04:50:54,377 [myid:1] - WARN  [main:ConstraintSecurityHandler@759] - ServletContext@o.e.j.s.ServletContextHandler@34cd072c{/,null,STARTING} has uncovered http methods for path: /*
2023-04-05 04:50:54,382 [myid:1] - INFO  [main:ContextHandler@915] - Started o.e.j.s.ServletContextHandler@34cd072c{/,null,AVAILABLE}
2023-04-05 04:50:54,386 [myid:1] - ERROR [main:ZooKeeperServerMain@86] - Unable to start AdminServer, exiting abnormally
org.apache.zookeeper.server.admin.AdminServer$AdminServerException: Problem starting AdminServer on address 0.0.0.0, port 8080 and command URL /commands
        at org.apache.zookeeper.server.admin.JettyAdminServer.start(JettyAdminServer.java:188)
        at org.apache.zookeeper.server.ZooKeeperServerMain.runFromConfig(ZooKeeperServerMain.java:155)
        at org.apache.zookeeper.server.ZooKeeperServerMain.initializeAndRun(ZooKeeperServerMain.java:113)
        at org.apache.zookeeper.server.ZooKeeperServerMain.main(ZooKeeperServerMain.java:68)
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:141)
        at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:91)
Caused by: java.io.IOException: Failed to bind to /0.0.0.0:8080
        at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:349)
        at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:310)
        at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
        at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:234)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at org.eclipse.jetty.server.Server.doStart(Server.java:401)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
        at org.apache.zookeeper.server.admin.JettyAdminServer.start(JettyAdminServer.java:179)
        ... 5 more
Caused by: java.net.BindException: Address already in use
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:461)
        at sun.nio.ch.Net.bind(Net.java:453)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:222)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:85)
        at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:344)
        ... 12 more
Unable to start AdminServer, exiting abnormally
2023-04-05 04:50:54,387 [myid:1] - INFO  [main:ZKAuditProvider@42] - ZooKeeper audit is disabled.
2023-04-05 04:50:54,388 [myid:1] - ERROR [main:ServiceUtils@48] - Exiting JVM with code 4

原因是存在其他进程占用了8080端口,检查具体的进程:

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin/logs$ sudo lsof -i :8080
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 2263 root    4u  IPv4  48370      0t0  TCP *:http-alt (LISTEN)
docker-pr 2270 root    4u  IPv6  48375      0t0  TCP *:http-alt (LISTEN)

发现是docker容器占用了进程,检查具体的容器:

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin/logs$ docker ps
CONTAINER ID   IMAGE              COMMAND                  CREATED        STATUS       PORTS                                                  NAMES
7c39ae707be0   importkey_server   "/bin/sh -c './serve…"   2 months ago   Up 2 weeks   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp              server
9c0de2584f09   mysql:8.0.21       "docker-entrypoint.s…"   3 months ago   Up 2 weeks   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   Mysql

发现是以前给老婆写的一个小server占用的。。。因为时间太久就忘了,这里先kill掉这个容器

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin/logs$ docker kill 7c39ae707be0
7c39ae707be0

再次重新启动:

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin$ bin/zkServer.sh start
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

发现已经可以启动成功,使用client测试:

king@king-server:~/workspace/zookeeper/apache-zookeeper-3.7.1-bin$ bin/zkCli.sh -server 127.0.0.1:2181
/usr/bin/java
Connecting to 127.0.0.1:2181
2023-04-05 05:18:30,578 [myid:] - INFO  [main:Environment@98] - Client environment:zookeeper.version=3.7.1-a2fb57c55f8e59cdd76c34b357ad5181df1258d5, built on 2022-05-07 06:45 UTC  
2023-04-05 05:18:30,580 [myid:] - INFO  [main:Environment@98] - Client environment:host.name=king-server
2023-04-05 05:18:30,580 [myid:] - INFO  [main:Environment@98] - Client environment:java.version=1.8.0_362
2023-04-05 05:18:30,580 [myid:] - INFO  [main:Environment@98] - Client environment:java.vendor=Private Build
2023-04-05 05:18:30,580 [myid:] - INFO  [main:Environment@98] - Client environment:java.home=/usr/lib/jvm/java-8-openjdk-amd64/jre
2023-04-05 05:18:30,580 [myid:] - INFO  [main:Environment@98] - Client environment:java.class.path=/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../zookeeper-server/target/classes:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../build/classes:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../zookeeper-server/target/lib/*.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../build/lib/*.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/zookeeper-prometheus-metrics-3.7.1.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/zookeeper-jute-3.7.1.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/zookeeper-3.7.1.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/snappy-java-1.1.7.7.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/slf4j-reload4j-1.7.35.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/slf4j-api-1.7.35.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient_servlet-0.9.0.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient_hotspot-0.9.0.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient_common-0.9.0.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/simpleclient-0.9.0.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/reload4j-1.2.19.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-native-unix-common-4.1.76.Final.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-native-epoll-4.1.76.Final.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-classes-epoll-4.1.76.Final.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/netty-transport-4.1.76.Final.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/netty-resolver-4.1.76.Final.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/netty-handler-4.1.76.Final.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/netty-common-4.1.76.Final.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/netty-codec-4.1.76.Final.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/netty-buffer-4.1.76.Final.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/metrics-core-4.1.12.1.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/jline-2.14.6.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-util-ajax-9.4.43.v20210629.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-util-9.4.43.v20210629.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-servlet-9.4.43.v20210629.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-server-9.4.43.v20210629.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-security-9.4.43.v20210629.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-io-9.4.43.v20210629.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/jetty-http-9.4.43.v20210629.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/jackson-databind-2.13.2.1.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/jackson-core-2.13.2.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/jackson-annotations-2.13.2.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/commons-cli-1.4.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../lib/audience-annotations-0.12.0.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../zookeeper-*.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin/bin/../conf:
2023-04-05 05:18:30,580 [myid:] - INFO  [main:Environment@98] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
2023-04-05 05:18:30,581 [myid:] - INFO  [main:Environment@98] - Client environment:java.io.tmpdir=/tmp
2023-04-05 05:18:30,581 [myid:] - INFO  [main:Environment@98] - Client environment:java.compiler=<NA>
2023-04-05 05:18:30,581 [myid:] - INFO  [main:Environment@98] - Client environment:os.name=Linux
2023-04-05 05:18:30,581 [myid:] - INFO  [main:Environment@98] - Client environment:os.arch=amd64
2023-04-05 05:18:30,581 [myid:] - INFO  [main:Environment@98] - Client environment:os.version=5.4.0-144-generic
2023-04-05 05:18:30,581 [myid:] - INFO  [main:Environment@98] - Client environment:user.name=king
2023-04-05 05:18:30,581 [myid:] - INFO  [main:Environment@98] - Client environment:user.home=/home/king
2023-04-05 05:18:30,581 [myid:] - INFO  [main:Environment@98] - Client environment:user.dir=/home/king/workspace/zookeeper/apache-zookeeper-3.7.1-bin
2023-04-05 05:18:30,581 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.free=51MB
2023-04-05 05:18:30,581 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.max=228MB
2023-04-05 05:18:30,581 [myid:] - INFO  [main:Environment@98] - Client environment:os.memory.total=59MB
2023-04-05 05:18:30,585 [myid:] - INFO  [main:ZooKeeper@657] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@449b2d27
2023-04-05 05:18:30,588 [myid:] - INFO  [main:X509Util@77] - Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation
2023-04-05 05:18:30,592 [myid:] - INFO  [main:ClientCnxnSocket@239] - jute.maxbuffer value is 1048575 Bytes
2023-04-05 05:18:30,601 [myid:] - INFO  [main:ClientCnxn@1735] - zookeeper.request.timeout value is 0. feature enabled=false
Welcome to ZooKeeper!
2023-04-05 05:18:30,608 [myid:127.0.0.1:2181] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1171] - Opening socket connection to server localhost/127.0.0.1:2181.
2023-04-05 05:18:30,608 [myid:127.0.0.1:2181] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1173] - SASL config status: Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2023-04-05 05:18:30,624 [myid:127.0.0.1:2181] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1005] - Socket connection established, initiating session, client: /127.0.0.1:56296, server: localhost/127.0.0.1:2181
2023-04-05 05:18:30,671 [myid:127.0.0.1:2181] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1446] - Session establishment complete on server localhost/127.0.0.1:2181, session id = 0x100075903100000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: 127.0.0.1:2181(CONNECTED) 0] 

完全ok!!!

上面的容器测试时是直接kill掉的,但是应该有些人是需要继续留着的,这时有两个解决方式:

1、修改 ZooKeeper 的 AdminServer 端口:可以编辑 ZooKeeper 的配置文件,将 AdminServer 的端口修改为其他未被占用的端口。在 ZooKeeper 的配置文件 zoo.cfg 中,可以找到 admin.serverPort 参数,将其值修改为其他端口,例如 admin.serverPort=8888。

2、避免使用 Docker 占用 ZooKeeper 默认的 AdminServer 端口:在启动 Docker 容器时,可以通过 -p 参数将容器的端口映射到宿主机的其他端口,以避免占用 ZooKeeper 默认的 AdminServer 端口 8080。
例如,可以使用类似于以下命令启动 Docker 容器,并将容器的 8080 端口映射到宿主机的 8888 端口:docker run -p 8888:8080 <image_name>. 这样,ZooKeeper 将能够使用默认的 8080 端口启动 AdminServer,而不会与 Docker 进程冲突。请注意,<image_name> 是要运行的 Docker 镜像的名称。具体的命令参数可能会因使用的 Docker 版本和镜像而有所不同,根据环境进行相应的调整。文章来源地址https://www.toymoban.com/news/detail-427622.html

到了这里,关于Zookeeper篇:本地安装的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Docker官方文档学习笔记(一):安装Docker Engine(和安装Docker Desktop for Linux二选一)

    参考官方文档 /var/lib/docker 中的内容会被保留,如果要完全删除,继续参考文章最后的卸载教程完成卸载 三种方法,通过仓库安装(推荐),通过DEB包手动安装,以及使用脚本安装。 在安装之前,请让自己熟悉脚本安装的潜在风险和限制: 该脚本需要root或sudo特权才能运行。

    2024年02月12日
    浏览(39)
  • Docker官方文档学习笔记(一):安装、升级、卸载Docker Desktop for Linux(和安装Docker Engine二选一,推荐Docker Engine)

    参考自官方文档Install Docker Desktop on Linux和Install Docker Desktop on Ubuntu 本教程所用系统为Ubuntu22.04 对新手来说有个图形化界面还是挺方便的,可以装上跟着学习笔记(二)熟悉Docker,我是练完手之后卸载了Docker Desktop转而装了Docker Engine,因为当时发现DD4L好像不支持容器内运行图

    2024年02月10日
    浏览(45)
  • 最新Elasticsearch8.4.3 + Kibana8.4.3在云服务器Centos7.9安装部署(参考官方文档)

      最近笔者学习Elasticsearch,官方最新稳定版为 Elasticsearch-8.4.3,想在云服务器上Centos7.9搭建。搭建之路坑多路少啊(指网上的博文教程五花八门,基本都是ES7版本居多,ES8有少数,各种配置参数一头雾水,细节不多说,照搬了踩坑跌得头破血流),对小菜的我来说,简直要

    2024年02月02日
    浏览(60)
  • 写最好的Docker安装最新版MySQL8(mysql-8.0.31)教程(参考Docker Hub和MySQL官方文档)

       MySQL官方安装包下载地址:   https://dev.mysql.com/downloads/mysql/      Docker Hub官方网址:   https://hub.docker.com/     如果需要了解Centos7下MySQL5.7最新版的安装部署,可参考教程【最新MySQL-5.7.40在云服务器Centos7.9安装部署)】。      本教程是笔者参考Docker Hub和MySQL官

    2024年02月01日
    浏览(43)
  • StableDiffusion-webUI环境配置、部署、汉化、扩展超详细步骤 || 服务器Linux Ubuntu/本地Windows || 比官方安装更高自定义度 || anaconda虚拟环境下

    目录 一、代码下载 以下指令用git下载代码(可能不能直接跑通,后续需要修改一些代码,见“ 四、代码修改”部分) 1. 下载 stable-diffusion-webui 仓库 2. 下载其他仓库 二、环境配置 0. 安装anaconda、CUDA、cuDNN 1. 建立并激活新 conda 环境 2. 安装 requirements.txt 中的依赖包 3

    2024年02月10日
    浏览(82)
  • Visual Studio中C++部分的官方文档链接【微软(Microsoft)所有产品的官方文档链接】

    目前(2022年07月),微软官方网站上关于Visual Studio的文档,最老的版本也是VS2015了,如下图所示: 微软所有产品的文档目录: 中文版:https://docs.microsoft.com/zh-CN/documentation/ 英文版:https://docs.microsoft.com/en-us/documentation/ Visual Studio中C++部分的官方文档: 中文版:https://docs.microso

    2024年02月07日
    浏览(65)
  • MySQL官方文档如何查看,MySQL中文文档

    MySQL官网地址:https://dev.mysql.com/doc/ 比如这里我要找InnoDB架构 MySQL 5.1中文文档地址:https://www.mysqlzh.com/

    2024年02月07日
    浏览(40)
  • C# 微软官方学习文档

    链接:https://learn.microsoft.com/zh-cn/dotnet/csharp/ 在C#的学习过程中,我们可以参考微软官方的学习文档。它是一个免费的学习平台,提供了丰富的C#学习路径和教程(如下图),对我们入门到高级应用开发都很有帮助。 如果我们想初步了解可以看 了解如何使用C# 模块: 学习或查

    2024年04月25日
    浏览(44)
  • RTOS官方文档学习

    一个程序可以只有任务、只有协程、二者都有,但不可以通过队列/信号量互相传递数据 任务之间可以互相独立 每个任务分配自己的堆栈,提高了RAM使用率 操作简单、按优先级抢占式执行 抢占容易导致重入(执行任务时被其他线程或进程调用了) 一般用于小型,RAM有限制的

    2024年02月11日
    浏览(39)
  • Opentsdb官方优化文档 - 翻译

    Tuning — OpenTSDB 2.4 documentation As with any database there are many tuning parameters for OpenTSDB that can be used to improve write and read performance. Some of these options are specific to certain backends, others are global. 翻译: 与任何数据库一样,OpenTSDB有许多调优参数可用于提高写和读性能。其中一些选项是特定于

    2024年01月16日
    浏览(96)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包