11 月 292012
 

配置服务器端

编辑配置文件

#vi /etc/ntp.conf

限定主机或子网
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

开启上游时间服务器访问
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org

查看服务运行状态
[root@oracle ~]# service ntpd status
ntpd is stopped

启动服务
[root@oracle ~]# service ntpd start
Starting ntpd: [ OK ]

查看监听端口
[root@oracle ~]# netstat -ltun |grep 123
udp 0 0 192.168.2.122:123 0.0.0.0:*

udp 0 0 127.0.0.1:123 0.0.0.0:*

udp 0 0 0.0.0.0:123 0.0.0.0:*

udp 0 0 ::1:123 :::*

udp 0 0 fe80::250:56ff:feab:2d4e:123 :::*

udp 0 0 :::123 :::*

查看服务器同步状态
[root@oracle ~]# ntpstat
unsynchronised
time server re-starting
polling server every 64 s

[root@oracle ~]# ntpstat
synchronised to NTP server (202.112.29.82) at stratum 3
time correct to within 201 ms
polling server every 64 s

客户端时间同步设置

安装时间同步软件包
yum install ntpdate

同步时间
[root@monitor ~]# ntpdate time.nist.gov
14 Nov 11:29:31 ntpdate[3316]: step time server 128.138.141.172 offset

172.282249 sec

查看系统当前时间
[root@monitor ~]# date
Wed Nov 14 11:29:36 CST 2012

查看硬件时间
#hwclock –show
Wed 14 Nov 2012 11:37:34 AM CST -0.625478 seconds

将系统时间写入硬件
#hwclock -w

使用计划任务定时与时间服务器同步

#vi /etc/crontab
 00 1 * * * ntpdate 192.168.2.122;hwclock -w

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据