ubuntu ntp時間同步伺服器搭建與使用

來源:互聯網
上載者:User

 

ubuntu server ntp時間同步伺服器安裝及使用

一、服務端

1 apt-get install ntp

 

2 安裝後預設啟動服務,如果沒有啟動,啟動之。

/etc/init.d/ntp start

 

3 vi /etc/ntp.conf 修改為如下

 

restrict default nomodify notrap noquery

restrict 127.0.0.1

restrict 10.91.0.0 mask 255.255.255.0 nomodify

server 0.pool.ntp.org

server 1.pool.ntp.org

server 2.pool.ntp.org

server  127.127.1.0     # local clock

fudge   127.127.1.0 stratum 10

 

driftfile /var/lib/ntp/drift

broadcastdelay  0.008

keys            /etc/ntp/keys

4 重啟ntp服務

 

/etc/init.d/ntp restart

 

 二、用戶端

 

1 使用ntpdate命令,如果不存在這個命令,則先安裝apt-get install ntp

 

/usr/sbin/ntpdate 10.91.0.10 //即使用ip為10.91.0.10的ntp伺服器同步時間

 

2 設定定時同步。

 

vi /etc/crontab

30 01 * * * /usr/sbin/ntpdate 10.91.0.10

 

系統便會在每天早上1點30分自動將系統時間同步到ntp伺服器的時間。

 

當然這裡crontab的時間是指用戶端的時間,同步後等同於ntp伺服器的時間。

 

gg296231363的專欄

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.