安装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. JSONP解决ajax跨域问题

    在A域名下,用ajax请求B域名下的请求,会报类似这样的错误:No 'Access-Control-Allow-Origin' header is present on the requested r ...

  2. 十五个最常用Linux命令行 - imsoft.cnblogs

    众多Linux管理员在使用Linux的时候会经常使用到很多Linux命令行,其中有绝大部分不是经常使用到的.在本文中主要为大家总结了经常使用的十五个最常用Linux命令行,希望对刚刚接触Linux命令 ...

  3. android listview去掉分割线

    1:android listview去掉分割线 1>设置android:divider="@null" 2>android:divider="#0000000 ...

  4. 转:db2 iptables相关用法(2)

    Centos 6 iptables 配置 Ben 2011/12/24 [root@localhost ben.liu]# service iptables status Table: filter ...

  5. 批量kill相关所有进程

    首先,用ps查看进程,方法如下: $ ps -ef …… smx       1822     1  0 11:38 ?        00:00:49 gnome-terminal smx      ...

  6. 【转】非常适用的Sourceinsight插件,提高效率事半功倍

    原文网址:http://www.cnblogs.com/wangqiguo/p/3713211.html 一直使用sourceinsight编辑C/C++代码,sourceinsight是一个非常好用 ...

  7. Measuring the amount of writes in InnoDB redo logs

    Choosing a good InnoDB log file size is key to InnoDB write performance. This can be done by measuri ...

  8. 如何给EDIUS添加区域性马赛克

    我们平时观看视频时会经常看到画面上的一部分信息被用马赛克来遮盖,那在使用EDIUS制作编辑视频时,这一效果要如何做到呢?下面,小编就来给大家讲讲如何给EDIUS区域添加马赛克吧. 1.首先在特效面板中 ...

  9. API、ABI区别

    http://blog.csdn.net/xinghun_4/article/details/7905298 应用程序二进制接口(ABI-Application Binary Interface)定义 ...

  10. wikioi 1973 Fibonacci数列【输出第N项的值】

    /*===================================== 1978 Fibonacci数列 3 题目描述 Description 斐波纳契数列是这样的数列: f1 = 1 f2 ...