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.8/ zkserver1 cp -r zookeeper-3.4.8/ zkserver2 cp -r zookeeper-3.4.8/ zkserver3
mkdir /tmp/zoo/zk1 mkdir /tmp/zoo/zk2 mkdir /tmp/zoo/zk3
[[email protected]# echo 1 > zk1/zookeeper_server.pid [[email protected]# echo 2 > zk2/zookeeper_server.pid [[email protected]# echo 3 > zk3/zookeeper_server.pid
修改三个配置文件
vi /conf/zk1.cfg
tickTime=2000 initLimit=10 syncLimit=5 dataDir=/tmp/zoo/zk1 clientPort=2181 server.1=192.168.1.165:2888:3888 server.2=192.168.1.165:2889:3889 server.3=192.168.1.165:2890:3890
vi /conf/zk2.cfg
tickTime=2000 initLimit=10 syncLimit=5 dataDir=/tmp/zoo/zk1 clientPort=2182 server.1=localhost:2888:3888 server.2=localhost:2889:3889 server.3=localhost:2890:3890
vi /conf/zk3.cfg
tickTime=2000 initLimit=10 syncLimit=5 dataDir=/tmp/zoo/zk1 clientPort=2183 server.1=localhost:2888:3888 server.2=localhost:2889:3889 server.3=localhost:2890:3890
启动
/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
时间: 2024-10-12 15:54:37