NTP时间同步总结

目录

1. 概述

Linux服务需要时间戳的时候,时间同步就显得十分重要。

Centos系统时间同步的命令为:ntpdate

2. 安装ntpdate

[root@myhost ~]# yum install ntpdate -y

3. NTP时间服务器地址

210.72.145.44 (国家授时中心服务器IP地址) 
133.100.11.8 日本 福冈大学 
time-a.nist.gov 129.6.15.28 NIST, Gaithersburg, Maryland 
time-b.nist.gov 129.6.15.29 NIST, Gaithersburg, Maryland 
time-a.timefreq.bldrdoc.gov 132.163.4.101 NIST, Boulder, Colorado 
time-b.timefreq.bldrdoc.gov 132.163.4.102 NIST, Boulder, Colorado 
time-c.timefreq.bldrdoc.gov 132.163.4.103 NIST, Boulder, Colorado 
utcnist.colorado.edu 128.138.140.44 University of Colorado, Boulder 
time.nist.gov 192.43.244.18 NCAR, Boulder, Colorado 
time-nw.nist.gov 131.107.1.10 Microsoft, Redmond, Washington 
nist1.symmetricom.com 69.25.96.13 Symmetricom, San Jose, California 
nist1-dc.glassey.com 216.200.93.8 Abovenet, Virginia 
nist1-ny.glassey.com 208.184.49.9 Abovenet, New York City 
nist1-sj.glassey.com 207.126.98.204 Abovenet, San Jose, California 
nist1.aol-ca.truetime.com 207.200.81.113 TrueTime, AOL facility, Sunnyvale, California 
nist1.aol-va.truetime.com 64.236.96.53 TrueTime, AOL facility, Virginia 
———————————————————————————————————— 
ntp.sjtu.edu.cn (上海交通大学网络中心NTP服务器地址202.120.2.101) 
s1a.time.edu.cn 北京邮电大学 
s1b.time.edu.cn 清华大学 
s1c.time.edu.cn 北京大学 
s1d.time.edu.cn 东南大学 
s1e.time.edu.cn 清华大学 
s2a.time.edu.cn 清华大学 
s2b.time.edu.cn 清华大学 
s2c.time.edu.cn 北京邮电大学 
s2d.time.edu.cn 西南地区网络中心 
s2e.time.edu.cn 西北地区网络中心 
s2f.time.edu.cn 东北地区网络中心 
s2g.time.edu.cn 华东南地区网络中心 
s2h.time.edu.cn 四川大学网络管理中心 
s2j.time.edu.cn 大连理工大学网络中心 
s2k.time.edu.cn CERNET桂林主节点 
s2m.time.edu.cn 北京大学

比较稳定的国内NTP时间服务器地址:

ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com

4. 时间同步命令的语法

[root@myhost ~]# which ntpdate 
/usr/sbin/ntpdate
[root@myhost ~]# /usr/sbin/ntpdate ntp1.aliyun.com

5. 用for循环进行时间同步

for n in {1..7};
	do 
		/usr/sbin/ntpdate ntp$n.aliyun.com;
		sleep 1; 
	done

6. 配置时间同步定时任务

企业中配置时间同步任务实践如下,尽量配置两个或两个以上时间同步服务器地址,防止某一个出问题:

[root@myhost~]#cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed
*/5 * * * * root /usr/sbin/ntpdate pool.ntp.org

或者

[root@myhost~]# crontab -l
*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com & > /dev/null
*/5 * * * * /usr/sbin/ntpdate ntp2.aliyun.com & > /dev/null
*/5 * * * * /usr/sbin/ntpdate ntp3.aliyun.com & > /dev/null
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值