搭建时间服务器

1、必要条件====>所有机器都要安装ntp服务器。

  • 1、查看是否安装 ===> rpm -qa | grep ntp
  • 2、yum安装ntp服务器 ==> yum install -y ntp
  • 3、如果时间不是CST,而是EDT的,那么需要改为shanghai时间

mv /etc/localtime /etc/localtime.bak

ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

2、其中一台机器作为ntp服务器端:

  • 1、首先同步一下网络时间

ntpdate -u cn.pool.ntp.org

  • 2、把自己的时间作为ntp时间==>1、vim /etc/ntp.conf
  •   把原本所有以server 开头的,都注释掉,然后加上两条
  •   server "127.127.1.0"  
  •   fudge  "127.127.1.0" stratum 10

3、其他机器作为ntp客户端

  • 1、其他节点机器 ==> vim /etc/ntp.conf。
  • restrict 192.168.85.0 mask 255.255.255.0 nomodify notrap

把原本所有以server 开头的,都注释掉,然后加上两条

server "上面那台服务器的IP地址"

fudge "时间服务器的IP地址" stratum 10

  • 2、启动ntpd服务器,并设置位开机启动

systemctl start ntpd

systemctl enable ntpd

ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

原文地址:https://www.cnblogs.com/leiwenbin627/p/11271568.html