NTP服务配置
apt update
apt install ntp
vim /etc/ntp.conf
# NTP configuration file for Ubuntu
#
# For more information, see /usr/share/doc/ntp-doc/html/ntp_conf.html
driftfile /var/lib/ntp/ntp.drift # 存储系统频率偏移的文件
statsdir /var/lib/ntpstats # 存储统计文件的目录
logfile /var/log/ntp.log # NTP 日志文件
server ntp.aliyun.com iburst # NTP 服务器地址,并使用 iburst 参数加快初次同步的速度,ntp.aliyun.com为阿里云开源的ntp服务器
restrict default kod nomodify notrap nopeer noquery # 限制所有主机(除了本地主机)对 NTP 服务的访问权限
restrict -6 default kod nomodify notrap nopeer noquery # 限制所有 IPv6 主机(除了本地主机)对 NTP 服务的访问权限
restrict 127.0.0.1 # 允许本地主机(IPv4)不受限制地访问 NTP 服务
restrict -6 ::1 # 允许本地主机(IPv6)不受限制地访问 NTP 服
timedatectl set-timezone Asia/Shanghai
systemctl start ntp
systemctl enable ntp
systemctl status ntp
ntpq -p //检查ntp同步状态

remote //NTP 客户端正在同步的时间服务器的 IP 地址或域名
refid //时间服务器获取时间信息的源
st //时间服务器的层次级别,数字越小,表示时间服务器离原子钟越近,在此例中,2 表示这是一个二级时间服务器
t //时间服务器的类型,u 表示这是一个未经验证的时间服务器(通常意味着它是一个公共时间服务器)
when //最后一次与时间服务器通信的时间
poll //客户端与时间服务器之间的轮询间隔(以秒为单位)
reach //与时间服务器的连接质量,数值范围从 0 到 377,其中 377 表示最佳连接质量
delay //客户端与时间服务器之间往返时间的一半(以毫秒为单位)
offset //客户端时钟与时间服务器时钟之间的偏差(以毫秒为单位)
jitter //时间偏差的变化量(以毫秒为单位),反映了时间服务器的稳定性
参数调整
server 192.168.1.10 iburst poll 64 prefer minpoll 16 maxpoll 1024 noquery notrap nomodify nopeer
iburst: 加快初次同步的速度。
poll 64: 轮询间隔为 64 秒。
prefer: 将此服务器标记为首选服务器。
minpoll 16: 最小轮询间隔为 16 秒。
maxpoll 1024: 最大轮询间隔为 1024 秒。
noquery: 禁止向服务器发送查询请求。
notrap: 禁止接收来自服务器的陷阱消息。
nomodify: 禁止修改服务器的配置。
nopeer: 禁止与服务器进行对等通信。

被折叠的 条评论
为什么被折叠?



