在CentOS 5以后不再区分客户端和服务器,只要配置了NTP,它就会提供NTP服务。
特殊说明:使用主机需要可以联网
1、确认已经ntp程序包:
# yum install ntp
2、配置时间源
# vi /etc/ntp.conf
server pool.ntp.org #可选择其他优先服务器
server 0.ntp1.aliyun.com
server 1.ntp2.aliyun.com
server 2.ntp3.aliyun.com
3、配置是否为其他PC提供时间服务
# vi /etc/ntp.conf
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
4、配置开机时自动运行时间服务
# chkconfig ntpd on
5、启动或停止时间服务
# service ntpd start
# service ntpd stop
# service ntpd restart
6、验证ntp服务已经运行
# pgrep ntpd
7、初始同步
# ntpdate -u ntp1.aliyun.com
8、确认同步成功
# ntpq -p
9、同时建议修改一下 /etc/sysconfig/ntpd 文件
# vi /etc/sysconfig/ntpd
SYNC_HWCLOCK=yes