阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 6.9下NTP时间服务器搭建

140次阅读
没有评论

共计 2281 个字符,预计需要花费 6 分钟才能阅读完成。

1.1 NTP 简介

NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议。它的用途是把计算机的时钟同步到世界协调时 UTC,其精度在局域网内可达 0.1ms,在互联网上绝大多数的地方其精度可以达到 1 -50ms。

NTP 服务器就是利用 NTP 协议提供时间同步服务的。

系统版本

[root@test ~]# cat /etc/RedHat-release

CentOS release 6.9 (Final)

1.2 NTP 服务器安装

[root@test ~]# rpm -qa ntp

ntp-4.2.6p5-10.el6.centos.2.x86_64

如果没有安装就 yum install ntp - y 进行安装

1.3 配置 NTP 服务

备份配置文件

[root@test ~]# cp /etc/ntp.conf{,.bak}

[root@test ~]# ll /etc/ntp.conf*

-rw-r–r–. 1 root root 1778 Jan 11  2017 /etc/ntp.conf

-rw-r–r–  1 root root 1778 Oct 23 23:10 /etc/ntp.conf.bak

精简化配置文件

[root@test ~]# egrep -v “^$|#” /etc/ntp.conf.bak  >/etc/ntp.conf

修改配置文件

[root@test ~]# cat /etc/ntp.conf

#driftfile /var/lib/ntp/drift

#restrict default kod nomodify notrap nopeer noquery

#restrict -6 default kod nomodify notrap nopeer noquery

#restrict 127.0.0.1

#restrict -6 ::1

#server 0.centos.pool.ntp.org iburst

#server 1.centos.pool.ntp.org iburst

#server 2.centos.pool.ntp.org iburst

#server 3.centos.pool.ntp.org iburst

#includefile /etc/ntp/crypto/pw

#keys /etc/ntp/keys

# nomodify 客户端可以同步

# 将默认时间同步源注释改用可用源

restrict default nomodify

server ntp1.aliyun.com

server time.nist.gov

1.4 启动 NTP 服务器

注意:如果有同步时间的定时任务要将其注销,否则会冲突

[root@test ~]# /etc/init.d/ntpd start

Starting ntpd:                                            [OK]

显示节点列表

[root@test ~]# ntpq -p
    remote          refid      st t when poll reach  delay  offset  jitter
==============================================================================
 time5.aliyun.co 10.137.38.86    2 u  28  64    3    5.092  6241215 185.623

 132.163.96.4    .INIT.          16 u    –  64    0    0.000    0.000  0.000

1.5 客户机时间同步

客户机要等几分钟再与新启动的 ntp 服务器进行时间同步,否则会提示

no server suitable for synchronization found 错误

[root@client ~]# ntpdate 10.0.0.250

24 Oct 16:46:58 ntpdate[26694]: adjust time server 10.0.0.250 offset 0.320652 sec

本博文中所使用的系统版本为: CentOS release 6.9 (Final) 内核版本为:2.6.32-696.10.1.el6.x86_64 望读者注意!

更多 NTP 时间服务器 相关教程见以下内容

开源软件包的安装及 ntp 时间服务器简析  http://www.linuxidc.com/Linux/2017-02/140342.htm

Linux 时间同步 NTP 服务的安装与配置 http://www.linuxidc.com/Linux/2016-10/135945.htm

如何在 CentOS 中搭建 NTP 服务器  http://www.linuxidc.com/Linux/2015-06/118480.htm

教你如何快速搭建 NTP 时间服务器  http://www.linuxidc.com/Linux/2017-02/140875.htm

CentOS 7 中使用 NTP 进行时间同步  http://www.linuxidc.com/Linux/2015-11/124911.htm

Linux 之使用 NTP 服务管理 / 同步服务器时间  http://www.linuxidc.com/Linux/2016-03/129277.htm

Linux 下搭建 NTP 服务器  http://www.linuxidc.com/Linux/2016-03/129126.htm

NTP 服务配置详解  http://www.linuxidc.com/Linux/2017-08/146188.htm

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-10/147962.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计2281字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中