在centos6.5中安装zookeeper集群

简介html

 ZooKeeper服务器是用Java编写建立,它运行在JVM。因此须要使用JDK 6或更高版本,在这里就不说在centos安装jdk环境了,直接进入正题,我搭建的是java

192.168.0.2,linux

192.168.0.4,git

192.168.0.5,三台机器上的zookeeper集群,下面演示的是,192.168.0.4的搭建过程,其它两台机器相似apache

一、首先我/usr/software/目录下有zookeeper-3.4.5.tar.gz源码包vim

[root@jacky software]# ls -l
总用量 190220
-rw-r--r--. 1 root root   8938514 12月 30 11:06 apache-tomcat-7.0.73.tar.gz
-rw-r--r--. 1 root root  27768439 12月 30 11:18 dubbo-admin-2.8.4.war
-rw-r--r--. 1 root root   4885101 12月 29 21:29 git-2.0.0.tar.gz
-rw-r--r--. 1 root root 136775360 12月 28 22:31 jdk-7u80-linux-i586.rpm
-rw-r--r--. 1 root root  16402010 10月 25 19:57 zookeeper-3.4.5.tar.gz

二、把源码包解压到/usr/local/路径下,并修改文件名称centos

[root@jacky software]# tar -xvzf zookeeper-3.4.5.tar.gz -C /usr/local/
[root@jacky software]# cd /usr/local/
[root@jacky local]# mv zookeeper-3.4.5.tar.gz zookeeper

三、进入到zookeeper的conf目录下,将zoo_sample.cfg这个文件复制为zoo.cfg(必须是这个文件)tomcat

[root@jacky jacky]# cd /usr/local/zookeeper/conf
[root@jacky local]# mv zoo_sample.cfg zoo.cfg

四、修改zoo.cfg文件内容服务器

# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/usr/local/zookeeper/data        #修改数据路径
# the port at which the clients will connect
clientPort=2181
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.0=192.168.0.2:2888:3888    #修改三台机器zookeeper集群
server.1=192.168.0.4:2888:3888
server.2=192.168.0.5:2888:3888

五、在zookeeper目录下创建个新文件夹data(不建启动zookeeper会报错ide

[root@jacky zookeeper]# mkdir data

六、在data目录下新建文件myid,文件内容为0,与server.0相对应

[root@jacky data]# vim myid

七、配置zookeeper环境变量

[root@jacky data]# vim /etc/profile

 在文件末尾加上

 export JAVA_HOME=/usr/java/jdk1.7.0_80
 export ZOOKEEPER_HOME=/usr/local/zookeeper
 export PATH=$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$PATH
 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

而后source /etc/profile文件

到这里集群就搭建完成了

八、启动192.168.0.4机器的zookeeper

[root@jacky conf]# zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... already running as process 13667.
[root@jacky conf]# zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Mode: leader
[root@jacky conf]# 
相关文章
相关标签/搜索