1.验证Server上的NTP版本
[root@testdb ~]# rpm -q ntp
ntp-4.2.2p1-9.el5_4.1
如果没有安装,需要在安装光盘的Server目录下找到ntp-*.rpm并安装
2.修改有关权限的设置
[root@testdb ~]# vim /etc/ntp.conf
常用选项:
ignore: 禁止所有的NTP请求包进入
nomodify: 禁止其他计算机更改本机NTP服务的设置,但可以通过NTP服务器进行网络校时
notrust: 禁止所有未通过认证的NTP包进入
noquery: 禁止其他计算机查询本机NTP服务的状态
我这里的设置:
restrict default nomodify notrap noquery
restrict 127.0.0.1
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap
server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server 3.asia.pool.ntp.org
server 127.127.1.0
fudge 127.127.1.0 stratum 10
3.启动NTP
[root@testdb ~]# /etc/init.d/ntpd start
4.停止NTP
[root@testdb ~]# /etc/init.d/ntpd stop
5.重启NTP
[root@testdb ~]# /etc/init.d/ntpd restart
6.设置NTP随系统启动自动加载
[root@testdb ~]# chkconfig ntpd on
7.检查NTP服务同步状态
[root@testdb ~]# ntpq -p
8.客户端时间同步命令
ntpdate 192.168.0.18 (此IP地址为配置的本地NTP服务器的IP地址)