centos 系統時間的同步

來源:互聯網
上載者:User

標籤:

1.當你的網站架構涉及到多台伺服器的時候,伺服器之間的時間必須得同步,這樣就涉及到了程式的時間的準確性問題,特別是跟時間相關的操作和系統本身的定時任務。

2.時間同步工具:ntpdate,安裝方式:yum install -y ntpdate

3.使用方法:ntpdate time.windows.com,同步你想同步的那台伺服器的時間

可以同步的伺服器:

time.nist.gov
time.nuri.net
asia.pool.ntp.org
asia.pool.ntp.org
asia.pool.ntp.org
asia.pool.ntp.org

 

 

4.同步時間的方法:

   1):第一種就是設定定時任務,定時的去運行ntpdate命令更新時間 */10 * * * * ntpdate time.nist.gov  

  2):配置/etc/ntp.conf 檔案:運行cat /etc/ntp.conf |awk ‘{if($0 !~ /^$/ && $0 !~ /^#/) {print $0}}‘命令就可以查看到配置情況

restrict default ignore //預設不允許修改或者查詢ntp,並且不接收特殊封包
restrict 127.0.0.1 //給於本機所有許可權
restrict 192.168.1.0 mask 255.255.255.0 notrap nomodify //給於區域網路機的機器有同步時間的許可權
server time.nist.gov prefer //設定時間伺服器,加prefer表示優先
server 0.asia.pool.ntp.org 
server 1.asia.pool.ntp.org 
server 2.asia.pool.ntp.org 
server 127.127.1.0 # local clock 
fudge 127.127.1.0 stratum 10 
driftfile /var/lib/ntp/drift 
keys /etc/ntp/keys

 

3)配置完成後就啟動服務: /etc/init.d/ntpd start 

4)查看同步情況:ntpq -pn

 

    

centos 系統時間的同步

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.