标签:unp cmd 5.4 cat 检查 zookeeper state nts 程序
消息中间件之zookper安装部署
jdk可以在官网或者网上下载
[root@q tools]# chmod 755 jdk-8u40-linux-x64.rpm [root@q tools]# rpm -i jdk-8u40-linux-x64.rpm Unpacking JAR files... rt.jar... jsse.jar... charsets.jar... tools.jar... localedata.jar... jfxrt.jar... plugin.jar... javaws.jar... deploy.jar... [root@q tools]# java -version #检查版本 java version "1.8.0_40" Java(TM) SE Runtime Environment (build 1.8.0_40-b25) Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode) [root@q tools]# mkdir zk1 zk2 zk3 [root@q tools]# cd zk1/ [root@q zk1]# ls zookeeper-3.4.6.tar.gz [root@q zk1]# tar xf zookeeper-3.4.6_.tar.gz zookeeper-3.4.6 zookeeper-3.4.6_.tar.gz [root@q zk1]# cd zookeeper-3.4.6
创建日志目录和数据存放的目录
[root@q zookeeper-3.4.6]# mkdir dataDir dataLogDir [root@q zookeeper-3.4.6]# cd dataDir/ [root@q dataDir]# touch myid #创建一个myid的文件 [root@q dataDir]# echo "1" >> myid #编号为1 [root@q dataDir]# cd .. [root@q zookeeper-3.4.6]# cd conf/ [root@q conf]# ls configuration.xsl log4j.properties zoo_sample.cfg [root@q conf]# mv zoo_sample.cfg zoo.cfg #修改为zoo.cfg [root@q conf]# ls configuration.xsl log4j.properties zoo.cfg [root@q conf]# vim zoo.cfg dataDir=/home/zsq/tools/zk1/zookeeper-3.4.6/dataDir dataLogDir=/home/zsq/tools/zk1/zookeeper-3.4.6/dataLogDir # the port at which the c lients will connect clientPort=2181 #端口 server.1=127.0.0.1:8880:7770 #server.1的1是刚才创建的编号1,8880是选举的端口,7770是心跳检测的端口 server.2=127.0.0.1:8881:7771 #另外两台中的一台 server.3=127.0.0.1:8882:7772 [root@q tools]# cd zk1/ [root@q zk1]# ls zookeeper-3.4.6 zookeeper-3.4.6_.tar.gz [root@q zk1]# cp -rf zookeeper-3.4.6 /home/zsq/tools/zk2 [root@q zk1]# cp -rf zookeeper-3.4.6 /home/zsq/tools/zk3
修改zk2和zk3
[root@q dataDir]# pwd /home/zsq/tools/zk2/zookeeper-3.4.6/dataDir [root@q dataDir]# cat myid 2 dataDir=/home/zsq/tools/zk2/zookeeper-3.4.6/dataDir dataLogDir=/home/zsq/tools/zk2/zookeeper-3.4.6/dataLogDir # the port at which the clients will connect clientPort=2182 server.1=127.0.0.1:8880:7770 server.2=127.0.0.1:8881:7771 server.3=127.0.0.1:8882:7772 [root@q dataDir]# pwd /home/zsq/tools/zk3/zookeeper-3.4.6/dataDir [root@q dataDir]# cat myid 3 dataDir=/home/zsq/tools/zk3/zookeeper-3.4.6/dataDir dataLogDir=/home/zsq/tools/zk3/zookeeper-3.4.6/dataLogDir # the port at which the clients will connect clientPort=2183 server.1=127.0.0.1:8880:7770 server.2=127.0.0.1:8881:7771 server.3=127.0.0.1:8882:7772
启动 zk1 zk2 zk3
[root@q zookeeper-3.4.6]# cd bin/ [root@q bin]# ls # zkServer.cmd是windows下的运行程序 README.txt zkCleanup.sh zkCli.cmd zkCli.sh zkEnv.cmd zkEnv.sh zkServer.cmd zkServer.sh [root@q bin]# ./zkServer.sh start #启动 JMX enabled by default Using config: /home/zsq/tools/zk1/zookeeper-3.4.6/bin/../conf/zoo.cfg Starting zookeeper ... STARTED
启动完成会在目录下生成zookeeper.out
[root@q bin]# cat README.txt zkCleanup.sh zkCli.cmd zkCli.sh zkEnv.cmd zkEnv.sh zkServer.cmd zkServer.sh zookeeper.out
相应的命令启动另外两台,进入到相应的路径
[root@q zookeeper-3.4.6]# netstat -ntpl|grep "218" tcp 0 0 :::2181 :::* LISTEN 5727/java tcp 0 0 :::2182 :::* LISTEN 5673/java tcp 0 0 :::2183 :::* LISTEN 5640/java
连接测试,能连进去就表面OK
[root@q bin]# ./zkCli.sh -server 127.0.0.1:2181 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: 127.0.0.1:2181(CONNECTED) 0] ls / [zookeeper] [zk: 127.0.0.1:2181(CONNECTED) 1] ls /zookeeper [quota] [zk: 127.0.0.1:2181(CONNECTED) 2] ls /zookeeper/quota [] [zk: 127.0.0.1:2181(CONNECTED) 3] get /zookeeper/quota cZxid = 0x0 ctime = Thu Jan 01 08:00:00 CST 1970 mZxid = 0x0 mtime = Thu Jan 01 08:00:00 CST 1970 pZxid = 0x0 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 0 numChildren = 0 [zk: 127.0.0.1:2181(CONNECTED) 4] quit Quitting...
标签:unp cmd 5.4 cat 检查 zookeeper state nts 程序
原文地址:https://www.cnblogs.com/w787815/p/9532464.html