Linux安装Zookeeper

Zookeeper能够做为分布式集群开发,本文是基于Centos7环境下安装的Zookeeper,具体步骤以下文所示:html

(1)下载Zookeeper,这里下载的是zookeeper-3.4.10.tar.gz,能够使用Linux的wget命令,也能够下载好安装包,将其上传至Linux环境中;下载的网址为:apache

http://apache.fayea.com/zookeeper/
复制代码

(2)将其解压到/usr/local路径下,解压的命令以下:服务器

tar -zxvf zookeeper-3.4.10.tar.gz
复制代码

(3)配置环境变量:使用命令分布式

vi /etc/profile
复制代码

查看profile文件的内容,在内容中添加以下语句:ide

在文件末尾添加此段内容: -- 开始和--中间的一段.(注意,尽可能保持环境变量名全大写,下划线隔开. 保持规范) -- 开始ui

export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.10
export PATH=$PATH:$ZOOKEEPER_HOME/bin
复制代码

-- 结束this

(4)进入到zookeeper-3.4.10的conf文件夹下,使用以下命令:spa

cd /usr/local/zookeeper-3.4.10/conf/
复制代码

(5)将zoo.sample.cfg拷贝出一份出来,将文件名强制zoo.cfg,使用以下命令:日志

cp zoo_sample.cfg zoo.cfg
复制代码

(6)使用以下命令对zoo.cfg文件内容进行编辑,code

vi zoo.cfg 
复制代码

-- 按i进入编辑模式. 修改完成以后, esc退出编辑模式, 大写字母Z双击便可保存.

在其后面添加zookeeper的文件路径和日志路径,其内容以下:

#The number of milliseconds of each tick

tickTime=2000

#The number of ticks that the initial

#synchronization phase can take

initLimit=10

#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=/tmp/zookeeper -- 这里要设置一下文件路径 路径必须存在,不存在的话就新建一个呗

dataLogDir=/tmp/zookeeper/log -- 日志路径 路径必须存在,不存在的话就新建一个呗

#the port at which the clients will connect

clientPort=2181 -- 若是是多机器的话,在clientPort处添加服务器的ip

#the maximum number of client connections.

#increase this if you need to handle more clients

#maxClientCnxns=60

#Be sure to read the maintenance section of the

#administrator guide before turning on autopurge.

#zookeeper.apache.org/doc/current…

#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

(7)进入到zookeeper的bin目录下,

cd /usr/local/zookeeper-3.4.10/bin/
复制代码

(8)启动zookeeper的命令为:

./zkServer.sh start
复制代码

若是成功,显示的内容以下:

JMX enabled by default Using config: /usr/local/zookeeper-3.4.10/bin/../conf/zoo.cfg Starting zookeeper ... STARTED

(9)查看zookeeper的状态,检测其是否启动,使用以下命令:

./zkServer.sh status
复制代码

输出的内容以下: JMX enabled by default Using config: /usr/local/zookeeper-3.4.10/bin/../conf/zoo.cfg Mode: standalone (10)中止zookeeper的话,在bin目录下,运行以下命令:

./zkServer.sh stop
复制代码

中止运行zookeeper; 本文到此,zookeeper的安装就算结束了。 若是本文侵权,请联系做者删除

相关文章
相关标签/搜索