安装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     #手动同步

最新文章

  1. C#--图片上传(PC端和APP)保存及 跨域上传说明
  2. php-fpm重启关闭等操作
  3. c#数据绑定(5)--LINQ
  4. CLR via C# 3rd - 02 - Building, Packaging, Deploying, and Administering Applications and Types
  5. Auto Layout
  6. iOS视图控制器的生命周期
  7. MongoDB学习笔记-查询
  8. a标签根据js返回值判断页面是否跳转
  9. liunx下search文件内容的几种方式
  10. Linux环境下Hadoop集群搭建
  11. 学习小片段——thymeleaf入门
  12. gogs 安装
  13. 基于 HTML5 的工业互联网 3D 可视化应用
  14. 小程序canvas生成海报保存至手机相册
  15. (C/C++学习笔记) 十七. 面向对象程序设计
  16. 【jmeter】jmeter之-断言和检查点
  17. sqoop1 使用测试
  18. 【noip模拟】D(==)
  19. 为django平台生成模拟用户,建立用户组,并将用户加入组
  20. tcpdump-根据IP查看程序与服务都用了哪些端口

热门文章

  1. 基于tcpdump实例讲解TCP/IP协议
  2. Core Java Volume I — 5.1. Classes, Superclasses, and Subclasses
  3. (实用篇)PHP ftp上传文件操作类
  4. keynotes egestas,PPT 渐变背景下载-imsoft.cnblogs
  5. 设置mysql远程连接root权限
  6. codeforce The Art of Dealing with ATM
  7. xmind的第四天笔记
  8. Codeforces Round #372 (Div. 2) A B C 水 暴力/模拟 构造
  9. AspxGridView
  10. java的加减乘除