CentOS7 minimal ntp chrony

2018-05-28  本文已影响0人  余带盐
  1. 下载
    yum install ntp -y
  2. 配置
    vi /etc/ntp.conf
...
#restrict default nomodify notrap nopeer noquery
restrict default nomodify  #允许其他任意ip主机同步
...
server 127.0.0.1     # 使用本地时间
fudge  127.0.0.1 stratum 10
...
#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
...
image.png
  1. 启动服务
    systemctl start ntpd
    systemctl enable ntpd
  2. 查看
    ntpq -p
    image.png
  1. 下载
    yum install ntp -y
  2. 配置
    vi /etc/ntp.conf
...
#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
server node2 iburst
...
image.png
  1. 启动服务
    systemctl start ntpd
    systemctl enable ntpd
  2. 查看
    ntpq -p
    image.png
  3. 验证

引用:centos7局域网同步时间ntp


  1. 下载:yum install chrony
  2. 配置:vi /etc/chrony.conf
#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
server ntp1.aliyun.com iburst #如果是局域网的话就不需要这个
allow 192.168.0.0/24
local stratum 10
bindcmdaddress 127.0.0.1
bindcmdaddress ::1
image.png
  1. 启动
    systemctl enable chronyd
    systemctl start chronyd
  2. 验证
    chronyc sources -v
    image.png
  1. 下载:yum install chrony
  2. 配置:vi /etc/chrony.conf
#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
server node2 iburst

image.png
  1. 启动
    systemctl enable chronyd
    systemctl start chronyd
  2. 验证
    chronyc sources -v
    注:MS字段中S*才算连接上
    image.png
  3. 测试
    修改客户端的时间:date -s 14:00:00
    然后重启chronyd:systemctl restart chronyd
    就可以重新对时
    通过systemctl status chronyd,可以查看日志
    image.png
上一篇下一篇

猜你喜欢

热点阅读