hadoop--集群时间同步(可不同步)
生活随笔
收集整理的这篇文章主要介绍了
hadoop--集群时间同步(可不同步)
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
集群时间同步
如果服务器在公网环境(能连接外网),可以不采用集群时间同步,因为服务器会定期和公网时间进行校准;
如果服务器在内网环境,必须要配置集群时间同步,否则时间久了会产生时间偏差,导致集群执行任务时间不同步。
1.需求
找一个机器,作为时间服务器,所有的及其与这台集群时间进行定时同步,生产环境根据任务对时间的准确度要求周期同步。
2.时间服务器配置(必须root用户)
1). 查看所有节点ntpd服务状态和开机自启动状态:
[xiaobai@hadoop102 ~]$ sudo systemctl status ntpd [xiaobai@hadoop102 ~]$ sudo systemctl start ntpd [xiaobai@hadoop102 ~]$ sudo systemctl is-enabled ntpd2). 修改hadoop102的ntp.conf配置:
[xiaobai@hadoop102 ~]$ sudo vim /etc/ntp.conf修改内容如下:
a. 修改1(授权192.168.10.0-192.168.10.255网段上的所有机器可以从这台机器上查询和同步时间)
#restrict 192.168.10.0 mask 255.255.255.0 nomodify notrap为
restrict 192.168.10.0 mask 255.255.255.0 nomodify notrapb. 修改2(集群在局域网中,不适用其他互联网上的时间)
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 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 iburstc. 天剑3(当该节点丢失网络连接,依然可以采用本地时间作为时间服务器为集群中的其他节点提供时间同步)
server 127.127.1.0 fudge 127.127.1.0 stratum 103). 修改hadoop102的/etc/sysconfig/ntpd文件:
[xiaobai@hadoop102 ~]$ sudo vim /etc/sysconfig/ntpd增加内容如下(让硬件时间与系统时间一起同步)
SYNC_HWCLOCK=yes4). 重新启动ntpd服务:
[xiaobai@hadoop102 ~]$ sudo systemctl start ntpd5). 设置ntpd服务开机启动:
[xiaobai@hadoop102 ~]$ sudo systemctl enable ntpd3.其他机器配置(必须root用户):
1). 关闭所有节点上ntp服务和自启动
[xiaobai@hadoop103 ~]$ sudo systemctl stop ntpd [xiaobai@hadoop103 ~]$ sudo systemctl disable ntpd [xiaobai@hadoop104 ~]$ sudo systemctl stop ntpd [xiaobai@hadoop104 ~]$ sudo systemctl disable ntpd2). 在其他及其配置1分钟与时间服务器同步一次:
[xiaobai@hadoop103 ~]$ sudo crontab -e编写定时任务如下:
*/1 * * * * /usr/sbin/ntpdate hadoop1023). 修改任意机器时间:
[xiaobai@hadoop103 ~]$ sudo date -s "2021-6-15 22:00:59"4). 1分钟后查看机器是否与时间服务器同步:
[xiaobai@hadoop103 ~]$ sudo date总结
以上是生活随笔为你收集整理的hadoop--集群时间同步(可不同步)的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 进程和线程的关系与区别是什么?如何创建多
- 下一篇: 表锁与行锁的区别以及适用情况