Linux同步时间服务器
来源:互联网 发布:三级分销数据统计表 编辑:程序博客网 时间:2024/05/19 20:43
在集群中同步时间,可以使用ntpd服务器
安装服务器:
1. 安装ntpd服务,可通过一下命令安装
yum install ntp -y
2. 修改配置如下:
# 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 nomodify
# 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 ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.56.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# 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
server 127.127.1.0
fudge 127.127.1.0 stratum 8
#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
# Disable the monitoring facility to prevent amplification attacks using ntpdc
# monlist command when default restrict does not include the noquery flag. See
# CVE-2013-5211 for more details.
# Note: Monitoring will not be disabled with the limited restriction flag.
disable monitor
systemctl start ntpd
yum install ntpdate -y
server 127.127.1.0
fudge 127.127.1.0 stratum 8
在ntp server上重新启动ntp服务后,ntp server自身或者与其server的同步的需要一个时间段,这个过程可能是5分钟,在这个时间之内在客户端运行ntpdate命令时会产生no server suitable for synchronization found的错误。
那么如何知道何时ntp server完成了和自身同步的过程呢?
在ntp server上使用命令:
# watch ntpq -p
注意LOCAL的这个就是与自身同步的ntp server。
注意reach这个值,在启动ntp server服务后,这个值就从0开始不断增加,当增加到17的时候,从0到17是5次的变更,每一次是poll的值的秒数,是64秒*5=320秒的时间。
如果之后从ntp客户端同步ntp server还失败的话,用ntpdate –d来查询详细错误信息,再做判断
错误2.Server dropped: no data
出现这个问题的原因可能有2:
1. 检查ntp的版本,如果你使用的是ntp4.2(包括4.2)之后的版本,在restrict的定义中使用了notrust的话,会导致以上错误。
使用以下命令检查ntp的版本:
# ntpq -c version
下面是来自ntp官方网站的说明:
The behavior of notrust changed between versions 4.1 and 4.2.
In 4.1 (and earlier) notrust meant "Don't trust this host/subnet for time".
In 4.2 (and later) notrust means "Ignore all NTP packets that are not cryptographically authenticated." This forces remote time servers to authenticate themselves to your (client) ntpd
解决:
把notrust去掉。
2. 检查ntp server的防火墙。可能是server的防火墙屏蔽了upd 123端口。
可以用命令
#service iptables stop
来关掉iptables服务后再尝试从ntp客户端的同步,如果成功,证明是防火墙的问题,需要更改iptables的设置。
- Linux服务器时间同步
- Linux服务器时间同步
- Linux服务器同步时间
- Linux服务器时间同步
- linux服务器同步时间
- Linux 服务器时间同步
- Linux服务器时间同步
- Linux服务器时间同步
- linux 服务器时间同步
- linux 服务器时间同步
- Linux 服务器时间同步
- Linux同步时间服务器
- Linux服务器时间同步
- Linux 服务器时间同步
- linux服务器时间同步
- Linux服务器时间同步
- LINUX服务器同步时间
- 让Linux服务器时间同步
- 给图像添加边界
- 自己的首个小系统
- 【LeetCode】 235. Lowest Common Ancestor of a Binary Search Tree
- poj3276 Face The Right Way 反转问题
- Android TextVeiw setText函数
- Linux同步时间服务器
- NumberUtils简单介绍和具体实例
- 【语言-批处理】批处理windows锁屏
- win10mysql(5.7.16)数据库删除和重新安装
- Oracle数据库的冷备恢复到另一台机器上.
- (转)SQLServer基础 单行注释与多行注释
- 谈谈码率,帧率,分辨率和清晰度的关系
- ①极好的PCA帖子&白化;②数据降维
- InnoDB数据库死锁