NTP时间同步服务器设置
- 时间同步服务器搭建
- 一、环境准备
- 二、安装服务
- 1,服务端(2.10)
- 2,客户端(2.11)
- 三、设置开机自启动
- 四、查看时间同步日志信息
避坑:
1,服务器全部安装ntp服务,通过配置文件中minpoll、maxpoll两个参数来调整轮训时间源服务器同步频率,测试很多次,全部失败。
2,调整方式:server iburst minpoll 3 maxpoll 4
3,有调整成功的欢迎给出指导意见,以下是比较稳妥的一种时间同步方式。
4,参数调整参考:
/ntpfaq/#Q-ALGO-POLL-BEST
/~mills/ntp/html/
时间同步服务器搭建
一、环境准备
虚拟机 | IP | 系统 |
---|---|---|
ntp时间同步服务器(服务端) | 192.168.2.10 | centos7 |
同步主服务器时间 (客户端) | 192.168.2.11 | centos7 |
二、安装服务
1,服务端(2.10)
1,安装ntp服务
yum -y install ntp
2,修改配置文件: vi /etc/
restrict default nomodify notrap nopeer noquery
# Use public servers from the project.
# Please consider joining the pool (/).
#server iburst
#server iburst
#server iburst
#server iburst
# server 全部注释,添加下面时间源地址
server 127.127.1.0
fudge 127.127.1.0 stratum 0
3,启动ntp服务
systemctl start ntpd
2,客户端(2.11)
1,添加hosts 域名映射 vi /etc/hosts
192.168.2.10
2,安装ntpdate
yum -y install ntpdate
3,测试ntpdate 命令是否安装成功,并测试是否可以同步本地时间服务器
4.1 date # 查看系统当前时间(同时查看时间服务器上的时间是否一致)
4.2 /usr/sbin/ntpdate # 这个域名映射的是本地局域网内的时间服务器
4,添加定时任务:crontab -e , 每10分钟同步一次服务器时间
*/10 * * * * /usr/sbin/ntpdate
三、设置开机自启动
1,关闭linux时间同步服务:chronyd
systemctl diable chronyd
2,设置ntp开机自启动
systemctl enable ntpd
3,启动ntpd
systemctl start ntpd
四、查看时间同步日志信息
cat /var/spool/mail/root
详细ntp配置说明可以参考:ntp配置参数详解