ntp介绍
NTP是用来使系统和一个精确的时间源保持时间同步的协议.在Linux下,我们可以通过自带的NTP(Network Time Protocol)协议通过网络使自己的系统保持精确的时间.
ntp服务端
#调整时区
timedatectl set-timezone Asia/Shanghai
#(1)安装ntp
[root@localhost ~]# yum install ntp -y
[root@localhost ~]# mkdir /var/lib/ntp/
[root@localhost ~]# mkdir /var/log/ntp/
#(2)修改 /etc/ntp.conf
[root@localhost ~]# cp /etc/ntp.conf{,.bak}
[root@localhost ~]# vim /etc/ntp.conf
driftfile /var/lib/ntp/ #记录当前时间服务器,与上游服务器的时间差的文件
#restrict default nomodify notrap nopeer noquery
restrict 192.168.17.0 mask 255.255.255.0 nomodify #允许192.168.17.0/24网段的所有主机使用该时间服务器进行时间同步
restrict 10.10.10.0 mask 255.255.255.0 nomodify #允许10.10.10.0/24网段的所有主机使用该时间服务器进行时间同步
restrict 127.0.0.1 # 允许本机使用这个时间服务器
server 114.118.7.161 prefer # ntp.ntsc.ac.cn解析后的地址114.118.7.161优先
server 114.118.7.163 # ntp.ntsc.ac.cn解析后的地址114.118.7.163
server 203.107.6.88 # ntp.aliyun.com解析后的地

本文介绍了如何在Linux系统中通过NTP协议配置时间服务端和客户端,包括设置时区、安装NTP软件、修改配置文件、启动服务以及检查同步状态。重点在于确保时间的精确同步,避免时间不连续对数据库业务的影响。
最低0.47元/天 解锁文章
1905

被折叠的 条评论
为什么被折叠?



