安装ntp

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

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

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


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

    1. systemctl enable ntpd
    1. 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. android内嵌入webview导致闪退

    这里碰到的是各种闪退情况之一,webview退出后,程序里立马需要申请内存空间做别的事情,这时内存不够就会闪退,做法就是延时个几百毫秒,在这段时间内让java把该回收的内存都回收,然后延时到了再做接下 ...

  2. PAT (Basic Level) Practise:1007. 素数对猜想

    [题目链接] 让我们定义 dn 为:dn = pn+1 - pn,其中 pi 是第i个素数.显然有 d1=1 且对于n>1有 dn 是偶数.“素数对猜想”认为“存在无穷多对相邻且差为2的素数”. ...

  3. 能不能对metronic继续封装一下呢

    按照这篇文章的说法,目前metronic的层级还是较低的,只是针对Bootstrap做了很多的用例(最佳实践). 我上一个项目是用easy UI,准确地说,是经过简单封装的easy UI.用起来非常爽 ...

  4. boot/head.S

    /* * linux/boot/head.S * * Copyright (C) 1991, 1992 Linus Torvalds */ /* * head.S contains the 32-bi ...

  5. timus 1136 Parliament(二叉树)

    Parliament Time limit: 1.0 secondMemory limit: 64 MB A new parliament is elected in the state of MMM ...

  6. Android——进度对话框

    java类代码: //普通进度对话框 public void bt8_onClick(View v) { final ProgressDialog progressDialog = new Progr ...

  7. ssh命令:使用密钥文件进行登陆

    在win上面可以使用XSHELL来登录类似于亚马逊这样的安全服务器,在mac上面就可以使用系统自带的命令工具来连接 1.使用命令 ssh -i key.pem [server] 如下: ssh -i  ...

  8. ChannelOption.TCP_NODELAY, true->浅谈tcp_nodelay的作用

    在TCP/IP协议中,无论发送多少数据,总是要在数据前面加上协议头,同时,对方接收到数据,也需要发送ACK表示确认.为了尽可能的利用网络带宽,TCP总是希望尽可能的发送足够大的数据.这里就涉及到一个名 ...

  9. HttpWebRequest's Timeout and ReadWriteTimeout — What do these mean for the underlying TCP connection?

    http://stackoverflow.com/questions/7250983/httpwebrequests-timeout-and-readwritetimeout-what-do-thes ...

  10. ExpressRoute

    Extending Your Network to Microsoft Azure Using ExpressRoute https://channel9.msdn.com/events/TechEd ...