NTP服务器

NTP安装部署
1.安装软件ntpdate
[root@m01 ~]# yum install -y ntp ntpdate
2.备份ntp服务器配置文件
[root@m01 ~]# cp /etc/ntp.conf /etc/ntp.conf.bak
3.精简优化配置文件
[root@m01 ~]# egrep -v "^$|#" /etc/ntp.conf.bak >/etc/ntp.conf
4.编辑配置文件
[root@m01 ~]# vim /etc/ntp.conf
ftfile /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

允许内网其他机器同步时间

restrict 172.16.1.0 mask 255.255.255.0 nomodify notr

server 0.centos.pool.ntp.org iburst

server 1.centos.pool.ntp.org iburst

server 2.centos.pool.ntp.org iburst

server 3.centos.pool.ntp.org iburst

定义使用的上游 ntp服务器,将原来的注释

server ntp1.aliyun.com
server time1.aliyun.com

允许上层时间服务器主动修改本机时间

restrict time1.aliyun.com nomodify notrap noquery
restrict ntp1.aliyun.com nomodify notrap noquery

外部时间服务器不可用时,以本地时间作为时间服务

server 127.127.1.0
fudge 127.127.1.0 stratum 10
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
5.启动NTP服务器和显示节点列表

[root@m01 ~]# systemctl start ntpd
[root@m01 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
120.25.115.20 10.137.53.7 2 u 8 64 1 32.515 2.672 0.000
203.107.6.88 10.137.38.86 2 u 7 64 1 24.061 4.179 0.000
*LOCAL(0) .LOCL. 10 l 6 64 1 0.000 0.000 0.000
6.客户端测试

[root@web01 ~]# date -s 20190825 #更改时间
Sun Aug 25 00:00:00 CST 2019

[root@web01 ~]# ntpdate 172.16.1.61 #同步测试
2 Oct 09:22:40 ntpdate[1606]: adjust time server 172.16.1.61 offset 0.001950 sec

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1. NTP简介 NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间...
    think_lonely阅读 2,967评论 0 0
  • 配置文件 服务器上配置文件: /etc/ntp.conf 主要变化: 1 、将本机的本地时钟作为时间供给源,这样,...
    less_sleep阅读 9,866评论 0 2
  • 1 概述 linux服务器在提供服务时,要和其他机器进行请求的交互,实际生产环境中,可能因为时间不同步,导致了服务...
    ghbsunny阅读 5,196评论 0 1
  • CentOS中搭建NTP服务器(网络时钟服务器) 文章由北京华人开创公司提供 请勿转载!!Q-522508213 ...
    京准时钟阅读 3,940评论 0 0
  • 2018年11月12日,星期二,阴。 自从决定周一来后,周末耍的时间就多了起来,不过周一就忙了。 ...
    秀子_9e99阅读 1,553评论 0 0