安装ntp

#检查服务是否安装
  1. rpm -q ntp
#安装ntp服务器
  1. yum -y install ntp

修改配置文件:/etc/ntp.conf

内容如下:
  1. restrict default kod nomodify notrap nopeer noquery
  2. restrict -6 default kod nomodify notrap nopeer noquery
  3. restrict 127.0.0.1 
  4. restrict -6 ::1
  5. fudge 127.127.1.0 stratum 10
  6. driftfile /var/lib/ntp/drift
  7. keys /etc/ntp/keys
  8. logfile /var/log/ntp.log
  9. includefile /etc/ntp/crypto/pw
  10. server 128.199.84.169


设置ntpd为系统服务,并开机自启动

  1. systemctl enable ntpd
  2. systemctl restart ntpd

测试Ntpd服务

1. 修改系统时间

  1. date -s "2016-03-09 07:00:00"


2. 使用tcpdump抓包测试

在一个终端执行:
  1. tcpdump -i eth0 -s 0 -vvvvv udp port 123
说明:ntpd是使用udp 123端口来传输数据的

3. 重启ntpd服务,查看时间同步结果

  1. systemctl restart ntpd

此时看看tcpdump抓包情况



手动同步时间

ntpdate 128.199.84.169  
(若报错,可参考:https://linux.cn/blog-6599-5989.html  )

其他命令

1. ntpq -p 
查看本机和上层服务器的时间同步结果
2. ntptrace
可以用來追踪某台时间服务器的时间对应关系 
3. ntpdate IP ,如:ntpdate 128.199.84.169    
  客户端与NTP server进行时钟同步。
4. tail -f /var/log/ntp.log
查看ntp日志

systemctl stop ntpd.service
ntpdate 128.199.84.169     #手动同步

【ntp】centos7下ntp服务器设置的更多相关文章

  1. centos7下SVN服务器如何搭建

    Centos7 搭建svn服务器 linux(centos)下SVN服务器如何搭建?说到SVN服务器,想必大家都知道,可以是在LINUX下如何搭建SVN服务器呢?那么今天给大家分享一下linux(ce ...

  2. Linux centos7 下 svn 服务器搭建

    摘自:https://www.cnblogs.com/mymelon/p/5483215.html 鉴于在搭建时,参考网上很多资料,网上资料在有用的同时,也坑了很多人 本文的目的,也就是想让后继之人在 ...

  3. Centos7下git服务器及gogs部署

    1.安装git # yum install -y git 2.创建git用户及组 # groupadd git # adduser git -g git # mkdir /home/git # mkd ...

  4. CentOS7下,防火墙设置

    CentOS中防火墙程序主要是firewall和iptables两种. CentOS7中firewall服务已经默认安装好了,而iptables服务需要自己用yum install  iptabes- ...

  5. centos7下SVN服务器搭建

    1,安装 yum install subversion 2,输入rpm -ql subversion查看安装位置 3,创建svn版本库目录 mkdir -p /var/svn/svnrepos 4,创 ...

  6. 浅谈Linux(Centos7.4)环境下NTP服务器的构建

     一.软件环境 1.操作系统版本 [root@Geeklp201 etc]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core ...

  7. centos7 搭建ntp时钟服务器

    服务器 : 192.168.137.3 客户机:  192.168.137.6 1. 服务器端 centos7下首先确认服务器的防火墙.selinux关闭状态 # cat /etc/redhat-re ...

  8. centos7搭建ntp时间同步服务器chrony服务

    centos7搭建ntp时间同步服务器chrony服务 前言: 在centos6的时候我们基本使用的是ntp服务用来做时间同步,但是在centos7后推荐是chrony作为时间同步器的服务端使用, ...

  9. centos6 & centos7搭建ntp服务器

    原理 NTP(Network TimeProtocol,网络时间协议)是用来使计算机时间同步的一种协议.它可以使计算机对其服务器或时钟源做同步化,它可以提供高精准度的时间校正(LAN上与标准间差小于1 ...

随机推荐

  1. js实现简单易用的上下无缝滚动效果

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  2. POJ 3660 Cow Contest

    题目链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

  3. UVa 12100打印队列(队列)

    原题链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  4. 基于Spring MVC的Web应用开发(三) - Resources

    基于Spring MVC的Web应用开发(3) - Resources 上一篇介绍了在基于Spring MVC的Web项目中加入日志,本文介绍Spring MVC如何处理资源文件. 注意到本项目的we ...

  5. Httptunnel教程

    hts --forward-port localhost:22 80 htc -F 6789 192.168.10.1:80

  6. spring源码学习之:spring容器的applicationContext启动过程

    Spring 容器像一台构造精妙的机器,我们通过配置文件向机器传达控制信息,机器就能够按照设定的模式进行工作.如果我们将Spring容器比喻为一辆汽车,可以将 BeanFactory看成汽车的发动机, ...

  7. ps图层混合模式

    溶解: ------------- 变暗:当使用该模式时,图像中的颜色或物体,总是其中颜色比较深的覆盖比较浅的,而数值相同或更深的像素不受影响.但记住,是上层针对下层,也就是说要有两个图层才有用 正片 ...

  8. JVM ,JIT ,GC RUNTIME 解析

    Java Class字节码知识点回顾 https://yq.aliyun.com/articles/2358?spm=5176.8067842.tagmain.105.fQdvH3 JVM Class ...

  9. MFC应用程序框架入门(转)

    1 MFC概述 顾名思意,MFC应用程序框架是以MFC作为框架基础的,以此程序框架模式搭建起来的应用程序在程序结构组织上是完全不同于以前的Win32 SDK编程方式的.自20世纪90年代初问世以来,M ...

  10. Linux-Nginx之sendfile与上下文切换

    今天在看nginx thread pool的时候,频繁的看到sendfile,其实以前也经常看到sendfile,只是我平时选择性的忽视而已... 先说下sendfile,明天在好好聊下nginx 线 ...