ntp时间同步

1 篇文章 0 订阅

ntp

NTP的时间同步有两种方式,一种是通过ntpdate进行手动调整(也可以做成定时任务);一种是通过ntpd服务进行自动调整

ntpdate就是执行该命令的时候就将客户端的时钟与服务器端的时钟做下同步,不管差异多大,都是一次调整到位。

而ntpd服务的方式,又有两种策略,一种是平滑、缓慢的渐进式调整(adjusts the clock in small steps所谓的微调);一种是步进式调整(跳跃式调整)。两种策略的区别就在于,微调方式在启动NTP服务时加了个“-x”的参数,而默认的是不加“-x”参数。
  • 假如使用了-x选项,那么ntpd只做微调,不跳跃调整时间,但是要注意,-x参数的负作用:当时钟差大的时候,同步时间将花费很长的时间。-x也有一个阈值,就是600s,当系统时钟与标准时间差距大于600s时,ntpd会使用较大“步进值”的方式来调整时间,将时钟“步进”调整到正确时间。

  • 假如不使用-x选项,那么ntpd在时钟差距小于128ms时,使用微调方式调整时间,当时差大于128ms时,使用“跳跃”式调整。

这两种方式都会在本地时钟与远端的NTP服务器时钟相差大于1000s时,ntpd会停止工作。在启动NTP时加了参数“-g”就可以忽略1000S的问题。

以下是man ntpd里关于加参数“-x”的描述:

-x
Normally, the time is slewed if the offset is less than the step threshold, which is 128 msby default, and stepped if above the threshold. This option sets the threshold to 600 s, which is well within the accuracy window to set the clock manually. Note: Since the slew rate of typical Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an amortization interval of 2000 s. Thus, an adjustment as much as 600 s will take almost 14 days to complete. This option can be used with the -g and -q options. See the tinker command for other options. Note: The kernel time discipline is disabled with this option.

root@ip-10-0-5-85:/var/log# cd /etc/default/
root@ip-10-0-5-85:/etc/default# ls
acpid   bsdmainutils   cron        dbus    grub    halt        keyboard  nss      ntp      pollinate  rsync    ssh  useradd
apport  console-setup  cryptdisks  devpts  grub.d  irqbalance  locale    ntfs-3g  ntpdate  rcS        rsyslog  ufw
root@ip-10-0-5-85:/etc/default# cat ntp
NTPD_OPTS=''
OPTIONS="-u ntp:ntp -x  -p /var/run/ntpd.pid"
root@ip-10-0-5-85:/etc/default# ps -ef|grep ntp
ntp       4563     1  0 02:05 ?        00:00:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -u 107:112 -x -g
root      9320  3961  0 02:57 pts/0    00:00:00 grep --color=auto ntp
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值