首页 > 数据库 > Oracle > Linux的NTP的配置
Linux下的NTP服务器:
http://www.linuxidc.com/Linux/2013-07/88030.htm
Linux下快速搭建ntp时间同步服务器:
http://www.linuxidc.com/Linux/2014-07/104371.htm
Linux的NTP配置总结:
https://www.cnblogs.com/kerrycode/archive/2015/08/20/4744804.html
安装环境:
Red Hat Enterprise Linux Server release 6.7 (Santiago)
一、检查服务端、客户端的ntp包是否已经安装,默认是安装的:
rpm -qa | grep ntp
rpm -q ntp
二、服务端
1.编辑ntp服务器的配置文件/etc/ntp.conf:
server 127.127.1.0 #把本机作为ntp服务端
fudge 127.127.1.0 stratum 0 #这行是时间服务器的层次。设为0则为顶级,如果要向别的NTP服务器更新时间,请不要把它设为0
2.重启ntp服务:
service ntp restart(Ubuntu)
service ntpd restart(CentOS、linux)
systemctl restart ntpd(CentOS7.X、redhat linux 7以上)
3.ntp服务器的防火墙放行ntp的123端口:(如果iptable防火墙关闭则不必要做,跳过即可)
/sbin/iptables -I INPUT -p udp --dport 123 -j ACCEPT
/etc/init.d/iptables status
netstat -tlunp | grep ntp
4.检查ntp服务是否开机启动,将其设置为开机启动
chkconfig --list ntpd
chkconfig --level 345 ntpd on
三、
客户端ntp client
1.编辑ntp客户端的配置文件/etc/ntp.conf,添加server_ip:
server server_ip
2.启动后,一般需要5-10分钟左右的时候才能与外部时间服务器开始同步时间。可以通过命令查询NTPD服务情况。
service ntpd restart
--查看状态:
ntpq -p
或者
watch "ntpq –p"
--查看ntp服务器有无和上层ntp连通:
ntpstat
--如果需要,手工同步,则需要先将client的ntp服务停掉:
servict ntpd stop
ntpdate ntpserver_ip
3.
检查ntp服务是否开机启动,将其设置为开机启动
chkconfig --list ntpd
chkconfig --level 345 ntpd on
实例:
客户端:
[root@one ~]# grep -v ^# /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
server 192.168.56.20 prefer
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
[root@one ~]#
[root@one ~]#
ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
192.168.56.20 .LOCL. 1 u 27 64 177 0.167 2100350 8577226
[root@one ~]#
[root@one ~]#
ntpstat
synchronised to unspecified at stratum 2
time correct to within 14779 ms
polling server every 64 s
[root@one ~]#
服务端端server_ip端:
[root@slient ~]# grep -v ^# /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict -6 ::1
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
server 127.127.1.0
fudge 127.127.1.0 stratum 0
[root@slient ~]#
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31397003/viewspace-2148396/ ,如需转载,请注明出处,否则将追究法律责任。