安装配置NTP服务器详解
1、在server节点上安装ntp
yum install ntp -y
2、在server节点上修改配置文件
vim /etc/ntp.conf
增加如下内容:
restrict 192.168.139.0 mask 255.255.255.0 nomodify notrap
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
参数说明:
igonre:拒绝所有类型的`NTP`连接
nomodify:Client不能够使用命令ntpc以及ntpdq来修改修改服务器的时间参数,但是可以进行网络校时;
noquery:表示不提供NTP网络校时;
notrap:表示不提供远程事件登陆的功能;
notrust:表示不接受没有认证的Clent;
默认的一个内部时钟数据,用在没有外部 NTP 服务器时,使用它为局域网用户提供服务:
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10 #设定层次作为局域网的time service provider,通常将stratum设置为10
3、在server节点上启动ntp服务
systemctl start ntpd
systemctl enable ntpd
4、在client节点上同步server的时间
ntpdate 192.168.139.96
5、编写脚本,每分钟同步一次(所有client节点)
crontab -e
增加如下信息:
* * * * * /usr/sbin/ntpdate 192.168.139.96 >> /var/log/ntpdate.log