随笔 - 836  文章 - 1 评论 - 40 阅读 - 102万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

参考原文:https://blog.csdn.net/wyfsxs/article/details/80608957

 

1. 首先安装ntp服务(ubuntu 16.02)
在linux的root用户下执行以下命

   sudo apt-get install  ntp

(如果不是ubuntu系统则执行 yum install ntp –y)

2. 修改ntp配置文件(server)
我们需要在linux集群中找到一台作为ntp服务器的server,其他机器则为ntp的client,因此,在server服务器上修改一下配置文件
执行

退出保存,重启ntp服务

执行 service ntp restart

 

 vim /etc/ntp.conf

复制代码
#linux自带的时间同步,需要注释掉
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst
# Use Ubuntu's ntp server as a fallback.
#pool ntp.ubuntu.com
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1
#因为是内网,所以用本地时间做为服务器时间,注意这里不是127.0.0.1
server 127.127.1.0
fudge 127.127.1.0 stratum 8

#开放192.168.8.0 整个网段,即在这个网段的所有机器都可以使用 214 作为时间同步服务端
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap
复制代码

 

3. 修改ntp配置文件(client)

同样的server端已经配置好了,client的配置相对简单

 执行 sudo  vim /etc/ntp.conf

复制代码
#linux自带的时间同步,需要注释掉
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst
# Use Ubuntu's ntp server as a fallback.
#pool ntp.ubuntu.com
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

#增加214作为时间服务器即可
server 192.168.0.214
# Needed for adding pool entries

restrict source notrap nomodify noquery
复制代码

 

退出保存,重启ntp服务

执行 sudo  service ntp restart

4. 查看ntp服务是否配置完成
在ntp sever上执行 ntpq -p

在ntp client上执行 ntpq –p

即完成ntp服务的配置

 

 

5. ntp服务的相关命令
service ntpstart 启动

service ntp stop停止

service ntprestart 重新启动

 

posted on   lshan  阅读(2582)  评论(1编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示