实体云服务器 ntpd服务安装 yum -y install ntp 添加远程时间同步信息 server 10.25.128.66 iburst Server 10.25.128.67 iburst 注意事项 iburst 不会 增加服务器负载(只在···
实体云服务器
ntpd服务安装
yum -y install ntp
添加远程时间同步信息
server 10.25.128.66 iburst
Server 10.25.128.67 iburst
注意事项
iburst 不会 增加服务器负载(只在启动时触发一次)。
如果 NTP 服务器禁止 burst 请求(如某些公共池),可能会被 限制或封 IP,但国内主流源(阿里云、腾讯云)都支持。
与 burst 不同:
iburst:仅用于初始同步,推荐。
burst:持续高频率请求,不推荐,可能被服务器封禁。
✅ 总结一句话
生产环境务必加上 iburst,能显著缩短首次同步时间,几乎无副作用。
systemctl enable ntpd && systemctl restart ntpd
cat /etc/ntp.conf
本地作为时间同步服务器需要配置
把本地时钟伪装成 stratum-10 参考源
访问控制
restrict default kod nomodify notrap nopeer noquery
restrict 127.0.0.1 允许本机使用时间服务器
默认拒绝所有外部访问,只允许同步时间,但不允许配置
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited
nomodify表示客户端不能更改服务器端的时间参数,参数说明在下面
10.25.128.0网段的设备访问NTP服务,但不能修改服务器时间。
restrict 10.25.128.0 mask 255.255.255.0 nomodify notrap
外部时间源
prefer表示优先使用该项
server asia.pool.ntp.org prefer iburst
server 0.asia.pool.ntp.org iburst
server 1.asia.pool.ntp.org iburst
server 2.asia.pool.ntp.org iburst
server time.nist.gov iburst
阿里云服务器要多少钱
本地兜底 本地时钟,0 表示使用本地时钟,1 表示使用硬件时钟
server 127.127.1.0
fudge 127.127.1.0 stratum 10 设置本地时钟的层次(默认是 10)
这样即可保证:
有外网时,本机自动从外网 stratum-1/2 源同步,并对外提供 stratum-2/3 服务;
外网全部失效时,ntpd 会回落到 127.127.1.0,并把自身 stratum 降到 10,继续为内网客户端提供时间,但不会被误当成权威时间。
客户端配置(客户端只需同步时间,不需要提供时间,因此不必把自己配置成 NTP 服务器;开 ntpd(或 chronyd)就够了。):
/etc/ntp.conf
server 10.25.128.66 iburst
fudge 192.168.128.66 stratum 10
systemctl restart ntpd
或者
yum -y install ntpdate 默认应该都有安装
crontab -e
sync time with local ntp server 192.168.128.66 every day
30 06 * * * /usr/sbin/ntpdate 192.168.128.66 &> /dev/null;/sbin/hwclock -w &> /dev/null
查看ntp服务器与上层ntp的状态
【命令】ntpq -p
remote:本机和上层ntp的ip或主机名,+表示优先,*表示次优先
公司云服务器内存
refid:参考上一层ntp主机地址
st:stratum阶层
when:多少秒前曾经同步过时间
poll:下次更新在多少秒后
reach:已经向上层ntp服务器要求更新的次数
delay:网络延迟
offset:时间补偿
jitter:系统时间与bios时间差
国内常用的NTP时间源同步服务器汇总:
使用以前请先ping相应的域名查看网络是否可达,和相应的访问速度
ntp.ntsc.ac.cn 中国国家授时中心
cn.ntp.org.cn 中国授时
阿里云NTP时间源服务器
ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com
国内一些大学NTP时间源服务器
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服务,以下7个域名
http://time1.apple.com
http://time2.apple.com
http://time3.apple.com
http://time4.apple.com
http://time5.apple.com
http://time6.apple.com
http://time7.apple.com
Google(谷歌)提供的NTP服务,以下4个域名
http://time1.google.com
http://time2.google.com
http://time3.google.com
http://time4.google.com
阿里云服务器多个网站

发表评论
最近发表
标签列表