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--集群时间同步(可不同步)的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 进程和线程的关系与区别是什么?如何创建多
 - 下一篇: Android开发入门教程--Andro