免责声明:本文为 Installing and Configuring NTP on an ESX host (1339)的翻译版本。尽管我们会不断努力为本文提供最佳翻译版本,但本地化的内容可能会过时。有关最新内容,请参见英文版本。
/etc/ntp.conf
/etc/ntp/step-tickers
[root@esxhost]# esxcfg-firewall --enableService ntpClient
ntpd
。 /etc/ntp.conf
:cp /etc/ntp.conf /etc/ntp.conf.bk
/etc/ntp.conf
文件(ESX 安装所创建),使该文件类似于:restrict 127.0.0.1
restrict default kod nomodify notrap
server 0.vmware.pool.ntp.org
server 1.vmware.pool.ntp.org
server 2.vmware.pool.ntp.org
driftfile /var/lib/ntp/drift
/etc/ntp/drift
作为 driftfile 的位置。restrict
– 第一个 restrict
为必需项,因为 ntpd
需要通过环回网络解析主机名称地址。如果该条目不存在,系统日志 (/var/log/messages
) 将显示以下内容:ntpd_initres: ntpd returns a permission denied error
restrict
行提供 NTP 的一般 UDP 欺诈基本级别保护。kod
– 访问违规时发送 KoD 包。nomodify
– 拒绝试图修改服务器的运行时配置的 ntpq
和 ntpdc
查询。允许返回信息的查询。notrap
– 拒绝为匹配的主机提供模式 6 控制消息陷阱服务。陷阱服务是 ntpdq
控制消息协议的子系统,用于远程事件日志记录程序。 noquery
(用于阻止远程查询)和 nopeer
(用于阻止主机尝试与服务器对等,并允许欺诈性服务器控制时钟)。0.vmware.pool.ntp.org
、1.vmware.pool.ntp.org
和 2.vmware.pool.ntp.org
名称指向一组每小时都在变化的随机服务器。driftfile
行指出用来存储系统时钟偏移(频率错误)的文件的名称。有关更完整的 driftfile
定义,请参见 http://www.eecis.udel.edu/~mills/ntp/html/notes.html。/etc/ntp/step-tickers
文件:cp /etc/ntp/step-tickers /etc/ntp/step-tickers.bk
/etc/ntp/step-tickers
以使文件类似于该示例:0.vmware.pool.ntp.org
1.vmware.pool.ntp.org
2.vmware.pool.ntp.org
[root@esxhost]# esxcfg-firewall --enableService ntpClient
/etc/ntp.conf
和 /etc/ntp/step-tickers
文件之后,重新启动 NTP 服务。service ntpd restart
chkconfig --level 345 ntpd on
hwclock --systohc
ntpd
成功轮询 NTP 服务器,内核会定期将硬件时钟自动设置为系统时钟的时间。ntpdate -q time_server_name_or_ip_address
ntpd
进程的状态,请运行以下命令:watch "ntpq -p"
377
表示源已应答了前八个连续轮询。 ntpq -p
返回 ntpq: read: Connection refused
,请查看 /var/log/messages
以了解更详细的错误消息。 mount /mnt/cdrom
/mnt/cdrom/RedHat/RPMS
目录。 rpm -Uhv ntp-*.i386.rpm
/etc
目录。 /etc
目录(您已在第 5 步切换到该目录)中查找 ntp.conf
文件(安装 rpm
之后)。运行以下命令编辑该文件:vi ntp.conf
server 127.127.1.0 # local clock
server 192.6.38.127 # This is an example only
/etc/ntp
目录中创建名为 step-tickers
的文件。在该文件中,列出引用时间服务器的主机名称。 chkconfig ntpd on
/etc/rc.d/init.d/ntpd start
ntpq -p
umount /mnt/cdrom