linux设置ntp时间同步
发表于:2025-12-01 作者:千家信息网编辑
千家信息网最后更新 2025年12月01日,NTP时钟同步方式说明NTP在linux下有两种时钟同步方式,分别为直接同步和平滑同步:直接同步使用ntpdate命令进行同步,直接进行时间变更。如果服务器上存在一个12点运行的任务,当前服务器时间是
千家信息网最后更新 2025年12月01日linux设置ntp时间同步
NTP时钟同步方式说明
NTP在linux下有两种时钟同步方式,分别为直接同步和平滑同步:
直接同步
使用ntpdate命令进行同步,直接进行时间变更。如果服务器上存在一个12点运行的任务,当前服务器时间是13点,但标准时间时11点,使用此命令可能会造成任务重复执行。因此使用ntpdate同步可能会引发风险,因此该命令也多用于配置时钟同步服务时第一次同步时间时使用。
平滑同步
使用ntpd进行时钟同步,可以保证一个时间不经历两次,它每次同步时间的偏移量不会太陡,是慢慢来的,这正因为这样,ntpd平滑同步可能耗费的时间比较长。
1、安装ntp
yum install ntp2、设置ntp服务开机启动
systemctl restart ntp.service3、设置服务器
3.1. vi /etc/ntp.conf,内容如下:driftfile /var/lib/ntp/ntp.drift #草稿文件# 允许内网其他机器同步时间restrict 192.168.137.0(替换成自己的ip) mask 255.255.255.0 nomodify notrap# Use public servers from the pool.ntp.org project.# 中国这边最活跃的时间服务器 :[http://www.pool.ntp.org/zone/cn](http://www.pool.ntp.org/zone/cn)server 210.72.145.44 perfer # 中国国家受时中心server 202.112.10.36 # 1.cn.pool.ntp.orgserver 59.124.196.83 # 0.asia.pool.ntp.org # allow update time by the upper server# 允许上层时间服务器主动修改本机时间restrict 210.72.145.44 nomodify notrap noqueryrestrict 202.112.10.36 nomodify notrap noqueryrestrict 59.124.196.83 nomodify notrap noquery # 外部时间服务器不可用时,以本地时间作为时间服务server 127.127.1.0 # local clockfudge 127.127.1.0 stratum 103.2 重启服务:service ntpd restart
3.3查看同步状态:netstat -tlunp | grep ntp
4、设置同步
4.1 vim /etc/ntp.conf,内容如下:driftfile /var/lib/ntp/ntp.drift # 草稿文件statsdir /var/log/ntpstats/statistics loopstats peerstats clockstatsfilegen loopstats file loopstats type day enablefilegen peerstats file peerstats type day enablefilegen clockstats file clockstats type day enable#让NTP Server为内网的ntp服务器server 192.168.137.110 (master节点ip)fudge 192.168.137.110 stratum 5#不允许来自公网上ipv4和ipv6客户端的访问restrict -4 default kod notrap nomodify nopeer noqueryrestrict -6 default kod notrap nomodify nopeer noquery#Local users may interrogate the ntp server more closely.restrict 127.0.0.1restrict ::14.2重启服务:service ntpd restart
4.3手动同步:ntpdate -u 192.168.124.146
同步
时间
服务
服务器
时钟
平滑
命令
任务
内容
文件
方式
草稿
中国
主动
上层
下有
国家
客户
慢慢来
手动
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
网络安全法56条
远程服务器调出任务管理器
赛默飞世尔 软件开发
sql数据库日志清理工具
宿迁云主机服务器供应商
python的数据库操作
云上网络安全教程
服务器只开放80端口
北京火龙果网络技术有限公司
阿里云云服务器已过期怎么续费
西安交易软件开发
天津淘商网络技术
软件开发流程相应文档
jsp技术与数据库
php 分布式服务器
重力感应无人售货柜软件开发
软件开发培训学校凯迪拉克
数据库点击查看只显示一条数据
网络安全 书 推荐
网络技术工程师女生的优势
软件开发模式的书籍
第三方支付的网络安全风险
北京戴尔服务器代理商
云软件开发有前途吗
深圳搜搜网络技术公司
北京数据库招聘
为自己建立一个数据库
安全知识网络安全知识网课
企业网络安全配置服务器
收费站网络安全组织机构及职责