在 NTP 中禁用 tinker panic 0 有什么缺点?

ujj*_*ain 10 redhat ntp puppet rhel6

我们有时会遇到新服务器在 bios 中的时间错误的问题,因此时间可能会延迟一个月。

当您在 VMware 中暂停虚拟机然后取消暂停时,时间也会关闭。因为 NTP 在最大偏移后不同步,我正在考虑在 /etc/ntp.conf 中使用 tinker panic 0。

有 1000 秒的默认最大偏移量导致 NTP 停止同步时间的原因是什么?我们正在使用 Puppet 来设置 NTP,我正在考虑让它在 ntp.conf 中设置 tinker panic 0,这样 NTP 无论如何都会同步。这样做的缺点是什么?

daw*_*wud 8

此处记录了未与时间如此不同的服务器同步的原因:

5.1.1.4. 如果参考时间改变会发生什么?

理想情况下,参考时间在世界各地都是相同的。一旦同步,操作系统时钟和参考时钟之间不应有任何意外变化。因此,NTP 没有特殊的方法来处理这种情况。

相反,ntpd 的反应将取决于本地时钟和参考时间之间的偏移。对于微小的偏移,ntpd 会像往常一样调整本地时钟;对于较小和较大的偏移量,ntpd 会暂时拒绝参考时间。在后一种情况下,当拒绝新的参考时间时,操作系统的时钟将继续使用最后一次有效的修正。一段时间后,小偏移(明显小于一秒)将被旋转(缓慢调整),而较大的偏移将导致时钟步进(重新设置)。巨大的偏移被拒绝,ntpd 将自行终止,相信一定发生了非常奇怪的事情。

在我当前的 NTP 配置中,也由 控制puppet,我在ntp.conf文件、使用tinker panic和守护程序设置 ( /etc/sysconfig/ntpd) 中强制与服务器同步,如ntpd(8)联机帮助页中所述:

-g 通常,如果偏移量超过恐慌阈值(默认为 1000 秒),ntpd 会退出并在系统日志中显示一条消息。此选项允许将时间设置为任何值而不受限制;然而,这只能发生一次。如果此后超过阈值,ntpd 将退出并在系统日志中显示一条消息。此选项可与 -q 和 -x 选项一起使用。

我这样做是因为我可以信任我正在连接的 NTP 服务器。

该模块适用于客户的相关部分如下:

class ntp (
  $foo
  $bar
  ...
  ){

  $my_files = {
    'ntp.conf'      => {
      path    => '/etc/ntp.conf',
      content => template("ntp/ntp.conf.$template.erb"),
      selrole => 'object_r',
      seltype => 'net_conf_t',
      require => Package['ntp'], },
    'ntp-sysconfig' => {
      path    => '/etc/sysconfig/ntpd',
      source  => 'puppet:///modules/ntp/ntp-sysconfig',
      require => Package['ntp'], },
      ...
  }

  $my_files_defaults = {
    ensure   => file,
    owner    => 'root',
    group    => 'root',
    mode     => '0644',
    selrange => 's0',
    selrole  => 'object_r',
    seltype  => 'etc_t',
    seluser  => 'system_u',
  }

  create_resources(file, $my_files, $my_files_defaults)

  exec { 'ntp initial clock set':
    command     => '/usr/sbin/ntpd -g -q -u ntp:ntp',
    refreshonly => true,
    timeout     => '-1',
    subscribe   => File['/etc/ntp.conf'],
  }

}
Run Code Online (Sandbox Code Playgroud)

并且引用文件的内容是:

$ cat devops/puppet/modules/ntp/files/ntp-sysconfig
# Drop root to id 'ntp:ntp' by default.
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g -a"
Run Code Online (Sandbox Code Playgroud)

和:

$ cat devops/puppet/modules/ntp/templates/ntp.conf.RedHat.erb
# HEADER: This file was autogenerated by puppet.
# HEADER: While it can still be managed manually, it
# HEADER: is definitely not recommended.
tinker panic 0
<% server.each do |ntpserver| -%>
server <%= ntpserver %> autokey
<% end -%>
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
crypto pw hunter2
crypto randfile /dev/urandom
keysdir /etc/ntp
Run Code Online (Sandbox Code Playgroud)

hiera此处缺少该部分,但您明白了。