美文网首页
ntp服务器搭建

ntp服务器搭建

作者: think_lonely | 来源:发表于2018-02-24 09:37 被阅读20次

1. NTP简介

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

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

2. NTP服务器安装

    # 查看系统是否安装ntp

    [root@joj ~]# rpm -qa ntp

    ntp-4.2.6p5-5.el6.centos.x86_64

    # 如果没有就安装

    [root@joj ~]# yum -y install ntp

3. 配置NTP服务

    [root@joj ~]# vim /etc/ntp.conf

    # 放行上层服务器及允许的网间服务器

restrict default kod nomodify notrap nopeer noquery    <==拒绝 IPv4 的用戶

restrict -6 default kod nomodify notrap nopeer noquery  <==拒绝 IPv6 的用戶

restrict ntp1.aliyun.com  <==放行 ntp1.aliyun.com进入本 NTP 服务器

restrict time.nist.gov    <==放行time.nist.gov进入本 NTP 服务器

restrict 127.0.0.1        <==下边两行预设值,放行本机来源

restrict -6 ::1

restrict 192.168.100.0 mask 255.255.255.0 nomodify <==放开允许客户端访问的网段

#设定同步主机来源

server ntp1.aliyun.com  prefer  <==以阿里的ntp时间同步为先

server time.nist.gov

#預設時間差異分析檔案與暫不用到的 keys 等,不需要更動它:

driftfile /var/lib/ntp/drift

keys      /etc/ntp/keys

4. 启动NTP服务器

    # 如果计划任务有时间同步,先注释,两种用法会冲突。

    [root@joj ~]# crontab -e

    # time sync by oldboy at 2010-2-1

    #*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1

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

    Starting ntpd:                                            [  OK  ]

    [root@joj ~]# ntpq -p

      remote          refid      st t when poll reach  delay  offset  jitter

==============================================================================

*time5.aliyun.co 10.137.38.86    2 u  57  64  377  17.631  -4.314  1.777

time-c-g.nist.g .INIT.          16 u    -  64    0    0.000    0.000  0.000

    [root@joj ~]# ntpstat

    synchronised to NTP server (182.92.12.11) at stratum 3

    time correct to within 967 ms

    polling server every 64 s

    [root@joj ~]# ntpdate 10.32.1.16

24 Feb 09:32:40 ntpdate[108100]: the NTP socket is in use, exiting

5. 客户机时间同步

客户机要等几分钟再与新启动的ntp服务器进行时间同步,否则会提示no server suitable for synchronization found错误。

    [root@zyops ~]# ntpdate 10.32.1.16

    7 Dec 18:40:16 ntpdate[1453]: step time server 10.0.0.9 offset 40.880807 sec

    # 将命令放入计划任务即可。

6.客户端设置

# crontab -e

30 2 * * * /usr/sbin/ntpdate 10.32.1.16

相关文章

  • 使用dokcer镜像快速搭建ntp服务器实现时间同步

    使用镜像搭建ntp服务器,并在客户端调用进行定时时间同步。 一、 ntp服务器搭建 查询到有现成的ntp服务器do...

  • 第十三周

    1、搭建时间服务器,日志服务器并简述sudo安全切换 1)安装ntp服务器 yum install ntp 配置文...

  • 第十三周作业

    1、搭建时间服务器,日志服务器并简述sudo安全切换。 1)搭建时间服务器: 早期是用ntp服务: #yum in...

  • 笔记 时间同步服务器搭建

    ntp配置 需要搭建本地的时间同步服务器(非授时)参考:1.CentOS 6 安装 NTP Server 时间服务...

  • Linux-16 ntpdate单台服务器同步网络时间

    生产中服务器时间同步还是比较重要的,一般都不会去专门搭建NTP服务器,可以直接使用公网上的NTP服务器去同步服务器...

  • 同步服务器时间

    生产中服务器时间同步还是比较重要的,一般都不会去专门搭建NTP服务器,可以直接使用公网上的NTP服务器去同步服务器...

  • CentOS中搭建NTP服务器(网络时钟服务器)

    CentOS中搭建NTP服务器(网络时钟服务器) 文章由北京华人开创公司提供 请勿转载!!Q-522508213 ...

  • ntp服务器搭建

    1. NTP简介 NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间...

  • NTP服务器搭建

    当本机时间不准确时,我们需要对时间进行校准,那么我们就需要在互联网上找到一个可以提供我们准确时间的服务器然后通过一...

  • ntp时间同步配置

    安装 ntp 修改ntp配置文件 vi /etc/ntp.conf 添加内网ntp服务器。 systemctl s...

网友评论

      本文标题:ntp服务器搭建

      本文链接:https://www.haomeiwen.com/subject/xrxqxftx.html