
上篇:
下篇:
安装好的的虚拟机,发现时间不一致,相差还比较大,对于hadoop集群来说,是需要时间同步的。
这个时候,就需要一个ntp服务了。
1、在各个节点上安装ntp
yum install ntp
2、在各个节点上设置时区为 亚洲上海
timedatectl set-timezone Asia/Shanghai
3、在各个节点启动ntp服务,依次执行以下命令
systemctl start ntpd
systemctl enable ntpd
4、在master上设置当前时间
timedatectl set-ntp no
timedatectl set-time HH:MM:SS
timedatectl set-ntp yes
5、在master上配置ntp服务
[hadoop@venn05 ~]$ vim /etc/ntp.conf
[hadoop@venn05 ~]$ more /etc/ntp.conf
# For more information about this file, see the man pages
# ntp.conf(), ntp_acc(), ntp_auth(), ntp_clock(), ntp_misc(), ntp_mon(). driftfile /var/lib/ntp/drift # Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery # Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1 # ntp服务器指向自己
restrict ::
restrict 192.168.0.0 mask 255.255.0.0 # 接受 192.168 段客户端
6、master上重启ntp服务
systemctl restart ntpd
7、在其他节点同步master的时间
[root@venn08 hadoop]# ntpdate venn05
25 Apr 23:23:48 ntpdate[1430]: step time server 192.168.1.5 offset -1.082561 sec
8、在其他节点启动ntp服务
systemctl start ntpd
systemctl enable ntpd
9、同步所以节点时间
timedatectl set-ntp yes
搞定
-------------更新----
如果ntp已经存在,但是发现服务器时间不同步,可能是同步的是本机,执行“ ntpdate venn05 ”出现如下报错:
ntpdate[]: the NTP socket is in use, exiting
解决:停止ntp,同步master,启动ntp
timedatectl set-ntp no ntpdate venn timedatectl set-ntp yes
上篇: