一、ntp同步shell命令:ntpdate time.nist.gov(或填ip:132.163.4.103)
二、配置NTP服务器(默认NTP软件已安装)。
①备份原ntp配置文件
cp/etc/ntp.conf/etc/ntp.conf.bak
②修改配置文件
vi /etc/ntp.conf
我的ntp.conf配置:
logfile /var/log/ntp.log
restrict default nomodify
restrict 127.0.0.1
restrict 192.168.0.0 mask 255.255.255.0 nomodify
server 128.138.141.172 prefer
若设置本地服务器为根时间服务器,则最后的参数改为:
server 127.127.1.0
fudge 127.127.1.0 stratum 1
三、查看ntpd是否可用。(一般要等5~10分钟后才可用)
watch ntpq -p
四、其他
1. 配置文件中的driftfile是什么?
我们每一个system clock的频率都有小小的误差,这个就是为什么机器运行一段时间后会不精确. NTP会自动来监测我们时钟的误差值并予以调整.但问题是这是一个冗长的过程,所以它会把记录下来的误差先写入driftfile.这样即使你重新开机以后之前的计算结果也就不会丢失了
2. 如何同步硬件时钟?
NTP一般只会同步system clock. 但是如果我们也要同步RTC(hwclock)的话那么只需要把下面的选项打开就可以了
代码:
# vi /etc/sysconfig/ntpd
SYNC_HWCLOCK=yes
参考网站:http://blog.csdn.net/love_life2011/article/details/8067652
以下为转载的
[root@bogon
[root@bogon
LSB
Distributor
Description: Fedora
Release: 17
Codename: BeefyMiracle
[root@bogon
Linux
[root@bogon
fontpackages-filesystem-1.44-4.fc17.noarch
ntpdate-4.2.6p5-2.fc17.x86_64
ntp-4.2.6p5-2.fc17.x86_64
[root@bogon
#
#
driftfile
#
#
restrict
restrict
#
#
#
restrict
restrict
#
#restrict
#
#
server
server
server
server
#broadcast
#broadcastclient #
#broadcast
#multicastclient
#manycastserver
#manycastclient