CentOS7部署Zookeeper3.4.6集群

版权声明:路漫漫其修远兮,吾将上下而求索。 https://blog.csdn.net/Happy_Sunshine_Boy/article/details/89146190

1. 安装Zookeeper集群的具体步骤

1.1 集群节点规划

Hostname IP Functions 内存 磁盘
hdp-01 192.168.121.61 master 4G 50G
hdp-02 192.168.121.62 slave 3G 50G
hdp-03 192.168.121.63 slave 3G 50G

1.2 在hdp-01节点上部署安装

[root@hdp-01 ~]# rz		# 上传zookeeper压缩包
[root@hdp-01 ~]# tar -zxvf zookeeper-3.4.6.tar.gz -C /opt/		# 解压

# 配置环境变量
[root@hdp-01 ~]# vim /etc/profile
export ZOOKEEPER_HOME=/opt/zookeeper-3.4.6
export PATH=$PATH:$ZOOKEEPER_HOME/bin
[root@hdp-01 ~]# source /etc/profile
[root@hdp-01 etc]# scp profile hdp-02:$PWD
[root@hdp-01 etc]# scp profile hdp-03:$PWD
# 在hdp-02、hdp-03节点执行:source /etc/profile

# 创建data目录
[root@hdp-01 ~]# mkdir -p /hadoop/zookeeper/data

[root@hdp-01 ~]# cd /opt/zookeeper-3.4.6/conf/
[root@hdp-01 conf]# cp zoo_sample.cfg zoo.cfg
[root@hdp-01 conf]# vim zoo.cfg
# 修改为
dataDir=/hadoop/zookeeper/data
# 添加
server.1=hdp-01:2888:3888
server.2=hdp-02:2888:3888
server.3=hdp-03:2888:3888

# 创建myid文件
[root@hdp-01 conf]# touch /hadoop/zookeeper/data/myid
[root@hdp-01 conf]# vim /hadoop/zookeeper/data/myid
1

# 从hdp-01分发到剩余节点
[root@hdp-01 opt]# scp -r zookeeper-3.4.6/ hdp-02:$PWD
[root@hdp-01 opt]# scp -r zookeeper-3.4.6/ hdp-03:$PWD

[root@hdp-01 /]# scp -r hadoop/ hdp-02:$PWD
[root@hdp-01 /]# scp -r hadoop/ hdp-03:$PWD

# 修改myid文件
[root@hdp-02 /]# vim /hadoop/zookeeper/data/myid
2
[root@hdp-03 /]# vim /hadoop/zookeeper/data/myid
3

# 启动master
[root@hdp-01 zookeeper-3.4.6]# ./bin/zkServer.sh start
JMX enabled by default
Using config: /opt/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@hdp-01 zookeeper-3.4.6]# jps
26267 QuorumPeerMain
......

# 启动slave
[root@hdp-02 zookeeper-3.4.6]# ./bin/zkServer.sh start
JMX enabled by default
Using config: /opt/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@hdp-02 zookeeper-3.4.6]# jps
21830 QuorumPeerMain
......

[root@hdp-03 zookeeper-3.4.6]# ./bin/zkServer.sh start
JMX enabled by default
Using config: /opt/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@hdp-03 zookeeper-3.4.6]# jps
21979 QuorumPeerMain
......

猜你喜欢

转载自blog.csdn.net/Happy_Sunshine_Boy/article/details/89146190