ntp_new

 

服务器(10.143.86.113)端安装ntp
$ sudo apt install ntp
$ sudo apt install ntpstat
$ sudo vi /etc/ntp.conf
#注释掉默认的远程服务器,因为内网连不上这些服务器
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst
# Use Ubuntu's ntp server as a fallback.
#pool ntp.ubuntu.com
server 127.127.1.0   #设置127.127.1.0为远程时间服务器
fudge 127.127.1.0 stratum 1  #设置远程时间服务器127.127.1.0的层级为1
$ sudo service ntp restart 
$ service --status-all   #查看所有服务

 

在客户端也安装ntp
$ sudo apt install ntp
$ sudo apt install ntpstat
$ sudo vi /etc/ntp.conf
#注释掉默认的远程服务器,因为内网连不上这些服务器
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst
# Use Ubuntu's ntp server as a fallback.
#pool ntp.ubuntu.com
server 10.143.86.113   #设置10.143.86.113为远程时间服务器
$ sudo service ntp restart #大概5分钟后才能生效
$ ntp
caoming@caoming-HP:~$ date
2021年 01月 07日 星期四 11:05:22 CST
caoming@caoming-HP:~$ sudo hwclock
2021-01-07 11:07:02.996300+0800
$ ntpstat    #查看NTP服务器上层联机

配置好服务器和客户端后

服务器(10.143.86.113 )上:
cts@cts-pc:~$ ntpq -p   #查看ntp服务器与上层ntp的状态
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*LOCAL(0)        .LOCL.           1 l   64   64  177    0.000    0.000   0.000
cts@cts-pc:~$ ntpstat  #查看ntp服务器有无和上层ntp连通
synchronised to local net at stratum 2
   time correct to within 11 ms
   polling server every 64 s
cts@cts-pc:~$

客户端上:
caoming@caoming-HP:~$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*10.143.86.113   LOCAL(0)         2 u   46   64    7    0.325   -0.413   0.242
caoming@caoming-HP:~$ ntpstat
synchronised to NTP server (10.143.86.113) at stratum 3
   time correct to within 81 ms
   polling server every 64 s

层级分析:

设置服务器层级为1
服务器同步本机时间的层级为2
客户端层级为3

 

1.NTP同步的方向是从stratum值较小的节点向较大的节点传播,如果某个NTP客户端接收到stratum比自己还要大,那么NTP客户端认为自己的时间比接受到的时间更为精确,不会进行时间的更新。
2.NTP在时间差大于一天的情况下是无法同步的。
3.ntp服务重启5分钟后才能生效

posted @ 2021-01-07 16:24  牧 天  阅读(103)  评论(0)    收藏  举报