Spark

Zookeeper 安装和配置

2019-07-07  本文已影响0人  帅气的外表之下

官网下载安装包

https://zookeeper.apache.org/releases.html 

拷贝到linux,进行解压

sudo tar -zxf /home/gandi/bin/share/apache-zookeeper-3.5.5.tar.gz -C /usr/local/
cd /usr/local
sudo mv ./apache-zookeeper-3.5.5/ ./zookeeper
sudo chown -R gandi ./zookeeper/
sudo gedit ~/.bashrc
    export ZOOKEEPER_HOME=/usr/local/zookeeper
    export PATH=$ZOOKEEPER_HOME/bin:$PATH
source ~/.bashrc

伪分布式集群配置

单机中配置多个端口,产生多个进程,用多个进程模拟多台机器,需要在conf目录下配置多个配置文件,并且需要配置多个myid文件。创建多个配置文件。

sudo gedit /usr/local/zookeeper/conf/zoo1.cfg

ckTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/data1
clientPort=2181
server.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890


sudo gedit /usr/local/zookeeper/conf/zoo2.cfg

ckTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/data2
clientPort=2182
server.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890


sudo gedit /usr/local/zookeeper/conf/zoo3.cfg

ckTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/local/zookeeper/data3
clientPort=2183
server.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890

集群模式下还要配置一个文件 myid,目录为dataDir配置的目录

echo 1 >> /usr/local/zookeeper/data1/myid
echo 2 >> /usr/local/zookeeper/data2/myid
echo 3 >> /usr/local/zookeeper/data3/myid

伪分布式的启动

因为有的配置文件都在/conf文件夹下面,因此要执行三次,而且要加文件名的参数,不然会默认执行zoo.cfg这个文件。


草图.png

启动成功后输入jps查看有三个QuorumPeerMain


草图.png

停止zookeeper

zkServer.sh stop zoo1.cfg
zkServer.sh stop zoo2.cfg
zkServer.sh stop zoo3.cfg
上一篇下一篇

猜你喜欢

热点阅读