Ubuntu18下安装和配置Zookeeper3.3.3

从下载目录解压到usr/local目录下

sudo tar -zxf ~/下载/zookeeper-3.3.3.tar.gz -C /usr/local/

Ubuntu18下安装和配置Zookeeper3.3.3_第1张图片
进入zookeeper3.3.3的conf目录,创建配置文件,复制其中的zoo_sample.zfg并命名为zoo.cfg。

复制配置文件命令:
	sudo cp ./zoo_sample.cfg ./zoo.cfg
编辑配置文件命令:
	sudo gedit /zoo.cfg

在这里插入图片描述

zoo.cfg配置文件内容如下:

# The number of milliseconds of each tick
# 心跳间隔,毫秒
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
# 配置zookeeper接受客户端初始化连接时最长能忍受多少个时间心跳间隔。
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
# 这个配置项标识 Leader 与 Follower 之间发送消息,请求和应答时间长度,最长不能超过多少个 tickTime 的时间长度。
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-3.3.3/data
#日志存放的位置
dataLogDir=/usr/local/zookeeper-3.3.3/zookeeperLog
# 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

# 2888,3888 are election port
# 2888端口是zookeeper服务之间的通讯的端口,3888是zookeeper与其他应用程序通讯的端口。
server.1=localhost:2888:3888

接下来在zookeeper-3.3.3目录下创建快照存储路径data。

进入目录:
	cd /usr/local/zookeeper-3.3.3/
创建文件夹:
	sudo mkdir data

再在data目录中创建新文件myid,命令如下:

cd /usr/local/zookeeper-3.3.3/data
sudo touch myid

编辑myid文件,命令如下:

sudo gedit myid

然后插入内容为1,并且保存,1表示当前的zookeeper定义为第一台服务器。

然后就编辑系统配置文件,设置环境变量。

sudo vim ~/.bashrc
sudo vim /etc/profile

环境变量内容如下:

按i键进入编辑模式,按Esc退出编辑模式,然后输入:wq进行保存(勿忘了分号)。

export ZOOKEEPER_HOME=/usr/local/zookeeper-3.3.3
export PATH=$PATH:$ZOOKEEPER_HOME/bin

Ubuntu18下安装和配置Zookeeper3.3.3_第2张图片
环境变量设置完成后进行刷新。

source ~/.bashrc
source /etc/profile

你可能感兴趣的:(zookeeper)