在公司内网,搭建服务器集群时,为了到达一致性,需要对服务器时间进行同步。内网一般不能访问互联网,此时急需一台内部的时间服务器,用于内网机器的时间同步。

安装ntp

yum install -y ntp ntpdate

修改配置文件 /etc/ntp.conf

driftfile /var/lib/ntp/drift

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.

restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of the administrative functions.

restrict 127.0.0.1
restrict -6 ::1

# 允许设置的可信任地址段对NTPD各服务的访问,但不允许此地址段内客户端修改NTPD服务器时间(nomodify)
restrict 192.168.113.0 mask 255.255.255.0 nomodify notrap 

# 外部时间服务器
server ntp.aliyun.com

# 外部时间服务器不可用时,以本地时间作为时间服务
server 127.127.1.0  
fudge  127.127.1.0   stratum  5

启动服务

systemctl start ntpd
systemctl enable ntpd

测试

ntpdate -u 127.0.0.1

相关文章:

  • 2022-12-23
  • 2021-06-10
  • 2021-04-10
  • 2021-10-01
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-09
  • 2021-08-02
  • 2021-10-27
  • 2021-05-02
  • 2021-09-09
  • 2021-07-23
相关资源
相似解决方案