一、編譯安裝ntp server
wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2.6.tar.gz
tar zxvf ntp-4.2.6.tar.gz
cd ntp-4.2.6
./configure --prefix=/usr/local/src/ntp --enable-all-clocks --enable-parse-clocks
make && make install服務器
二、修改ntp.conf配置文件ide
vi /etc/ntp.confui
①、第一種配置:容許任何IP的客戶機均可以進行時間同步
將「restrict default kod nomodify notrap nopeer noquery」這行修改爲:rest
restrict default nomodifyserver
配置文件示例:/etc/ntp.confblog
②、第二種配置:只容許192.168.18.***網段的客戶機進行時間同步
在restrict default nomodify notrap noquery(表示默認拒絕全部IP的時間同步)以後增長一行:進程
restrict 192.168.18.0 mask 255.255.255.0 nomodifyci
配置文件示例:/etc/ntp.confget
三、以守護進程啓動ntpd同步
/usr/local/ntp/bin/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid
四、ntpd啓動後,客戶機要等幾分鐘再與其進行時間同步,不然會提示「no server suitable for synchronization found」錯誤。
2、配置時間同步客戶機
vi /var/spool/cron/root
增長一行,在天天的5點13分、9點13分、14點13分、19點13分與時間同步服務器進行同步
13 5,9,14,19 * * * /usr/sbin/ntpdate 192.168.18.2
備註:若是客戶機沒有ntpdate,能夠下載ntpdate.tar.gz到/usr/sbin/目錄,而後解壓:
wget http://blog.s135.com/p_w_upload/200708/ntdate.tar.gz cd /usr/sbin/ tar zxvf ntpdate.tar.gz