一、搭建時(shí)間同步服務(wù)器
1、編譯安裝ntp server
wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2.4p4.tar.gz
tar zxvf ntp-4.2.4p4.tar.gz
cd ntp-4.2.4p4
./configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks
make && make install
注:如以上下載地址無法訪問,請(qǐng)從ntp官方下載網(wǎng)頁(yè)(http://www.ntp.org/downloads.html)尋找下載地址。
2、修改ntp.conf配置文件
vi /etc/ntp.conf
①、第一種配置:允許任何IP的客戶機(jī)都可以進(jìn)行時(shí)間同步
將“restrict default nomodify notrap noquery”這行修改成:
restrict default nomodify
配置文件示例:/etc/ntp.conf
②、第二種配置:只允許192.168.18.***網(wǎng)段的客戶機(jī)進(jìn)行時(shí)間同步
在restrict default nomodify notrap noquery(表示默認(rèn)拒絕所有IP的時(shí)間同步)之后增加一行:
restrict 192.168.18.0 mask 255.255.255.0 nomodify
配置文件示例:/etc/ntp.conf
3、以守護(hù)進(jìn)程啟動(dòng)ntpd
/usr/local/ntp/bin/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid
4、ntpd啟動(dòng)后,客戶機(jī)要等幾分鐘再與其進(jìn)行時(shí)間同步,否則會(huì)提示“no server suitable for synchronization found”錯(cuò)誤。
二、配置時(shí)間同步客戶機(jī)
vi /var/spool/cron/root
增加一行,在每天的5點(diǎn)13分、9點(diǎn)13分、14點(diǎn)13分、19點(diǎn)13分與時(shí)間同步服務(wù)器進(jìn)行同步
13 5,9,14,19 * * * /usr/sbin/ntpdate 192.168.18.2
備注:如果客戶機(jī)沒有ntpdate,可以下載ntpdate.tar.gz到/usr/sbin/目錄,然后解壓:
wget http://blog.s135.com/attachment/200708/ntdate.tar.gz
cd /usr/sbin/
tar zxvf ntpdate.tar.gz
[文章作者:張宴 本文版本:v1.0 最后修改:2007.08.09 轉(zhuǎn)載請(qǐng)注明出處:http://blog.s135.com]