CentOS7 下部署NTP服务供内网客户机使用

CentOS7 下部署NTP服务供内网客户机使用


1、安装NTP服务
# yum -y install ntp

2、修改 ntp配置
# vi /etc/ntp.conf

# 记录和上级时间服务器的时间差异,默认配置,保留
driftfile /var/lib/ntp/drift

#表示nomodify客户端可以同步时间
restrict default nomodify

# 允许本机的一切操作,默认策略,保留
restrict 127.0.0.1
restrict ::1

# 阿里云NTP服务可修改本NTP服务时间
restrict ntp.aliyun.com

# 添加阿里云时间源
server ntp.aliyun.com

3、启动NTP服务
启动:systemctl start ntpd
设置开机自启:systemctl enable ntpd

5、查看主备NTP服务器状态
IP地址前有*号,表示此服务器是主NTP服务器。
IP地址前有+号,表示此服务器是备NTP服务器。
Offset表示时间偏移秒数。

# ntpq -p

注意: 刚启动ntp服务有5分钟左右的同步时间,此时客户端用 ntpdate 同步时会报错如下:
ntpdate[29221]: no server suitable for synchronization found

多等一会,当执行 ntpq -p 显示上游服务器前带 * 即正常,如下:

remote refid st t when poll reach delay offset jitter

==============================================================================
*ntp.aliyun.com 100.107.25.114 2 u 47 64 17 13.471 20.391 3.650

还有一个命令是 ntpstat , 显示如下是正常的,否则检查配置,再重启一次

# ntpstat
synchronised to NTP server (203.107.6.88) at stratum 3
time correct to within 958 ms
polling server every 64 s


细节参考: https://www.cnblogs.com/harrymore/p/9566229.html
-----------------------------------------------------------------------------


AIX客户端同步NTP时间:

1、配置/etc/ntp.conf文件,添加NTP服务器地址信息(server 192.168.1.20)
broadcastclient
driftfile /etc/ntp.drift
server 192.168.1.125 //此处为内网ntp务器地址
tracefile /etc/ntp.trace

//启动 xntpd
方法1:
# startsrc -s xntpd
//停止服务
# stopsrc -s xntpd

方法2:
# smit xntpd

//设置xntpd服务自动启动
# vi /etc/rc.tcpip
//去掉如下行的 # 号
start /usr/sbin/xntpd "$src_running"

//检查服务状态
//当 system peer 不为 ‘insane’ 时, 表明客户端已与服务器端成功地进行了同步。
# lssrc -ls xntpd

也可以查看xntpd是不是tcpip的一个子服务
# lssrc -g tcpip


//使用ntpdate手动与NTP服务器同步
# ntpdate -d 192.168.1.20

posted @ 2020-04-09 11:49  莫让年华付水流  阅读(757)  评论(0编辑  收藏  举报