RHEL7安装部署ZooKeeper

Posted wzzkaifa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RHEL7安装部署ZooKeeper相关的知识,希望对你有一定的参考价值。

转载请注明出处:jiq?钦‘s technical Blog - 季义钦

 

文章说明:

分布式注冊中心(链接)须要安装的组件包括两个部分:

1、注冊中心服务(Zookeeper)

2、站点(Tomcat服务器) 

此文档摘自分布式注冊中心安装部署的Part-1


安装环境:

[[email protected] etc]# cat/etc/redhat-release

RedHat Enterprise Linux Server release 7.0 (Maipo)

[[email protected] etc]# uname -a

Linuxlocalhost.localdomain 3.10.0-123.el7.x86_64 #1 SMP Mon May 5 11:16:57 EDT 2014x86_64 x86_64 x86_64 GNU/Linux

[[email protected] etc]#

备注:CentOS估计也一样


一、安装JDK

Tomcat服务器的执行和Zookeeper服务的执行都依赖于JRE。

 

二、安装Zookeeper

步骤1:解压

[[email protected] uRegister]# tar –zxvf  zookeeper-3.4.8.tar.gz

 

步骤2:创建数据和日志存放文件夹

[[email protected] uRegister]# mkdir zkData zkLog

 

步骤3:创建/uRegister/zookeeper-3.4.8/conf/zoo.cfg配置文件

[[email protected] conf]#touch zoo.cfg

内容例如以下:

dataDir=/uRegister/zkData

dataLogDir=/uRegister/zkLog

clientPort=2181

tickTime=2000


步骤4:打开防火墙端口

[[email protected] bin]# firewall-cmd --add-port=2181/tcp --permanent

success

[[email protected] bin]# firewall-cmd --reload

success 

 

步骤5:启动

启动Zookeeper服务命令:

[[email protected] bin]# ./zkServer.sh start

ZooKeeper JMX enabled by default

Using config:/uRegister/zookeeper-3.4.8/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

 

用jps名录看Zookeeper服务QuorumPeerMain是否在执行:

[[email protected] bin]# jps

13103 Jps

13065 QuorumPeerMain

10899 Bootstrap

 

还能够查看Zookeeper服务执行状态:

[[email protected] bin]# ./zkServer.sh status

ZooKeeper JMX enabled by default

Using config:/uRegister/zookeeper-3.4.8/bin/../conf/zoo.cfg

Mode: standalone

 

停止Zookeeper服务的命令是:

[[email protected] bin]# ./zkServer.sh stop

ZooKeeper JMX enabled by default

Using config: /uRegister/zookeeper-3.4.8/bin/../conf/zoo.cfg

Stopping zookeeper ... STOPPED

[[email protected] bin]#


步骤6:測试连接:

[[email protected] bin]# ./zkCli.sh -server 192.104.103.170:2181

Connecting to 192.104.103.170:2181

2016-03-24 09:27:26,562 [myid:] - INFO [main:[email protected]] - Client environment:zookeeper.version=3.4.8--1,built on 02/06/2016 03:18 GMT

2016-03-24 09:27:26,565 [myid:] - INFO [main:[email protected]] - Client environment:host.name=localhost

2016-03-24 09:27:26,565 [myid:] - INFO [main:[email protected]] - Client environment:java.version=1.7.0_51

2016-03-24 09:27:26,568 [myid:] - INFO [main:[email protected]] - Client environment:java.vendor=OracleCorporation

2016-03-24 09:27:26,568 [myid:] - INFO [main:[email protected]] - Clientenvironment:java.home=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51-2.4.5.5.el7.x86_64/jre

2016-03-24 09:27:26,568 [myid:] - INFO [main:[email protected]] - Clientenvironment:java.class.path=/uRegister/zookeeper-3.4.8/bin/../build/classes:/uRegister/zookeeper-3.4.8/bin/../build/lib/*.jar:/uRegister/zookeeper-3.4.8/bin/../lib/slf4j-log4j12-1.6.1.jar:/uRegister/zookeeper-3.4.8/bin/../lib/slf4j-api-1.6.1.jar:/uRegister/zookeeper-3.4.8/bin/../lib/netty-3.7.0.Final.jar:/uRegister/zookeeper-3.4.8/bin/../lib/log4j-1.2.16.jar:/uRegister/zookeeper-3.4.8/bin/../lib/jline-0.9.94.jar:/uRegister/zookeeper-3.4.8/bin/../zookeeper-3.4.8.jar:/uRegister/zookeeper-3.4.8/bin/../src/java/lib/*.jar:/uRegister/zookeeper-3.4.8/bin/../conf:

2016-03-24 09:27:26,568 [myid:] - INFO [main:[email protected]] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib

2016-03-24 09:27:26,568 [myid:] - INFO [main:[email protected]] - Client environment:java.io.tmpdir=/tmp

2016-03-24 09:27:26,569 [myid:] - INFO [main:[email protected]] - Client environment:java.compiler=<NA>

2016-03-24 09:27:26,569 [myid:] - INFO [main:[email protected]] - Client environment:os.name=Linux

2016-03-24 09:27:26,569 [myid:] - INFO [main:[email protected]] - Client environment:os.arch=amd64

2016-03-24 09:27:26,569 [myid:] - INFO [main:[email protected]] - Clientenvironment:os.version=3.10.0-123.el7.x86_64

2016-03-24 09:27:26,569 [myid:] - INFO [main:[email protected]] - Client environment:user.name=root

2016-03-24 09:27:26,569 [myid:] - INFO [main:[email protected]] - Client environment:user.home=/root

2016-03-24 09:27:26,569 [myid:] - INFO [main:[email protected]] - Clientenvironment:user.dir=/uRegister/zookeeper-3.4.8/bin

2016-03-24 09:27:26,571 [myid:] - INFO [main:[email protected]] - Initiating client connection, connectString=192.104.103.170:2181sessionTi[email protected]511bfc28

Welcome to ZooKeeper!

2016-03-24 09:27:26,604 [myid:] - INFO [main-SendThread(192.104.103.170:2181):[email protected]] -Opening socket connection to server 192.104.103.170/192.104.103.170:2181. Willnot attempt to authenticate using SASL (unknown error)

2016-03-24 09:27:26,614 [myid:] - INFO [main-SendThread(192.104.103.170:2181):[email protected]] -Socket connection established to 192.104.103.170/192.104.103.170:2181,initiating session

JLine support is enabled

2016-03-24 09:27:26,638 [myid:] - INFO [main-SendThread(192.104.103.170:2181):[email protected]] -Session establishment complete on server 192.104.103.170/192.104.103.170:2181,sessionid = 0x153a639b4560000, negotiated timeout = 30000

 

WATCHER::

 

WatchedEvent state:SyncConnected type:None path:null

[zk: 192.104.103.170:2181(CONNECTED) 0] ls /

[zookeeper]

[zk: 192.104.103.170:2181(CONNECTED) 1] 

以上是关于RHEL7安装部署ZooKeeper的主要内容,如果未能解决你的问题,请参考以下文章

Zookeeper安装部署

Zookeeper安装部署

zookeeper安装及部署

20190426 部署Zookeeper集群

Zookeeper安装部署

zookeeper安装部署