部署hadoop之前准备的工作
1.将虚拟机集群环境的准备,所有安装好jdk并配置好变量.
2.修改主机名
3.修改主机名与ip映射关系
4.关闭防火墙
5.配置统一时间同步
1.jdk配置变量
vim /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_144
export PATH=
P
A
T
H
:
PATH:
PATH:JAVA_HOME/bin
source /etc/profile
2.修改主机名
vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=hadoop01
其中HOSTNAME 就是你想改的主机名.
3.修改主机名与ip映射关系
vim /etc/hosts
000.000.000.000 hadoop01
000.000.000.000 hadoop02
000.000.000.000 hadoop03
其中000.000.000.000 是想要部署的三台机器的ip地址,可以通过 (ifconfig查看)
4.关闭防火墙
1.查看防火墙:server iptables status
2.永久性关闭防火墙:chkconfig iptables off
3.重启防火墙:service iptables restart
5.配置统一时间同步
-
查看时间同步状态: service ntpd status
ntpd is stopped
-
ntp配置文件
vim /etc/ntp.conf
添加:
restrict 000.000.000.000 nomodify notrap nopeer noquery
其中000.000.000.000 为hadoop01的ip地址
修改:
restrict 000.000.000.000 mask 255.255.255.0 nomodify notrap
其中000.000.000.000 为网关 (000.000.000.1)
注释以下内容:
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
添加:
server 127.127.1.0
fudge 127.127.1.0 stratum 10 -
启动NTP服务: service ntpd start
-
设置开机启动: chkconfig ntpd on
-
时间命令
查看当前的时间
date
Thu Jun 10 10:45:39 EDT 2021
[root@hadoop03 ~]# service ntpd stop
[root@hadoop03 ~]# ntpdate hadoop01
10 Jun 11:23:57 ntpdate[2362]: step time server 192.168.254.101 offset 115685179.275931 sec -
客户端同步配置(hadoop02)
[root@hadoop02 ~]# vim /etc/ntp.conf
修改
#the administrative functions.
restrict 000.000.000.000 nomodify notrap nopeer noquery
其中000.000.000.000 为hadoop01的ip地址
#Hosts on local network are less restricted.
restrict 000.000.000.000 mask 255.255.255.0 nomodify notrap
其中000.000.000.000 为网关 (000.000.000.1)
注释掉:
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
添加:
server 000.000.000.000 其中000.000.000.000 为hadoop01的ip地址
fudge 127.127.0.1 stratum 10
最后测试:
ntpstat
sudo ntpq -p