多台服务器使用ntp做时间同步 linux

核心:
使用一台服务器A作为ntp服务器,自动同步网络时间;
其余的服务器皆作为客户端,自动同步服务器A的时间。

理由:
统一时间,防止因时间问题造成的程序混乱

操作:
服务器A操作,如下:

1、确认是否安装ntp:rpm -qa|grep ntp
2、未安装,安装ntp:yum -y install ntp
3、更改配置:vim /etc/ntp.conf


> **新增:**

restrict 服务器A的ip mask 255.255.252.0 nomodify notrap
server  127.127.1.0
fudge   127.127.1.0 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

4、查看时间,并校验:

查看:date
校验:date -s '年-月-日 时:分:秒'

5、启动ntp的服务:service ntpd start 或者 systemctl start ntpd
6、设置ntp服务开机自启动:systemctl enable ntpd

其他服务器:

1、定crontab计划任务自动校时:

 使用命令:crontab -e, 然后添加:
*/1 * * * * /usr/sbin/ntpdate 服务器A的ip
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值