ntp服务器同步时间详细配置
部署NTP服务器进行时间同步
NTP服务概述
1、原理
2、端口(123)
1 [root@linl_S ~]# vim /etc/services 2 nntp 119/tcp readnews untp # USENET News Transfer Protocol 3 nntp 119/udp readnews untp # USENET News Transfer Protocol 4 ntp 123/tcp 5 ntp 123/udp # Network Time Protocol
1 [root@linl_S ~]# ls /mnt/Packages/ntp* 2 /mnt/Packages/ntp-4.2.6p5-1.el6.x86_64.rpm #NTP服务端软件包 3 /mnt/Packages/ntpdate-4.2.6p5-1.el6.x86_64.rpm #NTP客户端软件包
1 [root@linl_S ~]# yum -y install ntp #NTP两个软件包都会安装上 2 ... 3 Installed: 4 ntp.x86_64 0:4.2.6p5-1.el6 5 Dependency Installed: 6 ntpdate.x86_64 0:4.2.6p5-1.el6 7 Complete!
1 [root@linl_C ~]# rpm -ivh /mnt/Packages/ntpdate-4.2.6p5-1.el6.x86_64.rpm #只安装ntpdate安装包 2 warning: /mnt/Packages/ntpdate-4.2.6p5-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY 3 Preparing... ########################################### [100%] 4 package ntpdate-4.2.6p5-1.el6.x86_64 is already installed
1 [root@linl_S ~]# ls /etc/ntp.conf 2 /etc/ntp.conf
1 [root@linl_S ~]# service ntpd start #启动ntp服务2 Starting ntpd: [ OK ]3 [root@linl_S ~]# netstat -anptu |grep 123 #查看端口123是否开放4 udp 0 0 10.0.0.15:123 0.0.0.0:* 5846/ntpd 5 udp 0 0 127.0.0.1:123 0.0.0.0:* 5846/ntpd 6 udp 0 0 0.0.0.0:123 0.0.0.0:* 5846/ntpd 7 udp 0 0 fe80::20c:29ff:fea9:c1ae:123 :::* 5846/ntpd 8 udp 0 0 ::1:123 :::* 5846/ntpd 9 udp 0 0 :::123 :::* 5846/ntpd 10 [root@linl_S ~]# chkconfig ntpd on #开机自启动
实战1:手动同步NTP时间服务器
1 [root@linl_S ~]# vi /etc/ntp.conf 2 # Use public servers from the pool.ntp.org project. 3 # Please consider joining the pool (http://www.pool.ntp.org/join.html). 4 server 0.rhel.pool.ntp.org iburst #找一个可以使用的NTP时间服务器 5 server 1.rhel.pool.ntp.org iburst 6 server 2.rhel.pool.ntp.org iburst 7 server 3.rhel.pool.ntp.org iburst
1 [root@linl_C ~]# ntpdate 0.rhel.pool.ntp.org 2 22 May 22:04:41 ntpdate[5733]: adjust time server 202.118.1.130 offset 0.027428 sec
1 [root@linl_S ~]# ntpdate 0.rhel.pool.ntp.org 2 22 May 22:06:17 ntpdate[2464]: the NTP socket is in use, exiting
1 [root@linl_S ~]# service ntpd stop 2 Shutting down ntpd: [ OK ] 3 [root@linl_S ~]# ntpdate 0.rhel.pool.ntp.org 4 22 May 22:13:27 ntpdate[2495]: adjust time server 202.118.1.130 offset -0.068183 sec
实战2:搭建内网NTP服务器,内网服务器通过此NTP服务器进行时间同步
1 [root@linl_S ~]# vi /etc/ntp.conf 2 # Permit all access over the loopback interface. This could3 # be tightened as well, but to do so would effect some of4 # the administrative functions.5 restrict 127.0.0.16 restrict -6 ::17 restrict 10.0.0.0 mask 255.255.255.0 #允许10.0.0.0 网段中的服务器访问本ntp服务器进行时间同步8 restrict 10.0.0.16 #允许单个IP地址访问本ntp服务器9 # Use public servers from the pool.ntp.org project. 10 # Please consider joining the pool (http://www.pool.ntp.org/join.html). 11 server 210.72.145.44 #指定本ntp服务器的上游ntp服务器为210.72.145.44,并且设置为首先服务器。同步时间为:从上到下,写的越靠上,优先级越高。(此服务器同步不了时间,寻找下一个ntp服务器)。此IP地址是中国国家授时中心ntp服务器。 12 server 133.100.11.8 #当上面服务器同步不了,则寻找第二个。此IP地址是日本福冈大学ntp服务器。 13 server 0.rhel.pool.ntp.org iburst 14 server 1.rhel.pool.ntp.org iburst 15 server 2.rhel.pool.ntp.org iburst 16 server 3.rhel.pool.ntp.org iburst 17 server 127.127.1.0 #local clock 如果上面的服务器都无法同步时间,就和本地系统时间同步。127.127.1.0在这里是一个IP地址,不是网段。 18 fudge 127.127.1.0 stratum 10 #127.127.1.0 为第10层。ntp 和127.127.1.0同步完后,就变成了11层。 ntp是层次阶级的。同步上层服务器的stratum 大小不能超过或等于16。
1 [root@linl_S ~]# /etc/init.d/ntpd start 2 Starting ntpd: [ OK ] 3 [root@linl_S ~]# netstat -ln |grep 123 4 udp 0 0 10.0.0.15:123 0.0.0.0:* 5 udp 0 0 127.0.0.1:123 0.0.0.0:* 6 udp 0 0 0.0.0.0:123 0.0.0.0:* 7 udp 0 0 fe80::20c:29ff:fea9:c1ae:123 :::* 8 udp 0 0 ::1:123 :::* 9 udp 0 0 :::123 :::*
1 [root@linl_S ~]# ntpq -p #列出本NTP服务器与上游服务器的连接状态2 remote refid st t when poll reach delay offset jitter3 ==============================================================================4 210.72.145.44 .INIT. 16 u - 64 0 0.000 0.000 0.0005 133.100.11.8 .INIT. 16 u - 64 0 0.000 0.000 0.0006 *dns1.synet.edu. 202.118.1.47 2 u 32 64 3 60.058 7.261 6.8607 news.neu.edu.cn .INIT. 16 u - 64 0 0.000 0.000 0.0008 202.118.1.130 .INIT. 16 u - 64 0 0.000 0.000 0.0009 42.96.167.209 .INIT. 16 u - 64 0 0.000 0.000 0.000 10 LOCAL(0) .LOCL. 10 l 96 64 2 0.000 0.000 0.000 11 [root@linl_S ~]# ntpstat #列出是否与上游服务器连接。需要过5分钟 12 synchronised to NTP server (202.112.29.82) at stratum 3 #可以看到我们当前在3层 13 time correct to within 257 ms #ms 毫秒是一种较为微小的时间单位,是一秒的千分之一。 14 polling server every 64 s
1 [root@linl_C ~]# date -s "2015-5-23 11:30" #先设置一个错误的时间点 2 Sat May 23 11:30:00 CST 2015 3 [root@linl_C ~]# ntpdate lin_S #进行ntp时间同步 4 23 May 11:34:10 ntpdate[6686]: step time server 10.0.0.15 offset 31622622.275270 sec 5 [root@linl_C ~]# date 6 Mon May 23 11:34:16 CST 2016 #时间同步成功
1 [root@linl_C ~]# ntpdate lin_S 2 23 May 11:38:02 ntpdate[6694]: no server suitable for synchronization found
1 [root@linl_S ~]# cat /etc/sysconfig/clock 2 # The time zone of the system is defined by the contents of /etc/localtime. 3 # This file is only for evaluation by system-config-date, do not rely on its 4 # contents elsewhere. 5 ZONE="Asia/Shanghai"
1 [root@linl_C ~]# date -s "2016-5-22 13:50" 2 Sun May 22 13:50:00 CST 2016 3 [root@linl_C ~]# hwclock -r 4 Mon 23 May 2016 01:53:50 PM CST -0.110948 seconds 5 [root@linl_C ~]# hwclock -w 6 [root@linl_C ~]# hwclock -r 7 Sun 22 May 2016 01:50:48 PM CST -0.783098 seconds #已将系统date时间写入到BIOS时间
1 [root@linl_C ~]# ntpdate lin_S 2 23 May 19:50:44 ntpdate[7507]: step time server 10.0.0.15 offset 1.239826 sec
1 [root@linl_C ~]# crontab -e 2 0 12 * * * /usr/sbin/ntpdate lin_S
转载于:https://www.cnblogs.com/shanhua-fu/p/9281040.html
ntp服务器同步时间详细配置相关推荐
- win7系统ntp时间服务器,win7与内部ntp服务器同步时间出来错误【NTP时间同步服务器】...
试试编辑略,运行"gpedit.msc",依次展开"计算机"-"管理模版"-"系-"Windows 时间服务" ...
- Linux强制与NTP服务器同步时间
Redhat 7: 先停止ntp服务,然后强制与NTP服务器的时间同步,完成后再启动ntp服务. # systemctl stop ntpd # ntpdate ntp-server-ip (如果想不 ...
- Centos7部署ntp服务器同步时间以及直接将本地时间同步为北京时间
一.查看配置 查看时区列表: timedatectl list-timezones|grep Asia 查看当前时间: date 查看当前设置: [root@localhost ~]# timedat ...
- ubuntu时间自动同步服务器,Ubuntu从NTP服务器同步时间
曾经的曾经,那台Ubuntu服务器的时间老是越走越快.我只看过一点点Ubuntu的书,于是问了一下I大,他给了个链接给我,太长了就懒得看.以下翻译自Ubuntu官方文档. 本页描述的是让你的电脑时间保 ...
- 运维小知识之企业内部NTP服务器基础安装与配置使用
0x00 前言简述 基础概念 服务方式 公共 NTP 服务器 0x01 服务器安装配置 CentOS Ubuntu (1) NTP 服务 (2) Chrony 服务 0x02 NTP客户端配置 Win ...
- 运维实战之企业内部NTP服务器基础安装与配置使用
关注「WeiyiGeek」公众号 将我设为「特别关注」,每天带你玩转网络安全运维.应用开发.物联网IOT学习! 文章目录 0x00 前言简述 基础概念 服务方式 公共 NTP 服务器 0x01 服 ...
- centos6如何安装和使用ntp来同步时间
在Centos6中,可以通过以下步骤安装和使用NTP来同步时间: 安装NTP包 在终端中输入以下命令: sudo yum install ntp 配置NTP服务器 打开NTP配置文件ntp.conf: ...
- 利用ntp服务同步时间(史上最简单)
说明(文末附XShell下载地址): 本文仅适用于测试环境下,解决集群时间同步问题. 生产环境ntp服务配置一般不能连外网,需要自行指定一台服务器作为ntp服务器,此服务器可以通过手动设置时间并写入c ...
- 使用NTP服务同步时间
一.实验环境 服务器类型 操作系统 IP地址 服务端 centos7.4 192.168.162.148 客户端1 redhat8.0 192.168.162.150 客户端2 redhat6.4 1 ...
最新文章
- 计算机设计思想 —— 代理(proxy)
- 谷歌升级Android分析应用程序
- Python这几个内置函数简直是屌爆了!!!
- Vue实现仿音乐播放器9-更多按钮实现数据匹配
- Java中几种输出数组的for循环,以及循环中使用标签(非goto)
- 惠普战66怎么用u盘进入系统_惠普笔记本怎么用u盘启动装系统,空间也要大所以超来超受欢迎!...
- checkStyle -- 代码风格一致
- Java 多线程 —— 常用并发容器
- hadoop原来是这样的!
- java进行图片和字符串的互相转换
- Funcode学习笔记:写一个维护性高、扩展性强的框架【By Myself】【C++】
- 传说中的世界500强面试题-推理能力(2)
- flash CS6 导入音频不成功的问题
- 自定义windows快捷键(autohotkey)的办法
- 彻底解决chrome等浏览器被劫持(篡改主页hao123等)问题
- 一级计算机基础不小心关掉了怎么重新打开,电脑不小心覆盖了文件该如何恢复-电脑自学网...
- 全键盘 掌上 linux,拥有QWERTY打字体验手机秒变掌上电脑 OPPO全键盘保护壳专利曝光...
- 全国天气预报信息 API 接口
- 全国降雨量数据、气温数据、风速数据
- 蒙特卡洛方法到底有什么用(转)
热门文章
- 第18课 闰年与平年 《小学生C++趣味编程》
- 第3课 天安门广场 《小学生C++趣味编程》--C++、Scratch
- thinkphp实现当前页面点击下载文件实例
- sql配置管理器服务是空的_PostgreSQL 12 安装和配置
- SQLyog笔记-CURRENT_TIMESTAMP在SQLyog的配置
- 【编译原理】:NFA转变为DFA的子集构造法
- jsp 导入java类_JSP页面导入问题。类文件放在WEB-INF / classes中的包中
- mysql 建表语句 stored as_Druid 解析Hive建表语句解析报错
- oracle取消备份存放本地,Oracle自动备份,压缩打包,删除原文件
- react中嵌入网页_在网站中添加 React