Linux上安装NTP SERVER实现时间校正

当Linux服务器的时间不对的时候,可以使用ntpdate工具来校正时间。

服务端安装

安装NTP:
yum install ntp

配置时间源
vi /etc/ntp.conf
server 210.72.145.44
server ntp.api.bz
server 2.centos.pool.ntp.org

配置时间自动同步

echo '*/30 * * * * /usr/sbin/ntpdate time7.aliyun.com >/dev/null 2>&1' > /tmp/crontab2.tmp

crontab /tmp/crontab2.tmp

配置客户端

配置对客户端(172.16.0.0/24的网段机器)提供NTP服务
# vi /etc/ntp.conf
restrict 172.16.0。0 mask 255.255.255.0 nomodify notrap
配置NTP Server的层数提供本地服务
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 2

设置开机时自动运行时间服务
systemctl enable ntpd

启动或停止时间服务
# systemctl start ntpd
# systemctl stop ntpd
# systemctl restart ntpd

验证ntp服务已经运行
pgrep ntpd

更新本服务器的时间
ntpdate -u 210.72.145.44

配置iptable规则允许客户端访问本机NTP Sever
vi /etc/sysconfig/iptables
增加一行(NTP Server使用UDP 123端口)
-A INPUT -m state --state NEW -m udp -p udp --dport 123 -j ACCEPT
重启iptables
service iptables restart

以下是一些可用的NTP服务器地址:

Name

IPLocation
210.72.145.44210.72.145.44中国(国家授时中心)
133.100.11.8133.100.11.8日本(福冈大学)
time-a.nist.gov129.6.15.28NIST,Gaithersburg,Maryland
time-b.nist.gov129.6.15.29NIST,Gaithersburg,Maryland
time-a.timefreq.bldrdoc.gov132.163.4.101NIST,Boulder,Colorado
time-b.timefreq.bldrdoc.gov132.163.4.102NIST,Boulder,Colorado
time-c.timefreq.bldrdoc.gov132.163.4.103NIST,Boulder,Colorado
utcnist.colorado.edu128.138.140.44UniversityofColorado,Boulder
time.nist.gov192.43.244.18NCAR,Boulder,Colorado
time-nw.nist.gov131.107.1.10Microsoft,Redmond,Washington
nist1.symmetricom.com69.25.96.13Symmetricom,SanJose,California
nist1-dc.glassey.com216.200.93.8Abovenet,Virginia
nist1-ny.glassey.com208.184.49.9Abovenet,NewYorkCity
nist1-sj.glassey.com207.126.98.204Abovenet,SanJose,California
nist1.aol-ca.truetime.com207.200.81.113TrueTime,AOLfacility,Sunnyvale,California
nist1.aol-va.truetime.com64.236.96.53TrueTime,AOLfacility,Virginia
ntp.sjtu.edu.cn 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 北京大学
  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

菲宇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值