Linux升級NTPD服務器-編譯安裝ntp-4.2.8p9與配置

1. 系統與軟件版本

1.1 系統版本

CentOS6.5 x86_64

1.2 ntpd軟件版本

ntp-4.2.8p9.tar.gz

1.3 下載地址

官方下載地址:http://support.ntp.org/bin/view/Main/SoftwareDownloads

參考文檔:http://www.linuxfromscratch.org/blfs/view/svn/basicnet/ntp.html

2. 安裝前提

2.1 安裝依賴包

[root@ntpserver ~]# yum install gcc gcc-c++ openssl-devel libstdc++* libcap*


2.2 備份舊版本的配置文件

[root@ntpserver ~]# cp -ar /etc/ntp /etc/ntp.bak
[root@ntpserver ~]# cp /etc/ntp.conf /etc/ntp.conf.bak
[root@ntpserver ~]# cp /etc/init.d/ntpd /etc/init.d/ntpd.bak
[root@ntpserver ~]# cp /etc/sysconfig/ntpd /etc/sysconfig/ntpd.bak
[root@ntpserver ~]# cp /etc/sysconfig/ntpdate /etc/sysconfig/ntpdate.bak

 

2.3 卸載yum安裝的ntpd服務

[root@ntpserver ~]# yum erase ntp ntpdate


3. 編譯安裝ntp-4.2.8p9

3.1 創建/var/lib/ntp目錄

[root@ntpserver ~]# install -v -m710 -o ntp -g ntp -d /var/lib/ntp


3.2 編譯安裝ntpd

[root@ntpserver ntp-4.2.8p9]# ./configure \
--prefix=/usr \
--bindir=/usr/sbin \
--sysconfdir=/etc \
--enable-linuxcaps \
--with-lineeditlibs=readline \
--docdir=/usr/share/doc/ntp-4.2.8p9 \
--enable-all-clocks \
--enable-parse-clocks \
--enable-clockctl
 
make && make install

 

[root@ntpserver ~]# ntp
ntpd        ntpdate     ntpdc       ntp-keygen  ntpq        ntptime     ntptrace    ntp-wait

4. 創建配置文件

[root@ntpserver ~]# cp /etc/init.d/ntpd.bak /etc/init.d/ntpd
[root@ntpserver ~]# cp /etc/sysconfig/ntpd.bak /etc/sysconfig/ntpd
[root@ntpserver ~]# cp /etc/sysconfig/ntpdate.bak /etc/sysconfig/ntpdate
[root@ntpserver ~]# mv /etc/ntp.bak /etc/ntp
[root@ntpserver ~]# cp /etc/ntp.conf.bak /etc/ntp.conf


5. 配置ntp.conf

/etc/ntp.conf配置文件添加以下參數

server 127.127.1.0

fudge 127.127.1.0 stratum 10

啓動ntpd服務

[root@ntpserver ~]# service ntpd start


6. 客戶端配置

[root@localhost ~]# date
Sat Aug  8 08:08:13 CST 2015


/etc/ntp.conf添加服務端IP地址

server 10.17.83.106


[root@localhost ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 10.17.83.106    10.17.82.25     12 u    3   64    1    0.628  4279381   0.001

 

等待幾分鐘,ntpd客戶端自動去同步服務端的時間

[root@localhost ~]# date
Sat Aug  8 08:11:10 CST 2015
[root@localhost ~]# date
Thu Dec 15 15:28:41 CST 2016


Windows客戶端配置

wKioL1hSShHS_jrmAAm0ZEPSbho699.png



wKiom1hSSe2S5a9hAAAc-IDXo7I434.png

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章