NTP 服務器配置
服務器端配置
1, 下載安裝ntp軟件包
apt-get installntp
2, 配置/etc/ntp.conf文件
server 210.72.145.44 prefer #prefer 表示首選
dirftfile /etc/ntp/drift#記錄上傳NTP與上層NTPserver連接所話費的時間
restrict defaultignore #默認任何主機進行時間同步
restrict 127.0.0.1
restrict 192.168.10.2# 指定某臺機器時間同步
restrict 192.168.0.0 mask255.255.255.0 #允許192.168.0.0/254子網內主機時間同步
restrict 0.0.0.0 mask 0.0.0.0nomodify notrap #允許任何主機跟進行時間同步
fudge127.127.1.1 stratum 10 #指定階層編號爲10,降低其優先級
statsdir /var/log/ntp/#設置ntp日誌的path
logfile/var/log/ntp/ntp.log #設置ntp日誌文件
3, 維護ntp服務
#chkconfig–level 345 ntp on
--啓動、停止
# service ntpdstart|stop
或
#/etc/rc.d/init.d/ntpdrestart
4,管理命令
#ntpq –n #查看本機和上層服務器的時間同步結果
#nettrace #可以用來追蹤某臺時間服務器的時間對應關係
#ntpdate IP #客戶端要和NTPserver 進行時鐘同步
2,客戶端配置
#echo “0 */1 * * * root /usr/sbin/ntpdate172.16.31.13; /sbin/hwclock -w”>>/etc/crontab
crontab–h #查看幫助