date -s "2008-08-08 20:08"
hwclock
hwclock --set --date="08/08/2008 20:08:08"
hwclock --hctosys
hwclock --systohc
NTP UDP 123
ntpd (server)
ntpdate -s pool.ntp.org (client)
hwclock --adjust
hwclock --systohc
yum install ntp
1、修改配置文件
# vi /etc/ntp.conf
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server pool.ntp.org
restrict 0.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 1.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 2.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict pool.ntp.org mask 255.255.255.255 nomodify notrap noquery
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap
restrict 127.0.0.1
driftfile /var/lib/ntp/drift
2、启动 ntpd
# chkconfig ntpd on
# service ntpd restart
3、检测配置
# ntpstat
# ntpq -p
# ntptrace 127.0.0.1
4、配置防火墙允许访问 udp 123 端口
# /sbin/iptables -A INPUT -p udp --dport 123 -j ACCEPT
# /sbin/iptables -A OUTPUT -p udp --sport 123 -j ACCEPT
安装系统:redhat linux as 4服务器配置:1、创建/etc/ntp.conf文件,添加如下内容:serverclepsydra.dec.com# 外部时间服务器driftfile/etc/ntp.drift2、创建/etc/n
linux 时间服务器安装配置 由Linux系统中文网(Linux521.com)编辑收集整理,除Linux521注明原创文章外,其版权归原作者所有。如果您在学习中遇到问题欢迎在下面的评论中留言,我们会尽全力解答您的问题。
安装系统:redhat linux as 4
服务器配置:
1、 创建/etc/ntp.conf文件,添加如下内容:
server clepsydra.dec.com # 外部时间服务器
driftfile /etc/ntp.drift
2、 创建/etc/ntp.drift,建立一个空文件就成
3、 启动时间服务器:
#/etc/rc.d/init.d/ntpd start
客户端配置:
1、 同步时间
ntpdate 时间服务器地址
2、 加入crontab, 每天同步一次.
0 1 * * * /usr/sbin/ntpdate 时间服务器地址
客户端启动时间同步要在服务器启动完后5-10分在启动客户端的时间同步.不然会报错.
时间更改
Date 月日时分年
注意这都是改 linux local clock,注意要执行 hwclock -w 把时间更新写入 bios/cmos 内硬体时钟
3.防火墙问题的话,送一句配置
iptables -t filter -A INPUT -p udp --destination-port 123 -j ACCEPT
也就是123 udp in 全部接受
服务器配置完成后启动
1种:可以在/etc/rc.d/init.d/ntpd 启动
2种:#/sbin/service ntpd start //启动ntpd 参数可为restart start stop
#/sbin/chkconfig --add ntpd
#/sbin/chkconfig --level 234 ntpd on //配置在开机时运行
检查:
netstat -an | grep 123
# ntpq -p
如果出现 jitter的值 为4000则是防火墙或者网络问题
正常为
remote refid st t when poll reach delay offset jitter
==============================================================================
*clock.nc.fukuok .GPS. 1 u 43 64 37 19.067 -6.884 10.339
clock.tl.fukuok .GPS. 1 u 36 64 35 19.670 -3.259 2.341
LOCAL(0) LOCAL(0) 5 l 45 64 37 0.000 0.000 0.001