网站首页 > 开源技术 正文
NTP:NTP 是网络时间协议(Network Time Protocol),它是用来同步网络
中各个计算机时间的协议。其对时精度在局域网内可达 0.1ms,且相较于
ntpdate 方式,ntp 对时更加平滑,不会造成时间跳跃式突变。
1.操作安系统出厂默认已安装 ntp 包,但 ntp 服务未自启动,需要进行
配置后再行启动,配置文件为/etc/ntp.conf,ntp 服务使用的端口号是 123,
使用 rpm -qa | grep ntp 命令查询当前系统是否已安装 ntp 包。
2. 客户端配置
vi /etc/ntp.conf 文件,找到如下内容
server 0.rhel.pool.ntp.org iburst
server 1.rhel.pool.ntp.org iburst
server 2.rhel.pool.ntp.org iburst
server 3.rhel.pool.ntp.org iburst
将这默认 4 行 server 开头的行添加#注释,并在上面添加一行:
server <时钟设备对时的 IP 地址> iburst 如下图所示
3. 服务端配置
vi /etc/ntp.conf 文件,添加内容
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
//表示允许 192.168.1.0 网段所有的机器与该服务器进行对时
server 127.127.1.0
//在不联网的时候可以把本机时间作为同步时间源
fudge 127.127.1.0 stratum 10
//设置 ntp 优先级。stratum 取值是 0-16,数字越小优先级越高
4. 服务端和客户端都启动 ntp 服务并设置开机自启动
systemctl start ntpd.service
systemctl enable ntpd.service
在客户端查看与服务端的对时状态:ntpq -p
用 date 命令查看客户端和服务端的时间是否一致。
最后使用crontab -e 添加一个定时任务,让系统定时去执行任务。
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
*/300 * * * * /usr/sbin/ntpdate -u 192.168.1.1 >/dev/null 2>&1
- 上一篇: NTP标准时间服务器在临床中心应用说明
- 下一篇: 开启Windows服务器的NTP时间服务器功能
猜你喜欢
- 2025-05-14 WP8.1 GDR1的NTP时间同步没有解决问题
- 2025-05-14 抑郁症与焦虑症(四):补充色氨酸,5HTP的作用
- 2025-05-14 ntp服务器多久同步一次呢
- 2025-05-14 简单三步,轻松解决NVR时间不同步问题
- 2025-05-14 Linux的300+个真实运维场景——19 NTP 配置与管理
- 2025-05-14 海康威视录像机时间不准怎么办录像机无法查看回放录像,NTP校时
- 2025-05-14 安全加倍,解密极氪001电池安全技术
- 2025-05-14 海康威视录像机NTP服务器
- 2025-05-14 每日一个Linux命令解析——ntpdate
- 2025-05-14 记一次NTP时间同步执行ntpdate时报错no server suitable
你 发表评论:
欢迎- 05-14WP8.1 GDR1的NTP时间同步没有解决问题
- 05-14抑郁症与焦虑症(四):补充色氨酸,5HTP的作用
- 05-14ntp服务器多久同步一次呢
- 05-14简单三步,轻松解决NVR时间不同步问题
- 05-14Linux的300+个真实运维场景——19 NTP 配置与管理
- 05-14海康威视录像机时间不准怎么办录像机无法查看回放录像,NTP校时
- 05-14安全加倍,解密极氪001电池安全技术
- 05-14海康威视录像机NTP服务器
- 最近发表
- 标签列表
-
- jdk (81)
- putty (66)
- rufus (78)
- 内网穿透 (89)
- okhttp (70)
- powertoys (74)
- windowsterminal (81)
- netcat (65)
- ghostscript (65)
- veracrypt (65)
- asp.netcore (70)
- wrk (67)
- aspose.words (80)
- itk (80)
- ajaxfileupload.js (66)
- sqlhelper (67)
- express.js (67)
- phpmailer (67)
- xjar (70)
- redisclient (78)
- wakeonlan (66)
- tinygo (85)
- startbbs (72)
- webftp (82)
- vsvim (79)
本文暂时没有评论,来添加一个吧(●'◡'●)