1、配置ntp和chrony服务,实现服务器时间自动同步

ntp服务器端

yum install -y ntp

修改配置文件
vim /etc/ntp.conf
注释以下行
#restrict default kod nomodify notrap nopeer noquery
设置时间服务器地址
server 互联网时间服务器域名或ip地址 iburst # iburst用于加速

centos6
chkconfig ntpd on # 设置开机启动
service ntpd start# 启动ntp服务

centos7
sytemctl enable ntpd # 设置开机启动
sytemctl start ntpd # 启动ntp服务

ntpq -p # 查看同步状态

ntp客户端

修改配置文件
vim /etc/ntp.conf
设置时间服务器地址
server 局域网时间服务器域名或ip地址 iburst # iburst用于加速

centos6
chkconfig ntpd on # 设置开机启动
service ntpd start # 启动ntp服务

centos7
sytemctl enable ntpd # 设置开机启动
sytemctl start ntpd # 启动ntp服务

ntpq -p # 查看同步状态


chrony服务器端

1yum install -y chrony

修改配置文件
vim /etc/chrony.conf
server 互联网时间服务器域名或ip地址 iburst # iburst用于加速
allow 0.0.0.0/0
local stratum 10

centos6
chkconfig chronyd on # 设置开机启动
service chronyd start # 启动ntp服务

centos7
sytemctl enable chronyd # 设置开机启动
sytemctl start chronyd # 启动ntp服务

ntpq -p # 查看同步状态

chrony客户端

修改配置文件
vim /etc/chrony.conf
server 互联网时间服务器域名或ip地址 iburst # iburst用于加速

centos6
chkconfig chronyd on # 设置开机启动
service chronyd start # 启动ntp服务

centos7
sytemctl enable chronyd # 设置开机启动
sytemctl start chronyd # 启动ntp服务

ntpq -p # 查看同步状态

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。