最新消息:建议使用非IE内核浏览本站博客,以便得到更好体验。比如360极速浏览器火狐等浏览器。

简单搭建NTP时钟服务器

手机电脑 李展滢 14119浏览 0评论

centos的做法:

yum -y install ntp ntpdate  #安装NTP的服务器和客户端
echo "restrict default nomodify" >> /etc/ntp.conf   #允许所有IP地址使用该服务器同步时间
echo "0.asia.pool.ntp.org" >> /etc/ntp.conf   #添加上级时钟源,在ntp.conf文件里已有时钟源,如果无法使用可以试着添加该时钟源
chkconfig   ntpd on    #添加开机启动
service ntpd start    #启动NTP服务端
ntpdate -d  127.0.0.1   #验证NTP服务端是否正常

/etc/ntp.conf为配置文件,可设置更多的配置,有兴趣的朋友可以搜索每一项参数的意义,但是像我之前上面的设置已经搭建好服务器了。

关于ntpdate -d  127.0.0.1命令后出来:

reference time:    00000000.00000000  Thu, Feb  7 2036 14:28:16.000
originate timestamp: 00000000.00000000  Thu, Feb  7 2036 14:28:16.000
transmit timestamp:  da5ae7d2.debf77e5  Tue, Feb  2 2016 16:31:14.870   #说明同步不成功
reference time:    da5ae7e3.1e4cbbf8  Tue, Feb  2 2016 16:31:31.118
originate timestamp: da5ae832.0e55f195  Tue, Feb  2 2016 16:32:50.055
transmit timestamp:  da5ae832.0e53d156  Tue, Feb  2 2016 16:32:50.055   #出来的是这样才是成功的。

windows的做法:

先到“日期和时间”中“Internet时间”的时钟上级时钟源,可以选择系统中默认的,先测试可以使用的。

使用运行或者CMD执行以下命令:

reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\TimeProviders\NtpServer /f /v Enabled /t REG_DWORD /d 1  #开机启动服务端,微软默认是关闭状态的
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time\TimeProviders\NtpClient /f /v Enabled /t REG_DWORD /d 1  #开机启动客户端端
net stop w32time && net start w32time  #重启时间服务

使用windows的cmd验证:

w32tm   /stripchart   /computer:127.0.0.1   #127.0.0.1为服务器的IP或者域名

返回15:47:56 d:+00.0704789s o:+52.2106474s则服务器可用。
返回15:31:05 错误: 0×80072746 则服务器不可用。(注意:服务器有防火墙的请打开123端口)

 

至于NTP客户端如何使用请大家使用自行搜索。

转载请注明:宿居博客 » 简单搭建NTP时钟服务器

您必须 登录 才能发表评论!