按照我的步骤一步步来就行,不明白的留言会看到回复
===========================================================
NTP服务升级
1.停止ntp服务
sudo systemctl stop ntpd
2.安装依赖包
sudo yum install -y gcc libcap libcap-devel glic-devel
3.备份如下配置文件:
sudo cp /etc/ntp.conf /etc/ntp.conf.bak
sudo cp /etc/sysconfig/ntpd /etc/sysconfig/ntpd.bak
sudo cp /etc/sysconfig/ntpdate /etc/sysconfig/ntpdate.bak
4.解压安装包
tar xvfz 安装包名称(这个是解压.gz文件的,注意后面结尾)
5.默认使用如下编译配置命令:
./configure --prefix=/usr --bindir=/usr/sbin --sysconfdir=/etc --enable-linuxcaps --with-lineeditlibs=readline --enable-all-clocks --enable-parse-clocks --enable-clockctl
(具体的编译命令要按照自己的需求修改一下,尤其是路径啥的)
sudo make
sudo make install
6.重启ntp服务
sudo systemctl restart ntpd
7.ntp同步
sudo ntpdate -u ip地址(server的ip)
=============================================================
Ntp常用命令:
ntp -v 查看版本
ntpdate -u ip地址 同步时间
ntpq -p 查询网络中的NTP服务器,同时显示客户端和每个服务器的关系
=============================================================
ntp服务器主配置文件:
# 允许172.16.*.*的IP使用该时间服务器;
restrict 172.16.0.0 mask 255.255.0.0 nomodify
#允许任何人来同步;
restrict default nomodify notrap
# 屏蔽其他IP过来更新时间;
restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap noquery notrust
#ignore:关闭所有的NTP联机服务;
#nomodify:表示Client端不能更改Server端的时间参数;不过Client端仍然可以透过Server端来进行网络校时;
#notrust:该Client除非通过认证否则该Client来源将被视为不信任网域;
#noquery:不提供Client端的时间查询;
#notrap:允许任何人来查询;
# 同步的上层服务器(210.72.145.44国家时间服务器),NTP服务器默认也有同步的时间服务器;
server 210.72.145.44
# 同步本地时间;
server 127.127.1.0 prefer
# 本地服务器的stratum大小不能超过16;
fudge 127.127.1.0 stratum 8
=========================================================