CentOS之NTP服务器配置

  本文使用CentOS 6.5作为搭建环境

一、服务器端配置

  1.安装所需软件包
  yum -y install ntp ntpdate
-------------------------------------------

  2.编辑NTP主配置文件,修改如下:
  vim /etc/ntp.conf

  #允许192.168.244.0网段同步
  restrict 192.168.244.0 mask 255.255.255.0 nomodify notrap      
  #注释如下几行
  #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

  #添加本地时间为服务时间

  server s2m.time.edu.cn iburst
  server 127.127.1.0 iburst    # local clock

--------------------------------------------

  3.重启ntp服务
  service ntpd restart

  验证:

  查看端口是否存在

  netstat -tulnp | grep ntp

--------------------------------------------

  4.设置开机自启动
  chkconfig ntpd on
----------------------------------------------
  5.查看现有连接客户端
  watch ntpq -p
       remote           refid     st t when poll reach   delay   offset  jitter
  ==============================================================================
  *LOCAL(0)        .LOCL.           5 l   46   64  377    0.000    0.000   0.000

------------------------------------------------
二、客户端配置:

  1、命令行手动执行一次验证是否可用:
  #ntpdate 192.168.244.20
   4 Dec 13:57:13 ntpdate[32277]: step time server 192.168.244.20 offset -24.396496 sec

  2.配置自动同步
  crontab -e
  15 1 * * *        /usr/sbin/ntpdate 192.168.244.20; /sbin/hwclock -w  

  IP以自己服务端IP为准

原文地址:https://www.cnblogs.com/jim-hwg/p/4606821.html