找回密码
 注册
查看: 4991|回复: 4

linux 时间同步ntp和chrony服务搭建配置

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2016-8-22 15:36:56 | 显示全部楼层 |阅读模式
购买主题 本主题需向作者支付 3 金钱 才能浏览

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2017-2-16 15:55:14 | 显示全部楼层
查看时间同步源的信息。$ z8 K5 \$ C/ J: v8 A7 R9 J& n
# chronyc sourcestats -v
; G9 J& I" N+ t, |4 t6 O. C( y210 Number of sources = 1( K; @+ i2 a: l0 E9 C7 E3 a
                             .- Number of sample points in measurement set.7 [, s( _8 Y" i! p# \9 i6 h/ @/ K
                            /    .- Number of residual runs with same sign.! h/ `! W$ o& D( X) i! w7 j9 `
                           |    /    .- Length of measurement set (time).
7 {$ \( Q, H5 q  G                           |   |    /      .- Est. clock freq error (ppm).
+ h7 d5 Y6 V. s! e0 C                           |   |   |      /           .- Est. error in freq.
9 e- F5 K( R; U6 n1 n: e1 ^                           |   |   |     |           /         .- Est. offset.7 ^3 ~' N# k( M$ X# V, i, F
                           |   |   |     |          |          |   On the -.
8 t; p6 @: o& |# }' e/ V5 O                           |   |   |     |          |          |   samples. \
9 R+ D# e! H' B; p                           |   |   |     |          |          |             |% Q- |( Q  b# ?- v  X, n
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev$ a4 e6 X# W2 ]
==============================================================================6 Z" A" t0 P/ R
promote.cache-dns.local     0   0     0     +0.000   2000.000     +0ns  4000ms

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2017-2-16 15:56:30 | 显示全部楼层
[root@361way ~]# chronyc& Z- N# p- y% m. D: P% e4 W
chrony version 1.29.16 t! s* }* X- e& A) Y
Copyright (C) 1997-2003, 2007, 2009-2013 Richard P. Curnow and others" E8 \  T7 H0 \  [
chrony comes with ABSOLUTELY NO WARRANTY.  This is free software, and
# t$ K9 N+ B. ~! z# Xyou are welcome to redistribute it under certain conditions.  See the
/ \3 J* v" ?: N. F, i0 f5 HGNU General Public License version 2 for details.
9 I- Y2 M6 B8 m, P, {5 p2 |% lchronyc> activity
( y. |8 E% K  F: _; M2 k* P" V' M200 OK
1 W* p; N) H, |3 sources online' t6 N/ _) }" o3 _: A- f
0 sources offline3 J; D. N/ [7 [) r
0 sources doing burst (return to online)' c  @  {  C9 {5 b% E9 d5 }5 Y$ d
0 sources doing burst (return to offline)/ Q3 Q5 f/ H: c6 Q
0 sources with unknown address7 I( W* [  v6 p8 ^0 D6 C4 @
chronyc> help
- e1 w* P7 V5 K' J7 _! X4 BCommands:! w) l' p/ h1 W( Q& L# a% J& T
accheck <address> : Check whether NTP access is allowed to <address>
, s7 g: [" r( Z. }activity : Check how many NTP sources are online/offline% f# n$ M: P& i6 |# j) [, a
add peer <address> ... : Add a new NTP peer' G* \8 d1 t; ?3 n! h
add server <address> ... : Add a new NTP server3 K9 P' L. L0 M. j6 R# K; e/ k. ?+ @
allow [<subnet-addr>] : Allow NTP access to that subnet as a default6 H! ], w- A( h: k9 X
allow all [<subnet-addr>] : Allow NTP access to that subnet and all children
! e1 @9 h) G- W$ Lburst <n-good>/<n-max> [<mask>/<masked-address>] : Start a rapid set of measurements) |! P9 S3 ^+ j# H) y5 @
clients : Report on clients that have accessed the server1 Y, v& t, t8 F. O: O
cmdaccheck <address> : Check whether command access is allowed to <address>, B% Y  F4 t+ t; A* @3 _
cmdallow [<subnet-addr>] : Allow command access to that subnet as a default
, S6 t+ R( T4 y8 s4 P2 bcmdallow all [<subnet-addr>] : Allow command access to that subnet and all children
* ~% p9 K+ S  l2 `5 x/ ?: D0 Ncmddeny [<subnet-addr>] : Deny command access to that subnet as a default0 ]; w( Z/ ?5 f9 R8 `
……………………省略

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2017-2-28 20:25:21 | 显示全部楼层
配置NTP server 服务器 #yum install -y ntp # o5 T5 I1 R( M. f7 D0 h% G
●        编辑ntp 配置  vim /etc/ntp.conf
7 p4 \8 V% S4 z# m. E9 _! w3 odriftfile /var/lib/ntp/drift
. ]# g5 O0 n  y# \& Q( j' orestrict default nomodify notrap nopeer noquery$ s9 j% {9 Q/ Z4 s
restrict 127.0.0.1 6 X& {: N+ T. D# e
restrict ::1! R7 i3 z$ Y  o5 I  w/ w8 d, ^0 }
server 127.127.1.0                                2 T, z) i$ e5 Y$ Q
fudge 127.127.1.0 stratum 0                   ; A) U0 d' K) n. L( `
includefile /etc/ntp/crypto/pw
4 G1 H# x' L2 X7 R; J7 X- okeys /etc/ntp/keys$ X" K: z& ^" H! x6 ?2 C
disable monitor
3 c& N) F" K5 s$ _( c( U●        编辑ntp 服务器的配置
" W) r0 K  r3 I$ ^; K3 S# vim  /etc/sysconfig/iptables % F6 x2 a& R' x) A; @

8 s  m1 u9 M/ v6 }3 X( X* s* k: Q  -A INPUT -p udp --dport 123 -j ACCEPT
3 f; b, d7 K" S0 [. @
' A. E7 C/ [8 ]2 V# systemctl restart iptables% S  |: y: h( D- t- R2 [0 i; \: x$ G2 h
# systemctl restart iptables.service
. T8 o! Z. G4 Y% l, b8 B●        将系统时间写入硬件4 s6 k* @7 W2 \1 i, J8 E0 H) D8 d
  # hwclock --systohc
8 E5 ~% h3 ]0 g●        重新启动NTP服务
. I1 V0 I- A' Z3 n    # service ntpd restart
7 y+ `: Q& N& z3 l3 y0 z% |4 x8 X7 x/ d! V7 e( D. s7 o% R& Y/ D- n

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2018-9-28 19:45:01 | 显示全部楼层
设定NTP主机来源(其中prefer表示优先主机),192.168.7.49是本地的NTP服务器,所以优先指定从该主机同步时间。& X7 J: |& E' b$ J
# H8 j# G6 w' s5 G+ }: b
server 192.168.7.49 prefer
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 04:24 , Processed in 0.016367 second(s), 26 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表