linux ubuntu多台主机使用ntp同步时间

linux ubuntu多台主机使用ntp同步时间
1台主机同步网络时间,叫做server,其他主机同步server的时间,叫做client

步骤:
1.下载ntpdate
2.统一时区 tzselect
3.使用date修改到一个大体相同的时间 date -s '2020-10-22 21:23:05’
4. 照着这篇文章修改server和client的/etc/ntp.conf
https://www.cnblogs.com/rancher-maomao/p/9309990.html

NTP server配置文件/etc/ntp.conf去除注释后的内容:

driftfile /var/lib/ntp/ntp.drift
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
server 1.networktime.org iburst
server 2.networktime.org iburst
server ntp.synet.edu.cn iburst
server ntp.neu6.edu.cn iburst
server ntp.gwadar.cn iburst
server ntp.neu.edu.cn iburst
restrict -4 default kod notrap nomodify nopeer limited
restrict -6 default kod notrap nomodify nopeer limited
restrict 127.0.0.1
restrict ::1
restrict source notrap nomodify noquery

NTP client 配置文件/etc/ntp.conf去除注释后的内容:

driftfile /var/lib/ntp/ntp.drift
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
server 192.168.3.220 iburst
restrict -4 default kod notrap nomodify nopeer limited
restrict -6 default kod notrap nomodify nopeer limited
restrict 127.0.0.1
restrict ::1
restrict source notrap nomodify noquery

5.**打开Linux自带的防火墙(iptables)的UDP入口和出口的123端口。**这样运行ntpdate同步时间时,才不会出现“no server suitable for synchronization found”错误。

NTP Client

iptables -A OUTPUT -p udp --dport 123 -j ACCEPT
iptables -A INPUT -p udp --sport 123 -j ACCEPT

NTP Server

iptables -A INPUT -p udp --dport 123 -j ACCEPT
iptables -A OUTPUT -p udp --sport 123 -j ACCEPT

6.NTP服务和ntpdate命令不可同时使用。
使用ntpdate之前,一定要先停止NTP服务。
NTP Client

sudo service ntp stop

7.同步 client同步server
ntpdate server的ip地址

资料
鸟哥讲NTP
http://cn.linux.vbird.org/linux_server/0440ntp.php#ps4

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值