Hadoop环境搭建(10)--Zookeeper环境搭建

在zookeeper安装之前,先检查防火墙是否关闭

①防火墙状态的查看,命令:

systemctl status firewalld

②关闭防火墙,命令:

systemctl stop firewalld

③设置开机防火墙不启动,命令:

systemctl disable firewalld

1、将zookeeper安装包拉到/opt/software/文件夹中

安装包版本:apache-zookeeper-3.5.7-bin.tar.gz

2、解压zookeeper安装包到/opt/module/文件夹下,命令:

cd /opt/software/
tar -zxvf 安装包名 -C  /opt/module/

 3、在解压后的zookeeper文件下,创建log文件夹和data文件夹,命令:

cd /opt/module/apache-zookeeper-3.5.7-bin/

创建命令:

mkdir data
mkdir log

4、 拷贝配置文件,命令:

cd /opt/module/apache-zookeeper-3.5.7-bin/conf/
cp zoo_sample.cfg zoo.cfg
在此路径下,将zoo_sample.cfg文件拷贝一份并重命名为zoo.cfg

5、进行配置文件更改,命令:

vi zoo.cfg

将如下内容添加到编辑面板中:

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/opt/module/apache-zookeeper-3.5.7-bin/data
dataLogDir=/opt/module/apache-zookeeper-3.5.7-bin/log
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.0=192.168.1.100:2888:3888
server.1=192.168.1.101:2888:3888
server.2=192.168.1.102:2888:3888

 6、创建服务器myid

在data目录下创建一个myid文件,里面的值可以给个任意的值但要和上一步服务起server.x对应,稍后进行更改

cd /opt/module/apache-zookeeper-3.5.7-bin/data/

touch myid

7、集群拷贝,命令:

scp -r /opt/module/apache-zookeeper-3.5.7-bin root@hadoop101:/opt/module/apache-zookeeper-3.5.7-bin

将Hadoop100/opt/module/apache-zookeeper-3.5.7-bin里面的文件拷贝到Hadoop101/opt/module/apache-zookeeper-3.5.7-bin里面

scp -r /opt/module/apache-zookeeper-3.5.7-bin root@hadoop102:/opt/module/apache-zookeeper-3.5.7-bin

将Hadoop100/opt/module/apache-zookeeper-3.5.7-bin里面的文件拷贝到Hadoop102/opt/module/apache-zookeeper-3.5.7-bin里面

 8、集群myid更改,命令:

进入每个节点进行更改:

cd /opt/module/apache-zookeeper-3.5.7-bin/data/

Hadoop100的myid,改成0

touch myid

Hadoop101的myid,改成1

Hadoop102的myid,改成2

9、添加系统环境变量,命令:

vi /etc/profile

在编辑面板中添加如下内容:

export ZOOKEEPER_HOME=/opt/module/apache-zookeeper-3.5.7-bin
export PATH=$PATH:$ZOOKEEPER_HOME/bin

10、zookeeper集群启动,每个节点都要启动

cd /opt/module/apache-zookeeper-3.5.7-bin

启动命令:(在100、101、102里面都要启动)

zkServer.sh start
zkServer.sh status
依次启动

注意:启动zkServer.sh satus时要先找leader,leader可能在100、101、102中的其中一个里,否则zkServer.sh satus会报错

 本人的leader在101上所以,先在101上启动后,在启动100和102就不会报错了

11、zkCli连接验证,命令:

zkCli.sh -server hadoop100:2181

按Ctrl+Z停止运行

用jps查看出现ZooKeeperMain进程

出现QuorumPeerMain则说明zookeeper启动成功 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值