Linux时间同步
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Linux时间同步,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2906字,纯文字阅读大概需要5分钟。
内容图文
![Linux时间同步](/upload/InfoBanner/zyjiaocheng/1075/e5e6d8fac74d4819a5c8685f7ac25deb.jpg)
时间修改
1.将HKT时区修改为CST时区
cd /etc
mv localtime localtime.bak
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
date
2.修改时间
date -s "2019-03-19 12:00:00"
centos6.5配置NTP时间同步
1.修改/etc/ntp.conf配置文件
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6::1
# Hosts on local network are less restricted.
# restrict 192.168.1.0 mask 255.255.255.0 nomodify notra
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 目标同步NTP服务器(或自身)
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client
# Enable public key cryptography.
#crypto
includefile /etc/ntp/crypto/pw
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# Specify the key identifiers which are trusted.
#trustedkey 4 8 42
# Specify the key identifier to use with the ntpdc utility.
#requestkey 8
# Specify the key identifier to use with the ntpq utility.
#controlkey 8
# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats
2.启动ntp服务器
service ntpd start
3.开放防火墙端口udp123
-I INPUT -p udp --dport 123 -j ACCEPT
4.客户端同步
ntpdate 服务器IP && hwclock -w
5.客户端同步时间显示详情
ntpdate -d 服务器IP
问题
no server suitable for synchronization found
错误
1.Server dropped:Strata too high
肯能定义的Server不可用
2.Server dropped:nodata
防火墙是否开放udp123端口,关闭防火墙尝试能否同步
查询ntp版本命令:
ntpq -c version
centos7配置NTP时间同步
1.修改/etc/ntp.conf
2.启动ntp服务
systemctl start ntpd.service
3.开启防火墙端口
firewall-cmd --zone=public --add-port=123/udp --permanent
firewall-cmd --reload
firewall-cmd --list-port
4.其它服务器同步时间
ntpdate 服务器IP
成功则显示
21 Mar 16:21:06 ntpdate[16681]: step time server 服务器IP offset -50.608671 sec
若显示以下问题查看当前服务器是否开启ntp服务,开启ntp需要关闭
21 Mar 16:18:05 ntpdate[16125]: the NTP socket is in use, exiting
若显示以下问题查看当前服务器是否开启udp123端口,若无需要开启
21 Mar 16:18:23 ntpdate[16264]: no server suitable for synchronization found
5.配置crond定时同步
原文:https://www.cnblogs.com/code-red-memory/p/10623815.html
内容总结
以上是互联网集市为您收集整理的Linux时间同步全部内容,希望文章能够帮你解决Linux时间同步所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。