Centos 7.3 内网时间同步设置
进入ntp.conf配置文件,注释以server开头的配置,并添加内容:server 10.2.3.106添加完成保存退出。10.2.3.106 为我的时间服务器[root@localhost ~]# vim /etc/ntp.conf ▽ "/etc/ntp.conf" 59L, 2050C# These servers were defined in the installation:@增加server IPserver 10.2.3.106server 0.centos.pool.ntp.org iburstserver 1.centos.pool.ntp.org iburstserver 2.centos.pool.ntp.org iburstserver 3.centos.pool.ntp.org iburst #重启服务[root@localhost ~]# systemctl restart ntpd.service #查看状态[root@localhost ~]# systemctl status ntpd.service查看ntp服务是否能够被同步,显示为“LOCAL”,表示成功。如果没有任何显示,客户端将无法同步。[root@localhost ~]# ntpq -p remote refid st t when poll reach delay offset jitter==============================================================================*10.2.3.106 202.120.2.101 4 u 45 64 1 3.418 -2.245 0.000#使用ntpdate来同步:[root@localhost ~]# ntpdate 10.2.3.106#这个错误的原因是存在已经启动的ntpdate服务,重复启动导致的。31 Jan 11:32:51 ntpdate[19791]: the NTP socket is in use, exiting[root@localhost ~]# ping 10.2.3.106PING 10.2.3.106 (10.2.3.106) 56(84) bytes of data.64 bytes from 10.2.3.106: icmp_seq=1 ttl=63 time=1.94 ms64 bytes from 10.2.3.106: icmp_seq=2 ttl=63 time=2.87 ms#使用下面的命令查看进程 #lsof -i:123[root@localhost ~]# lsof -i:123COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEntpd 19776 ntp 16u IPv4 221312 0t0 UDP *:ntp ntpd 19776 ntp 17u IPv6 221313 0t0 UDP *:ntp ntpd 19776 ntp 18u IPv4 221318 0t0 UDP localhost:ntp ntpd 19776 ntp 19u IPv4 221319 0t0 UDP localhost.localdomain:ntp ntpd 19776 ntp 20u IPv4 221320 0t0 UDP localhost.localdomain:ntp ntpd 19776 ntp 21u IPv6 221321 0t0 UDP localhost:ntp 这里只要使用kill -9 PID,杀掉ntpd产生的进程号19776就可以了[root@localhost ~]# kill -9 19776[root@localhost ~]# ntpdate 10.2.3.10631 Jan 11:35:42 ntpdate[19822]: adjust time server 10.2.3.106 offset 0.001059 sec[root@localhost ~]# ntpdate 10.2.3.10631 Jan 11:38:32 ntpdate[19839]: adjust time server 10.2.3.106 offset 0.001629 sec#查询本地时间[root@localhost ~]# dateWed Jan 31 11:41:12 CST 2018