1.Zookeeper的下载与解压
通过后面的链接下载Zookeeper: Zookeeper下载
在此我们下载zookeeper-3.4.5
下载后解压至安装目录下,本文我们解压到目录:/opt/zookeeper-3.4.8
$:tar -xzvf zookeeper-3.4.8.tar.gz -C /opt/
如下图所示:
2.zookeeper的环境变量的配置:
为了今后操作方便,我们需要对Zookeeper的环境变量进行配置,方法如下:
在/etc/profile文件中加入如下的内容:
#set zookeeper environment export ZOOKEEPER_HOME=/opt/zookeeper-3.4.8
export PATH=$PATH:$ZOOKEEPER_HOME/bin:$ZOOKEEPER_HOME/conf
然后 source /etc/profile 刷新一下配置
-----------------------------------------------------------------------------------------------------------------------------------------
3.zookeeper伪集群部署
复制三个zookeeper
cp -r zookeeper-3.4./ zkserver1
cp -r zookeeper-3.4./ zkserver2
cp -r zookeeper-3.4./ zkserver3
mkdir /tmp/zoo/zk1
mkdir /tmp/zoo/zk2
mkdir /tmp/zoo/zk3
[root@VM# echo > zk1/zookeeper_server.pid
[root@VM# echo > zk2/zookeeper_server.pid
[root@VM# echo > zk3/zookeeper_server.pid
修改三个配置文件
vi /conf/zk1.cfg
tickTime=
initLimit=
syncLimit=
dataDir=/tmp/zoo/zk1
clientPort= server.=192.168.1.165::
server.=192.168.1.165::
server.=192.168.1.165::
vi /conf/zk2.cfg
tickTime=
initLimit=
syncLimit=
dataDir=/tmp/zoo/zk1
clientPort= server.=localhost::
server.=localhost::
server.=localhost::
vi /conf/zk3.cfg
tickTime=
initLimit=
syncLimit=
dataDir=/tmp/zoo/zk1
clientPort= server.=localhost::
server.=localhost::
server.=localhost::
启动
/bin/zkServer.sh start zk1.cfg
/bin/zkServer.sh start zk2.cfg
/bin/zkServer.sh start zk3.cfg
#查看节点状态
zkServer.sh status zk1.cfg
zkServer.sh status zk2.cfg
zkServer.sh status zk3.cfg
查看ZooKeeper物理文件目录结构 (yum -y install tree)
tree -L 3 /tmp/zoo
zookeeper命令行操作 客户端连接
/bin/zkCli.sh -server localhost:2181