hadoop集群時間同步


hadoop集群時間同步

第一種方法

  • 通過網絡鏈接外網進行時間同步,必須保證虛擬機是可以聯網的

  • 通過阿里雲的時鍾同步服務器

    crontab -e
    
    */1 * * * * /usr/sbin/ntpdate ntp4.aliyun.com
    

第二種方式

  • 通過某一台機器進行時間同步
  • 所有操作必須在root用戶下執行

1. 查看三台機器是否安裝了ntp時鍾同步工具

rpm -qa | grep ntpd
  1. 如果沒有安裝執行以下命令來安裝

    yum -y install ntp
    
  2. 三台機器分別執行以下命令,將市區設置為中國上海

    timedatectl set-timezone Asia/Shanghai
    

2. node01啟動服務器的ntpd服務

#啟動ntpd服務
systemctl start ntpd
#設置ntpd開機啟動
systemctl enable ntpd

3. 修改node01的服務器配置,允許其對外提供服務

vim /etc/ntp.conf
#添加下面兩行內容
restrict 192.168.200.0 mask 255.255.255.0 nomodify notrap 
#192.168.200.0這個IP需要和你的網段保持一致,如你的ip是192.168.19.x,則這里寫成192.168.19.0就行
server 127.127.1.0

#注釋掉以下幾行內容
#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

修改之后,重啟node01的ntpd服務

systemctl restart ntpd

4. 配置node02與node03同步node01的時間

  • 服務器node02、node03設置時區與node01保持一致

  • 在02、03上分別執行以下命令

    timedatectl set-timezone Asia/Shanghai
    
  • node02、node03修改配置文件

    vim /etc/sysconfig/ntpdate 
    
    
    SYNC_HWCLOCK=yes
    
  • node02與node03修改定時任務,定時與node01同步時間

    crontab -e
    
    */1 * * * * /usr/sbin/ntpdate 192.168.200.100
    


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM