【ntp】NTP服务器时间同步三部曲

【ntp】NTP服务器时间同步三部曲,第1张

在一台计算机上我们有两个时钟:一个称之为硬件时间时钟(RTC),还有一个称之为系统时钟(System Clock)。
系统时钟就是 *** 作系统的kernel所用来计算时间的时钟 它从1970年1月1日00:00:00 UTC时间到目前为止秒数总和的值。

在Linux下,系统时间在开机的时候会和RTC硬件时钟同步(synchronization),之后也就 各自独立运行 了。

系统运行期间,则通过其他硬件时钟源进行tick计算(tsc、hpet、acpi_pm)。

RTC(real time clock)通过主板(CMOS)的电磁供电,精确到秒。用户可手工设置RTC时间。

1 强制跃迁同步

ntpdate -u xxxxxxxx

xxxxxxxx 为ntpServer地址,如 ntpaliyuncom

注意:此时本机的ntpd不能启动,否则执行 ntpdate会报socket占用
2 将系统时间同步到硬件时钟

hwclock -w 
3 启动ntpd,后续平滑同步

systemctl start ntpd

注意:此时本机的不能在ntpd运行期间执行ntpdate,否则会报socket占用
NTP服务器时间监控脚本

>安装NTP服务可以说很容易,几个要点搞定就成。下面是我装NTP服务器的记录。
一、首先当然是惯例更新

然后修改下配置文件。
这里我们建议去找最近的ntp公共服务器,访问站点 >CentOS:
0centospoolntporg
1centospoolntporg
2centospoolntporg
国内可用的
ntpfudaneducn 复旦
2107214544 国家守势中心服务器
亚洲地区的ntp服务器
Bangladesh — bdpoolntporg (0)
China — cnpoolntporg (3)
Hong Kong — hkpoolntporg (1)
India — inpoolntporg (2)
Indonesia — idpoolntporg (2)
Iran — irpoolntporg (0)
Israel — ilpoolntporg (3)
Japan — jppoolntporg (5)
Korea — krpoolntporg (4)
Malaysia — mypoolntporg (3)
Philippines — phpoolntporg (0)
Singapore — sgpoolntporg (3)
Taiwan — twpoolntporg (7)
Thailand — thpoolntporg (1)
Turkey — trpoolntporg (1)
United Arab Emirates — aepoolntporg (0)
国外的:
timenistgov 美国
time-anistgov
time-bnistgov
time-nwnistgov

1、首先在电脑上打开linux系统。再cd和su命令进入root用户。

2、然后检查linux系统的时间。命令为date  +%F +%T。

3、启动ntp服务。命令为service ntp start。

4、进入etc/initd/文件。再启动ntp服务。

5、可以连接服务器更新时间。命令为ntpdate ip地址。

6、设置ntpd开机启动项。再规定ntpd服务自动启动。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/13428830.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-08-04
下一篇 2023-08-04

发表评论

登录后才能评论

评论列表(0条)

保存