Zookeeper3.4.10详解和安装

一、Zookeeper简介

二、Zookeeper安装

1.集群环境

IP 主机名
192.168.205.60 master
192.168.205.65 slave1
192.168.205.66 slave2

2.下载软件包

#Master
wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
tar zxvf zookeeper-3.4.10.tar.gz

3.修改zookeeper配置

#Master
mv zookeeper-3.4.10 /usr/local/
cd /usr/local/zookeeper-3.4.10
#创建日志文件夹及数据文件夹
mkdir -p /usr/local/zookeeper-3.4.10/data /usr/local/zookeeper-3.4.10/log
vim /usr/local/zookeeper-3.4.10/conf/zoo.cfg #修改配置文件
tickTime=2000
initLimit=10
syncLimit=5
clientPort=2181
dataDir=/usr/local/zookeeper-3.4.10/data
dataLogDir=/usr/local/zookeeper-3.4.10/log
server.1=master:2888:3888
server.2=slave1:2888:3888
server.3=slave2:2888:3888

4.配置环境变量

#Master、Slave1、Slave2
vim /etc/profile
#set zookeeper environment
ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.10
PATH=$PATH:$ZOOKEEPER_HOME/bin
#刷新环境变量
source /etc/profile

5.拷贝安装包和环境变量

#Master
ansible Vmware -m synchronize -a 'src=/usr/local/zookeeper-3.4.10 dest=/usr/local rsync_opts=-avuz'
ansible Vmware -m synchronize -a 'src=/etc/profile dest=/etc rsync_opts=-avuz'

6.分别添加ID

#Master
echo "1" >  /usr/local/zookeeper-3.4.10/data/myid  
#Slave1
echo "2" >  /usr/local/zookeeper-3.4.10/data/myid  
#Slave2
echo "3" >  /usr/local/zookeeper-3.4.10/data/myid  

7.启动Zookeeper服务

#Master、Slave1、Slave2
/usr/local/zookeeper-3.4.10/bin/zkServer.sh start

8.查看运行状态

/usr/local/zookeeper-3.4.10/bin/zkServer.sh status
#Master
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: follower
#Slave1
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: leader
#Slave2
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: follower

9.进程状态

jps
#Master
12483 QuorumPeerMain
3064 ResourceManager
12779 Jps
2892 SecondaryNameNode
2685 NameNode

#Slave1
2608 NodeManager
2513 DataNode
7702 Jps
7611 QuorumPeerMain

#Slave2
2503 DataNode
2600 NodeManager
7679 QuorumPeerMain
7759 Jps

10.关闭集群

#master、Slave1、Slave2
/usr/local/zookeeper-3.4.10/bin/zkServer.sh stop

你可能感兴趣的:(大数据)