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

Hadoop环境搭建(Zookeeper环境搭建),第1张

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

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

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

systemctl status firewalld

②关闭防火墙,命令:

systemctl stop firewalld

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

systemctl disable firewalld

2.将zookeeper安装包拉到/opt/software/文件夹中

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

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

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

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

创建命令:

mkdir data
mkdir log

5.拷贝配置文件

cd /opt/module/apache-zookeeper-3.5.5-bin/conf/

cp zoo_sample.cfg 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.5-bin/data

dataLogDir=/opt/module/apache-zookeeper-3.5.5-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会报错
11、zkCli连接验证,命令:
 

zkCli.sh -server hadoop100:2181

按Ctrl+Z停止运行

用jps查看出现ZooKeeperMain进程

出现QuorumPeerMain则说明zookeeper启动成功 

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5676841.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存