搭建ntp时间服务器 ntp,搭建ntp时间服务器


 

 

第1章 ntp

1.1 ntp简介

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

1.2 ntp服务端部署

1.2.1 环境说明
  使用系统:CentOS 7.4 (CentOS6自带 CentOS7需要安装的)
  ip地址: 外网-10.0.0.62   内网-172.16.1.62
1.2.2 安装ntp
  yum -y install ntp
1.2.3 修改配置文件
  vim /etc/ntp.conf  #添加
        restrict 172.16.1.0 mask 255.255.255.0 nomodify notrap
        server ntp1.aliyun.com
1.2.4 启动
  systemctl start ntpd   #启动
  systemctl status ntpd  #查看状态
  [root@m02 ~]# ntpstat  #查看是否正常
    synchronised (同步的) to NTP server (5.79.108.34) at stratum 3 
     time correct to within 1230 ms
     polling server every 64 s

1.1 客户端使用

1.3.1 测试
  ntpdate   172.16.1.62
  ntpdate -d  172.16.1.62
1.3.2 加入定时任务
  echo "*/5 * * * * /usr/sbin/ntpdate 172.16.1.62  &>/dev/null"  >>/var/spool/cron/root

 

相关内容