消息中间件之zookper安装部署
Posted w787815
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了消息中间件之zookper安装部署相关的知识,希望对你有一定的参考价值。
消息中间件之zookper安装部署
jdk可以在官网或者网上下载
[[email protected] tools]# chmod 755 jdk-8u40-linux-x64.rpm [[email protected] 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... [[email protected] 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) [[email protected] tools]# mkdir zk1 zk2 zk3 [[email protected] tools]# cd zk1/ [[email protected] zk1]# ls zookeeper-3.4.6.tar.gz [[email protected] zk1]# tar xf zookeeper-3.4.6_.tar.gz zookeeper-3.4.6 zookeeper-3.4.6_.tar.gz [[email protected] zk1]# cd zookeeper-3.4.6
创建日志目录和数据存放的目录
[[email protected] zookeeper-3.4.6]# mkdir dataDir dataLogDir [[email protected] zookeeper-3.4.6]# cd dataDir/ [[email protected] dataDir]# touch myid #创建一个myid的文件 [[email protected] dataDir]# echo "1" >> myid #编号为1 [[email protected] dataDir]# cd .. [[email protected] zookeeper-3.4.6]# cd conf/ [[email protected] conf]# ls configuration.xsl log4j.properties zoo_sample.cfg [[email protected] conf]# mv zoo_sample.cfg zoo.cfg #修改为zoo.cfg [[email protected] conf]# ls configuration.xsl log4j.properties zoo.cfg [[email protected] 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 [[email protected] tools]# cd zk1/ [[email protected] zk1]# ls zookeeper-3.4.6 zookeeper-3.4.6_.tar.gz [[email protected] zk1]# cp -rf zookeeper-3.4.6 /home/zsq/tools/zk2 [[email protected] zk1]# cp -rf zookeeper-3.4.6 /home/zsq/tools/zk3
修改zk2和zk3
[[email protected] dataDir]# pwd /home/zsq/tools/zk2/zookeeper-3.4.6/dataDir [[email protected] 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 [[email protected] dataDir]# pwd /home/zsq/tools/zk3/zookeeper-3.4.6/dataDir [[email protected] 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
[[email protected] zookeeper-3.4.6]# cd bin/ [[email protected] bin]# ls # zkServer.cmd是windows下的运行程序 README.txt zkCleanup.sh zkCli.cmd zkCli.sh zkEnv.cmd zkEnv.sh zkServer.cmd zkServer.sh [[email protected] 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
[[email protected] bin]# cat README.txt zkCleanup.sh zkCli.cmd zkCli.sh zkEnv.cmd zkEnv.sh zkServer.cmd zkServer.sh zookeeper.out
相应的命令启动另外两台,进入到相应的路径
[[email protected] 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
[[email protected] 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...
以上是关于消息中间件之zookper安装部署的主要内容,如果未能解决你的问题,请参考以下文章