Zookeeper学习之路——Zookeeper安装(单机模式)

下载Zookeeper

官网下载Zookeeper。
这里写图片描述
下载得到zookeeper-3.4.12.tar.gz文件,准备上传到CentOS 7系统中。

解压Zookeeper

上传完的文件在自己的家目录中,使用解压命令和移动文件命令将文件移动到指定的路径下,当前我使用的路径是/usr/local路径,基本自己安装的软件都是在这个路径下,jdk也是在这个路径下。

tar -zxvf zookeeper-3.4.12.tar.gz
mv zookeeper-3.4.12 /usr/local/

配置环境变量

打开profile文件,加入以下配置信息

vim /etc/profile

配置信息为

#zookeeper configuration
export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.12
export PATH=${ZOOKEEPER_HOME}/bin:$PATH

修改Zookeeper配置文件

解压完的Zookeeper文件目录如下
这里写图片描述
conf下存在着zoo_sample.cfg文件,将改文件复制一份zoo.cfg,(cp zoo_sample.cfg zoo.cfg
并且修改文件信息如下

# 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
dataDir=/usr/local/service/zookeeper/data
dataLogDir=/usr/local/service/zookeeper/logs
# the port at which the clients will connect
clientPort=2181
# 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.
#
# 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

操作zookeeper

启动

[root@localhost zookeeper-3.4.12]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.12/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

查看状态

[root@localhost zookeeper-3.4.12]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.12/bin/../conf/zoo.cfg
Mode: standalone

停止zookeeper

[root@localhost zookeeper-3.4.12]# zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.12/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED

猜你喜欢

转载自blog.csdn.net/u010871004/article/details/80686818