三台服务器的时间同步-Linux

本文详细介绍如何在局域网内设置NTP服务器,并实现客户端的时间同步。首先,在服务器端修改ntp.conf文件,添加限制规则并指定本地时钟源。然后,确保服务器BIOS与系统时间同步,并启动ntpd服务。最后,在客户端使用ntpdate命令同步时间,并通过crontab设置定时任务,实现每分钟自动同步。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

192.168.1.30    做服务器时间

192.168.1.40   同步30

192.168.1.50  同步30

step1.在30机器上修改ntp.conf

添加:

restrict  192.168.1.0 mask  255.255.255.0  nomodify notrap

说明:根据自己的该啊

注销:

#server 0.rhel.pool.ntp.org iburst
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
#server 3.rhel.pool.ntp.org iburst

添加:

server  127.127.1.0  #  local clock
fudge   127.127.1.0  stratum  10

保证BIOS(主板)与系统时间同步

vim  /etc/sysconfig/ntpd    

添加:SYNC_HWLOCK=yes

 

启动ntpd的运行进程

service  ntpd start

service  ntpd status   --保证服务启动

在40机器上:

[root@saver1 ~]# ntpdate -u  192.168.1.30

28 Jul 13:03:37 ntpdate[2698]: step time server 192.168.1.30 offset 14401.695083 sec

在50机器上:

[root@saver2 ~]# ntpdate -u  192.168.1.30

28 Jul 13:03:51 ntpdate[2663]: step time server 192.168.1.30 offset 14401.690938 sec

date 查看时间已经同步

配置定时器,定时每分钟与时钟服务器进行同步

crontab  -e

*/1 * * * * /usr/sbin/ntpdate 192.168.1.30

《完》

 

转载于:https://www.cnblogs.com/hello-wei/p/11258625.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值