需要在Hadoop-全分布式配置的基础上进行配置
(在所有节点上)
# 以master为例
# 安装chrony
[root@master ~]# yum -y install chrony
# 编辑配置文件
[root@master ~]# vi /etc/chrony.conf
server 0.time1.aliyun.com iburst
# 开启chronyd
[root@master ~]# systemctl restart chronyd
[root@master ~]# systemctl enable chronyd
Created symlink from /etc/systemd/system/multi-user.target.wants/chronyd.service to /usr/lib/systemd/system/chronyd.service.
# 查看状态
[root@master ~]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-04-22 15:00:38 CST; 3min 31s ago
Process: 795 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
Process: 762 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 781 (chronyd)
CGroup: /system.slice/chronyd.service
└─781 /usr/sbin/chronyd
Apr 22 15:00:37 master.example.com systemd[1]: Starting NTP client/server...
Apr 22 15:00:37 master.example.com chronyd[781]: chronyd version 2.1.1 starting (+CMDMON +NT...H)
Apr 22 15:00:38 master.example.com chronyd[781]: Frequency 0.000 +/- 1000000.000 ppm read fr...ft
Apr 22 15:00:38 master.example.com systemd[1]: Started NTP client/server.
Hint: Some lines were ellipsized, use -l to show in full.
# 看到running则表示成功
[root@master ~]# tar xf zookeeper-3.4.8.tar.gz -C /usr/local/src/
[root@master ~]# cd /usr/local/src/
[root@master src]# mv zookeeper-3.4.8 zookeeper
[root@master src]# cd /usr/local/src/zookeeper/
[root@master zookeeper]# mkdir data logs
[root@master zookeeper]# echo '1' > /usr/local/src/zookeeper/data/myid
[root@master zookeeper]# cd /usr/local/src/zookeeper/conf/
[root@master conf]# cp zoo_sample.cfg zoo.cfg
[root@master conf]# vi zoo.cfg
dataDir=/usr/local/src/zookeeper/data
server.1=master:2888:3888
server.2=slave1:2888:3888
server.3=slave2:2888:3888
# 表示三个 ZooKeeper 节点的访问端口号
[root@master conf]# vi /etc/profile.d/zookeeper.sh
export ZOOKEEPER_HOME=/usr/local/src/zookeeper
export PATH=${ZOOKEEPER_HOME}/bin:$PATH
[root@master conf]# chown -R hadoop.hadoop /usr/local/src/
[root@master conf]# scp /etc/profile.d/zookeeper.sh slave1:/etc/profile.d/
zookeeper.sh 100% 87 0.1KB/s 00:00
[root@master conf]# scp /etc/profile.d/zookeeper.sh slave2:/etc/profile.d/
zookeeper.sh 100% 87 0.1KB/s 00:00
# 在slave1节点
[root@slave1 ~]# chown -R hadoop.hadoop /usr/local/src/
# 在slave2节点
[root@slave2 ~]# chown -R hadoop.hadoop /usr/local/src/
# 在slave1节点
[root@slave1 ~]# echo '2' > /usr/local/src/zookeeper/data/myid
# 在slave2节点
[root@slave2 ~]# echo '3' > /usr/local/src/zookeeper/data/myid
[root@master conf]# su - hadoop
Last login: Fri Apr 22 16:26:07 CST 2022 on pts/0
[hadoop@master ~]$ jps
43248 QuorumPeerMain
44316 Jps
# 看到QuorumPeerMain进程才表示成功
[hadoop@master ~]$ zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/src/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[hadoop@master ~]$ zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/src/zookeeper/bin/../conf/zoo.cfg
Mode: follower
# 确保能够看到1个leader, 2个follower才表示启动成功
[root@slave1 ~]# su - hadoop
[hadoop@slave1 ~]$ zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/src/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... already running as process 42747.
[hadoop@slave1 ~]$ zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/src/zookeeper/bin/../conf/zoo.cfg
Mode: leader
[root@slave2 ~]# su - hadoop
[hadoop@slave2 ~]$ zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/src/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[hadoop@slave2 ~]$ zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/src/zookeeper/bin/../conf/zoo.cfg
Mode: follower
步骤和【Hadoop】HBase组件配置步骤一样
只有hbase-env.sh配置文件下true改为false
vi hbase-env.sh
export JAVA_HOME=/usr/local/src/jdk
export HBASE_MANAGES_ZK=false
export HBASE_CLASSPATH=/usr/local/src/hadoop/etc/hadoop/
# 在master上启动分布式hadoop集群
[hadoop@master ~]$ start-all.sh
[hadoop@master ~]$ jps
3210 Jps
2571 NameNode
2780 SecondaryNameNode
2943 ResourceManager
# 查看slave1节点
[hadoop@slave1 ~]$ jps
2512 DataNode
2756 Jps
2623 NodeManager
# 查看slave2节点
[hadoop@slave2 ~]$ jps
3379 Jps
3239 NodeManager
3135 DataNode
#确保master上有NameNode、SecondaryNameNode、 ResourceManager进程, slave节点上要有DataNode、NodeManager进程
[hadoop@master ~]$ start-hbase.sh
[hadoop@master ~]$ jps
3569 HMaster
2571 NameNode
2780 SecondaryNameNode
3692 Jps
2943 ResourceManager
3471 HQuorumPeer
# 查看slave1节点
[hadoop@slave1 ~]$ jps
2512 DataNode
2818 HQuorumPeer
2933 HRegionServer
3094 Jps
2623 NodeManager
# 查看slave2节点
[hadoop@slave2 ~]$ jps
3239 NodeManager
3705 Jps
3546 HRegionServer
3437 HQuorumPeer
3135 DataNode
# 确保master上有HQuorumPeer、HMaster进程,slave节点上要有HQuorumPeer、HRegionServer进程
声明:未经许可,不得转载
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://www.cnblogs.com/wzgwzg/p/16183617.html
内容来源于网络,如有侵权,请联系作者删除!