一、安装ntp
| |
| yum install -y ntp |
| |
| yum install -y ntpdate |
| |
| |
| systemctl start ntpd |
| |
| |
| systemctl enable ntpd |
| |
| |
| firewall-cmd --zone=public --permanent --add-port=123/udp |
| firewall-cmd --reload |
二、ntp 常用配置 /etc/ntp.conf
一般服务端才需要配置,客户端直接使用命令同步即可
| |
| driftfile /var/lib/ntp/drift |
| |
| |
| logfile /var/log/ntp.log |
| |
| logconfig all |
| |
| |
| restrict default nomodify notrap nopeer noquery |
| |
| |
| restrict 127.0.0.1 |
| restrict -6 ::1 |
| |
| |
| restrict 192.168.100.0 mask 255.255.255.0 nomodify notrap |
| |
| |
| |
| server s1b.time.edu.cn prefer |
| |
| |
| server 127.127.1.0 |
| fudge 127.127.1.0 stratum 10 |
restrict 控制相关权限
三、使用
| |
| 210.72.145.44 |
| |
| ntp.aliyun.com |
| |
| s1a.time.edu.cn 北京邮电大学 |
| s1b.time.edu.cn 清华大学 |
| s1c.time.edu.cn 北京大学 |
| s1d.time.edu.cn 东南大学 |
| s1e.time.edu.cn 清华大学 |
| s2a.time.edu.cn 清华大学 |
| s2b.time.edu.cn 清华大学 |
| s2c.time.edu.cn 北京邮电大学 |
| s2d.time.edu.cn 西南地区网络中心 |
| s2e.time.edu.cn 西北地区网络中心 |
| s2f.time.edu.cn 东北地区网络中心 |
| s2g.time.edu.cn 华东南地区网络中心 |
| s2h.time.edu.cn 四川大学网络管理中心 |
| s2j.time.edu.cn 大连理工大学网络中心 |
| s2k.time.edu.cn CERNET桂林主节点 |
| s2m.time.edu.cn 北京大学 |
| ntp.sjtu.edu.cn 202.120.2.101 上海交通大学 |
ntp 常用命令
| |
| ntpq -c version |
| |
| |
| ntpq -p |
| |
| |
| ntpstat |
| |
| |
| ntpdate -u s1a.time.edu.cn |
系统时钟与硬件时钟之间同步
| |
| |
| hwclock -w |
| |
| |
| |
| hwclock -s |
| |
| vim /etc/sysconfig/ntpd |
| |
| SYNC_HWCLOCK=yes |
ntpd 与 ntpdate
ntpd 不仅仅是时间同步服务器,它还可以做客户端与标准时间服务器进行同步时间,而且是平滑同步,并非ntpdate立即同步,在生产环境中慎用ntpdate,也正如此两者不可同时运行。
时钟的跃变,对于某些程序会导致很严重的问题。
四、关于定时同步
| 定时同步可使用 crontab,添加定时任务 |
| systemctl start crond |
| |
| systemctl enable crond |
| |
| |
| crontab -e |
| |
| |
| 5 * * * * ntpdate ntp1.aliyun.com |
| |
| |
| crontab –l |
转自:https://www.cnblogs.com/jhxxb/p/10579816.html
******************************我也想难过的时候到海边走走,可是我的城市没有海。******************************
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY