ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

ubuntu下ntp时间同步

2022-08-04 12:02:59  阅读:186  来源: 互联网

标签:同步 ntp server iburst ubuntu org pool


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 重新启动

ubuntu更改时区(东八区)
tzselect

 

 

 

 

 

ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

 

标签:同步,ntp,server,iburst,ubuntu,org,pool
来源: https://www.cnblogs.com/banger/p/16550143.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有