1. Install and prepare a virtual machine (vmware, VirtualBox).
2. Use the connection tool to connect (Xshell, electerm and other tools, the electerm tool I use).
use
ip address or ip addr
To view the virtual machine address. If you are using a local area network, you need to set a bridging network and copy the physical address. If it is a local virtual machine, you don't need to.
Connect using the connection tool (electerm)
If you see it, the following interface indicates that the connection is successful.
3. Download zookeeper
zookeeper official download address
The 3.6.3 of zookeeper I downloaded here is connected as follows
4. Build environment
Switch to the opt directory
cd /opt
Create the modules directory and the software directory (parent-child relationship, or save it directly to opt without creating it. I made a classification).
mkdir -p /opt/modules/software
Check whether the creation is successful (if not, this step can be omitted)
ls
5. Upload zookeeper file
6. Unzip the zookeeper package
Switch to software
cd ./modules/software
Check to see if the zookeeper package exists
ls
If it does not exist, it may be uploaded to another path or the upload failed.
Unzip the zookeeper compressed file to / opt/modules
tar -zxvf apache-zookeeper-3.6.3-bin.tar.gz -C /opt/modules/
If there are no errors, the decompression is successful.
7. Deployment and operation
Switch to the installation path of zookeeper
cd /opt/modules
Modify the name of the zookeeper file (the name is too long for easy operation and can not be modified)
mv apache-zookeeper-3.6.3-bin/ zookeeper3.6.3
Switch to the configuration directory of zookeeper
cd zookeeper3.6.3/conf/
Create a data folder
mkdir /opt/modules/zookeeper3.6.3/data
Copy a zoo_sample.cfg configuration file and change its name to zoo_cfg
cp zoo_sample.cfg zoo.cfg
Modify zoo_cfg configuration
vi zoo.cfg or vim zoo.cfg
If you use VIM to report centos vim command not found, you can try installing vim
yum install -y vim
Edit again
Modified configuration (optional, or keep the default value)
tickTime = 2000 # Data storage location of zookeeper (recommended modification) dataDir = /opt/zookeeper3.6.3/data clientPort = 2181 initLimit = 5 syncLimit = 2
If the current directory is the zookeeper installation directory, you can use the
pwd
Modify after obtaining
Press ESC - > Press Shift +: key in English or half angle status, and enter wq! Exit editing.
Run zookeeper
/opt/modules/zookeeper3.6.3/bin/zkServer.sh start
If you see the following results, the operation is successful
Connection test via zkCli
/opt/modules/zookeeper3.6.3/bin/zkCli.sh
The following characters will be output
/usr/bin/java Connecting to localhost:2181 2021-09-29 09:41:25,479 [myid:] - INFO [main:Environment@98] - Client environment:zookeeper.version=3.6.3--6401e4ad2087061bc6b9f80dec2d69f2e3c8660a, built on 04/08/2021 16:35 GMT 2021-09-29 09:41:25,546 [myid:] - INFO [main:Environment@98] - Client environment:host.name=zookeeper-standlone 2021-09-29 09:41:25,546 [myid:] - INFO [main:Environment@98] - Client environment:java.version=1.8.0_302 2021-09-29 09:41:25,548 [myid:] - INFO [main:Environment@98] - Client environment:java.vendor=Red Hat, Inc. 2021-09-29 09:41:25,548 [myid:] - INFO [main:Environment@98] - Client environment:java.home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64/jre 2021-09-29 09:41:25,548 [myid:] - INFO [main:Environment@98] - Client environment:java.class.path=/opt/modules/zookeeper3.6.3/bin/../zookeeper-server/target/classes:/opt/modules/zookeeper3.6.3/bin/../build/classes:/opt/modules/zookeeper3.6.3/bin/../zookeeper-server/target/lib/*.jar:/opt/modules/zookeeper3.6.3/bin/../build/lib/*.jar:/opt/modules/zookeeper3.6.3/bin/../lib/zookeeper-prometheus-metrics-3.6.3.jar:/opt/modules/zookeeper3.6.3/bin/../lib/zookeeper-jute-3.6.3.jar:/opt/modules/zookeeper3.6.3/bin/../lib/zookeeper-3.6.3.jar:/opt/modules/zookeeper3.6.3/bin/../lib/snappy-java-1.1.7.jar:/opt/modules/zookeeper3.6.3/bin/../lib/slf4j-log4j12-1.7.25.jar:/opt/modules/zookeeper3.6.3/bin/../lib/slf4j-api-1.7.25.jar:/opt/modules/zookeeper3.6.3/bin/../lib/simpleclient_servlet-0.6.0.jar:/opt/modules/zookeeper3.6.3/bin/../lib/simpleclient_hotspot-0.6.0.jar:/opt/modules/zookeeper3.6.3/bin/../lib/simpleclient_common-0.6.0.jar:/opt/modules/zookeeper3.6.3/bin/../lib/simpleclient-0.6.0.jar:/opt/modules/zookeeper3.6.3/bin/../lib/netty-transport-native-unix-common-4.1.63.Final.jar:/opt/modules/zookeeper3.6.3/bin/../lib/netty-transport-native-epoll-4.1.63.Final.jar:/opt/modules/zookeeper3.6.3/bin/../lib/netty-transport-4.1.63.Final.jar:/opt/modules/zookeeper3.6.3/bin/../lib/netty-resolver-4.1.63.Final.jar:/opt/modules/zookeeper3.6.3/bin/../lib/netty-handler-4.1.63.Final.jar:/opt/modules/zookeeper3.6.3/bin/../lib/netty-common-4.1.63.Final.jar:/opt/modules/zookeeper3.6.3/bin/../lib/netty-codec-4.1.63.Final.jar:/opt/modules/zookeeper3.6.3/bin/../lib/netty-buffer-4.1.63.Final.jar:/opt/modules/zookeeper3.6.3/bin/../lib/metrics-core-3.2.5.jar:/opt/modules/zookeeper3.6.3/bin/../lib/log4j-1.2.17.jar:/opt/modules/zookeeper3.6.3/bin/../lib/json-simple-1.1.1.jar:/opt/modules/zookeeper3.6.3/bin/../lib/jline-2.14.6.jar:/opt/modules/zookeeper3.6.3/bin/../lib/jetty-util-ajax-9.4.39.v20210325.jar:/opt/modules/zookeeper3.6.3/bin/../lib/jetty-util-9.4.39.v20210325.jar:/opt/modules/zookeeper3.6.3/bin/../lib/jetty-servlet-9.4.39.v20210325.jar:/opt/modules/zookeeper3.6.3/bin/../lib/jetty-server-9.4.39.v20210325.jar:/opt/modules/zookeeper3.6.3/bin/../lib/jetty-security-9.4.39.v20210325.jar:/opt/modules/zookeeper3.6.3/bin/../lib/jetty-io-9.4.39.v20210325.jar:/opt/modules/zookeeper3.6.3/bin/../lib/jetty-http-9.4.39.v20210325.jar:/opt/modules/zookeeper3.6.3/bin/../lib/javax.servlet-api-3.1.0.jar:/opt/modules/zookeeper3.6.3/bin/../lib/jackson-databind-2.10.5.1.jar:/opt/modules/zookeeper3.6.3/bin/../lib/jackson-core-2.10.5.jar:/opt/modules/zookeeper3.6.3/bin/../lib/jackson-annotations-2.10.5.jar:/opt/modules/zookeeper3.6.3/bin/../lib/commons-cli-1.2.jar:/opt/modules/zookeeper3.6.3/bin/../lib/audience-annotations-0.5.0.jar:/opt/modules/zookeeper3.6.3/bin/../zookeeper-*.jar:/opt/modules/zookeeper3.6.3/bin/../zookeeper-server/src/main/resources/lib/*.jar:/opt/modules/zookeeper3.6.3/bin/../conf: 2021-09-29 09:41:25,549 [myid:] - INFO [main:Environment@98] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 2021-09-29 09:41:25,549 [myid:] - INFO [main:Environment@98] - Client environment:java.io.tmpdir=/tmp 2021-09-29 09:41:25,549 [myid:] - INFO [main:Environment@98] - Client environment:java.compiler=<NA> 2021-09-29 09:41:25,549 [myid:] - INFO [main:Environment@98] - Client environment:os.name=Linux 2021-09-29 09:41:25,549 [myid:] - INFO [main:Environment@98] - Client environment:os.arch=amd64 2021-09-29 09:41:25,549 [myid:] - INFO [main:Environment@98] - Client environment:os.version=3.10.0-1160.42.2.el7.x86_64 2021-09-29 09:41:25,549 [myid:] - INFO [main:Environment@98] - Client environment:user.name=root 2021-09-29 09:41:25,549 [myid:] - INFO [main:Environment@98] - Client environment:user.home=/root 2021-09-29 09:41:25,549 [myid:] - INFO [main:Environment@98] - Client environment:user.dir=/opt/modules/zookeeper3.6.3/conf 2021-09-29 09:41:25,549 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.free=23MB 2021-09-29 09:41:25,551 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.max=228MB 2021-09-29 09:41:25,551 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.total=29MB 2021-09-29 09:41:25,556 [myid:] - INFO [main:ZooKeeper@1006] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@379619aa 2021-09-29 09:41:25,559 [myid:] - INFO [main:X509Util@77] - Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation 2021-09-29 09:41:25,566 [myid:] - INFO [main:ClientCnxnSocket@239] - jute.maxbuffer value is 1048575 Bytes 2021-09-29 09:41:25,573 [myid:] - INFO [main:ClientCnxn@1736] - zookeeper.request.timeout value is 0. feature enabled=false Welcome to ZooKeeper! 2021-09-29 09:41:25,588 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1181] - Opening socket connection to server localhost/127.0.0.1:2181. 2021-09-29 09:41:25,588 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1183] - SASL config status: Will not attempt to authenticate using SASL (unknown error) JLine support is enabled 2021-09-29 09:41:25,662 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1013] - Socket connection established, initiating session, client: /127.0.0.1:52286, server: localhost/127.0.0.1:2181 2021-09-29 09:41:25,699 [myid:localhost:2181] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1448] - Session establishment complete on server localhost/127.0.0.1:2181, session id = 0x100003ad51e0000, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: localhost:2181(CONNECTED) 0]
Congratulations, zookeeper single node deployment is successful.
How to stop the zookeeper single node service?
Exit zkCli
quit
Stop zookeeper service
/opt/modules/zookeeper3.6.3/bin/zkServer.sh stop
If you see the following results, the stop is successful.
So far, the deployment of zookeeper single node in Centos7 has been completed. If this article helps you, please give me a like. Thank you.