Ntp&Chrony-CentOS7部署

1.1 ntp

ntp服务端口是123


服务端:

 

rpm -qa ntp
rpm -qa chrony
yum -y install ntp

 

cp /etc/ntp.conf{,.bak}

 

vim /etc/ntp.conf

 8 #restrict default nomodify notrap nopeer noquery

 9 restrict default nomodify

 21 #server 0.centos.pool.ntp.org iburst

 22 #server 1.centos.pool.ntp.org iburst

 23 #server 2.centos.pool.ntp.org iburst

 24 #server 3.centos.pool.ntp.org iburst

 25 server ntp1.aliyun.com

 

[root@m02 ~]# ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter

==============================================================================

 time5.aliyun.co 10.137.38.86     2 u   52   64    1   34.532  139.579   0.000

##显示你的上级ntp服务器情况

 

ntpstat

##查看ntp服务的状态,是否可以使用

[root@m02 ~]# ntpstat

synchronised to NTP server (182.92.12.11) at stratum 3

   time correct to within 958 ms

   polling server every 64 s

##出现类似这样的输出,就表示ntp服务可以使用了

 

客户端:

yum -y install ntpdate

 

ntpdate  NTP服务器

##测试好使之后把同步ntp服务器的命令放到计划任务,并每五分钟执行一次

 

至此,ntp   Over~~

 

1.2 chrony

服务端:

 

systemctl stop ntpd.service

 

yum -y install chrony

 

cp /etc/chrony.conf{,.bak}

 

vim /etc/chrony.conf

 3 #server 0.centos.pool.ntp.org iburst

 4 #server 1.centos.pool.ntp.org iburst

 5 #server 2.centos.pool.ntp.org iburst

 6 #server 3.centos.pool.ntp.org iburst

 7 server ntp2.aliyun.com

 27 allow 172.16.1.0/24

 

systemctl start chronyd

 

tailf /var/log/messages

Mar 13 11:40:04 m02 chronyd[1649]: Selected source 120.25.115.19

##出现上面这一条的话就代表这个服务可以使用了

 

客户端:

也是一样用ntpdate命令

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值