单机配置(连接网络的时间地址)

准备一台可连通外网的单机

  1. yum install -y ntp #安装所需要的ntp工具
  2. vim /etc/ntp.conf #进入配置文件
  3. #重要的配置:
  4. restrict default nomodify notrap nopeer noquery #表示默认拒绝所有IP的时间同步
  5. server ntp1.aliyun.com iburst #设置匹配的时间同步地址
  6. systemctl restart ntpd #重启服务
  7. ntpq -p #查看是否配置成功

image.png
出现以上内容就是单机节点配置成功。

集群配置

server节点和n个client节点

  1. yum install -y ntp #安装所需要的ntp工具
  2. #server节点做如下操作
  3. vim /etc/ntp.conf #进入配置文件
  4. #restrict default nomodify notrap nopeer noquery #添加注释
  5. #将下面的四行server注释
  6. server 127.0.0.1 #这里写内网网卡
  7. fudge 127.0.0.1 stratum 5 #设置服务器的时间层次,尽量不要设置为0
  8. #client节点做如下操作
  9. #restrict default nomodify notrap nopeer noquery #添加注释
  10. #将下面的四行server注释
  11. server 192.168.0.157 #这里写内网网卡