CentOS7 minimal ntp chrony

  • ntp服务器(192.168.0.242 node2)(暂时没测试出来,不使用)
  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
...
CentOS7 minimal ntp chrony_第1张图片
image.png
  1. 启动服务
    systemctl start ntpd
    systemctl enable ntpd
  2. 查看
    ntpq -p
    image.png
  • ntp客户端(192.168.0.242 nod3)(暂时没测试出来,不使用)
  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
...
CentOS7 minimal ntp chrony_第2张图片
image.png
  1. 启动服务
    systemctl start ntpd
    systemctl enable ntpd
  2. 查看
    ntpq -p
    image.png
  3. 验证

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


  • chrony服务器
  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
CentOS7 minimal ntp chrony_第3张图片
image.png
  1. 启动
    systemctl enable chronyd
    systemctl start chronyd
  2. 验证
    chronyc sources -v
    CentOS7 minimal ntp chrony_第4张图片
    image.png
  • chrony客户端
  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

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

你可能感兴趣的:(CentOS7 minimal ntp chrony)