新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

Linux下的NTP配置

这篇文章主要讲解了“Linux下的NTP配置”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Linux下的NTP配置”吧!

成都创新互联公司专注于企业网络营销推广、网站重做改版、湘潭县网站定制设计、自适应品牌网站建设、H5高端网站建设电子商务商城网站建设、集团公司官网建设、成都外贸网站制作、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为湘潭县等各大城市提供网站开发制作服务。



安装环境:
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 ~]#

感谢各位的阅读,以上就是“Linux下的NTP配置”的内容了,经过本文的学习后,相信大家对Linux下的NTP配置这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联,小编将为大家推送更多相关知识点的文章,欢迎关注!


当前名称:Linux下的NTP配置
标题网址:http://www.wjwzjz.com/article/gspiig.html
在线咨询
服务热线
服务热线:028-86922220
TOP