ntp.md
1.48 KB
ntp时间校验组件安装
Centos7上使用chrony组件,同步时间,目前只是设置了时间服务器,以后别的机器需要同步时间服务器
//---------- linux时间同步(chrony服务器) ----------//
// 查看是否安装了chrony
rpm -qa|grep chrony
// 没有找到,yum安装
yum install chrony -y
// 修改/etc/chrony.conf配置文件,如下图:
// 启动chrony服务,加入开机启动项,查看状态
systemctl enable chronyd.service
systemctl restart chronyd.service
systemctl status chronyd.service
// 查看时间源服务器状态,状态提示,如图显示*为已经同步了
chronyc sources -v
chronyc sourcestats -v
chronyc activity
// 手动同步时间
chronyc -a makestep
// 设置防火墙规则
firewall-cmd --add-service=ntp --permanent
在/etc/firewalld/services下添加my_chrony.xml文件,如下图,
firewall-cmd --add-service=my_chrony --permanent
firewall-cmd --reload
// 与timedatectl关联,如下图:
timedatectl set-ntp 1
//---------- linux时间同步(chrony客户端)centos7 ----------//
// 同上安装chrony
// 防火墙开启ntp服务
firewall-cmd --add-service=ntp --permanent
// /etc/chrony.cnf配置文件,如下图:
//---------- linux时间同步(chrony客户端)centos6 -----------//
// 停止ntpd服务,取消开机自启
service ntpd stop
chkconfig ntpd off
// 添加chronyd服务,开机自启,启动服务
chkconfig --add chronyd
chkconfig chronyd on
service chronyd start
// 配置同上