centos 6.5 搭建ntp服務

來源:互聯網
上載者:User

標籤:centos 6.5 搭建ntp服務

       我們大家來學習第一個服務,ntp時間伺服器。學習服務首先得知道這個服務主要是做什麼的,怎麼去安裝,怎麼去配置,然後啟動。知道了這些之後,我們再來搭建ntp服務。

     1. NTP服務是主要做什麼的?

            答:NTP(Network Time Protocol)是用來使電腦時間同步化的一種協議,它可以使電腦對其伺服器或時鐘源做同步化,它可以提供高精準度的時間校正。本例講解如何在CentOS6.5上配置NTP伺服器和NTP用戶端,可使多台客戶機的時間與指定的NTP伺服器的時間保持一致。從而保證了多台伺服器的時間同步。

       2.ntp伺服器和ntp用戶端都需要安裝哪些包?

            答: ntp伺服器 yum install ntp ntpdate -y  (首先必須配置好yum,這裡就不多介紹)

                    ntp用戶端 yum install ntpdate -y 

    3.我們需要實現的需求?

            答: 

            1)準備好3台機器,分別為192.168.137.11(ntp伺服器) 和 192.168.137.12-13(ntp用戶端)

            2)服務端與上層伺服器同步時間,用戶端半個小時和ntp服務端同步一次時間,來用戶端時間和服務端時間的正常。

       

實驗步驟

1.在192.168.137.11(ntp服務端) 

[[email protected] ~]# yum install ntp ntpdate -yLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: centos.ustc.edu.cnSetting up Install ProcessResolving Dependencies--> Running transaction check---> Package ntp.i686 0:4.2.6p5-3.el6.centos will be installed.....(此處省略)Installed:  ntp.i686 0:4.2.6p5-3.el6.centos              ntpdate.i686 0:4.2.6p5-3.el6.centos             Dependency Installed:  libedit.i686 0:2.11-4.20080712cvs.1.el6                                                       Complete!

然後我們來配置ntp伺服器的設定檔。

[[email protected] ~]# vim /etc/ntp.conf driftfile /var/lib/ntp/driftrestrict default kod nomodify notrap nopeer noqueryrestrict -6 default kod nomodify notrap nopeer noqueryrestrict 127.0.0.1 restrict -6 ::1server ntp.fudan.edu.cn    (server是指定上層伺服器時間)restric ntp.fudan.edu.cn nomodify notrap noquery  (允許上層伺服器修改本地機器時間,如果此列不寫,那麼本地時間不會修改)server 127.127.1.0    fudge  127.127.1.0 stratum 10(如果上層伺服器同步不了時間,那麼本機器自動同步自己的時間)includefile /etc/ntp/crypto/pwkeys /etc/ntp/keys

修改好設定檔之後,重啟ntp服務。

[[email protected] ~]# service ntpd startStarting ntpd:                                             [  OK  ][[email protected] ~]# dateFri Aug  7 21:25:35 CST 2015

如果時間沒有立馬同步,那需要等幾分鐘會和上層伺服器同步。

2.在192.168.137.12和13(ntp用戶端)

[[email protected] ~]# yum install ntpdate -yLoaded plugins: fastestmirror, securityDetermining fastest mirrors * base: mirrors.163.com * extras: mirrors.163.com * updates: centos.ustc.edu.cnSetting up Install ProcessResolving Dependencies--> Running transaction check---> Package ntpdate.i686 0:4.2.6p5-1.el6.centos will be updated.....(此處省略)                   Dependency Updated:  ntp.i686 0:4.2.6p5-3.el6.centos                                                     Complete![[email protected] ~]#

安裝好軟體之後,主要設定自動任務計劃,就可以自動同步ntp伺服器時間。

[[email protected] ~]# crontab -e*/30 * * * * /usr/sbin/ntpdate 192.168.138.12 >>/tmp/ntp.log

設定自動任務計劃,半個小時同步一次ntp伺服器時間。

192.168.137.12 和 192.168.137.13 都是一樣的操作。


實驗就是這麼簡單,但是如果你想瞭解ntp服務端的設定檔,可以去Google下。











本文出自 “linux” 部落格,請務必保留此出處http://liunxbk.blog.51cto.com/8683822/1682789

centos 6.5 搭建ntp服務

相關文章

聯繫我們

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