centos7配置ntp服务器和客户端同步

环境centos7.6

服务端:ip:172.21.210.27

1、安装ntp、禁用chronyd时间同步服务

yum -y install ntp   #安装ntp服务

timedatectl set-ntp 0

2、配置ntp服务器

vi /etc/ntp.conf

restrict default nomodify                         #去掉后面的  notrap nopeer noquery

restrict 172.21.210.0 mask 255.255.255.0 nomodify notrap    #以前是注释的,修改ip段

server 127.127.1.0 #local clock                #配置自己为时间同步服务器,注意不是127.0.0.1

fudge 127.127.1.0 stratum 10  

#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst

3、重启服务

systemctl  start ntpd && systemctl  enable ntpd

客户端同步时间
方式一、ntp模式(一般redhat用)
yum -y install ntp   #安装ntp服务
vi /etc/ntp.conf  #配置server服务地址
server 172.21.210.27
systemctl  start ntpd && systemctl  enable ntpd    #重启服务
验证:
ntpdate -d 172.21.210.27 #查看同步情况
ntpq -p  #查看同步的服务器
ntpstat   #查看是否同步
 
方式二、chronyd方式(一般centos用)
yum -y install chrony
sed -i 's/0.centos.pool.ntp.org/172.21.210.27/' /etc/chrony.conf
验证:
timedatectl 
chronyc sources -v #查看时间同步源

posted @   苍茫宇宙  阅读(965)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
点击右上角即可分享
微信分享提示