易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 4986|回复: 4
收起左侧

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

[复制链接]
发表于 2016-8-22 15:36:56 | 显示全部楼层 |阅读模式
购买主题 本主题需向作者支付 3 金钱 才能浏览
 楼主| 发表于 2017-2-16 15:55:14 | 显示全部楼层
查看时间同步源的信息。
# i/ R& I! _( @1 q# chronyc sourcestats -v+ h1 ^- E- u! Z) O1 v5 @4 T2 Y
210 Number of sources = 1
! w. g8 K9 Y4 I+ q& Y                             .- Number of sample points in measurement set.
4 W& V  U. \( E3 v+ ], T                            /    .- Number of residual runs with same sign.9 ^/ Z7 @2 {% k/ O) r% y
                           |    /    .- Length of measurement set (time).3 s* v6 i* \$ m% @
                           |   |    /      .- Est. clock freq error (ppm).
/ i% p' `% g8 S- S/ n8 {* ?                           |   |   |      /           .- Est. error in freq.
* J6 H1 O* b3 y! F$ z" w                           |   |   |     |           /         .- Est. offset.' f/ @6 ^! v* S3 I0 B' T
                           |   |   |     |          |          |   On the -., t$ j! g) B. t* y( \
                           |   |   |     |          |          |   samples. \
2 Z+ p( @0 Z5 ?% n* B8 V0 A                           |   |   |     |          |          |             |, t0 l) y- {: O8 k* y; @+ n. H
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
: Y1 H" v$ T! P- J- l4 v, l/ }==============================================================================/ a, h) E6 I8 e& `& y3 U
promote.cache-dns.local     0   0     0     +0.000   2000.000     +0ns  4000ms
 楼主| 发表于 2017-2-16 15:56:30 | 显示全部楼层
[root@361way ~]# chronyc
1 C# z* q" a( E2 T* L) C3 }' _chrony version 1.29.1
1 i( o" b/ g8 M! }9 i2 nCopyright (C) 1997-2003, 2007, 2009-2013 Richard P. Curnow and others
; j* u6 n- K( r/ p' D% D! E  ?chrony comes with ABSOLUTELY NO WARRANTY.  This is free software, and
2 V9 R2 A2 ~0 ?* g4 xyou are welcome to redistribute it under certain conditions.  See the4 k, R$ Z8 L; O( x! t
GNU General Public License version 2 for details.2 J8 ]6 G, u* n/ L2 P0 d
chronyc> activity
* e4 {2 k$ E% n3 v/ Q) K. @  C200 OK
" @6 F$ d8 k) K$ D1 C3 sources online2 V& J* V, t$ d- q  o! d/ i
0 sources offline
5 B" B( w# F4 ?) p" r: F# z; O) K7 O. o0 sources doing burst (return to online)
  C# G0 k7 Z7 J7 @0 sources doing burst (return to offline)" G# d& f' d& K4 h, ~3 C8 d- W
0 sources with unknown address* d- S, }8 G# g& x' L: O; V3 L+ |) [
chronyc> help
7 R& ~: I, H( E# U# \Commands:: ^) X5 r% j. }( k5 l, ?; T+ L
accheck <address> : Check whether NTP access is allowed to <address># P7 S& F% z( c; J& ?0 R0 Y3 a6 j
activity : Check how many NTP sources are online/offline
8 G! w" j+ r+ |. o: P( uadd peer <address> ... : Add a new NTP peer
5 v0 p  ]- i5 ?& B! `6 W* oadd server <address> ... : Add a new NTP server. P- l0 j/ p2 }! ?# j8 q0 P/ K
allow [<subnet-addr>] : Allow NTP access to that subnet as a default
, N. _6 v( M, P" P$ R3 u+ ^+ B1 @/ \allow all [<subnet-addr>] : Allow NTP access to that subnet and all children! G$ b- o/ S, E  Q! z- E  q
burst <n-good>/<n-max> [<mask>/<masked-address>] : Start a rapid set of measurements
5 s" ~) @: {8 M7 J* v8 vclients : Report on clients that have accessed the server
* u1 x3 o( V( e! tcmdaccheck <address> : Check whether command access is allowed to <address>: p+ w+ M8 W  `, J! S
cmdallow [<subnet-addr>] : Allow command access to that subnet as a default' I% f, O3 b9 S8 y+ d
cmdallow all [<subnet-addr>] : Allow command access to that subnet and all children, g! \/ \. [! D9 K+ G1 G
cmddeny [<subnet-addr>] : Deny command access to that subnet as a default
1 L; i- k) u! L  f……………………省略
 楼主| 发表于 2017-2-28 20:25:21 | 显示全部楼层
配置NTP server 服务器 #yum install -y ntp
! M5 }4 `3 [+ X, _  V9 w+ v- V, G●        编辑ntp 配置  vim /etc/ntp.conf
: X! i) [0 ]2 {: X: A3 xdriftfile /var/lib/ntp/drift
# e, ]0 ~$ ^( `+ b5 ~restrict default nomodify notrap nopeer noquery
2 X9 o! r" l" ~1 d6 Jrestrict 127.0.0.1
7 g% o" c( U1 L9 ^1 c. w% erestrict ::16 L% B6 y; q# L; {
server 127.127.1.0                                
# s# b/ M0 B4 qfudge 127.127.1.0 stratum 0                  
& S! j1 {, J. |includefile /etc/ntp/crypto/pw
7 i1 @& M6 J# H) \3 v0 O0 qkeys /etc/ntp/keys
4 u" o3 A7 J8 Y; D6 D( Odisable monitor9 N2 H1 P- a( m4 y7 Q" Y) N' K  V
●        编辑ntp 服务器的配置 " M! M- @" T( x: ~! ~0 h# D
# vim  /etc/sysconfig/iptables 6 _+ g3 ~& T  {1 V7 t( o' L1 O7 S

; h( w3 |% g0 ?6 Q; ]2 E& O; M6 g0 e  -A INPUT -p udp --dport 123 -j ACCEPT
! w' ^- `+ J- M8 W8 B4 `
4 O; R* c( a0 M# systemctl restart iptables
- f- f1 K: C4 f& G0 q# systemctl restart iptables.service
  x! n3 ]2 p7 j. l1 D7 D●        将系统时间写入硬件) @: w, H+ |: S1 y! G" h
  # hwclock --systohc
( w3 P, D4 R  F+ o; B●        重新启动NTP服务+ {5 L1 i( E% a* {6 K! s7 {2 _3 w
    # service ntpd restart) j/ U# G. d( V- {0 O
/ X; o* S5 p3 b$ h+ h
 楼主| 发表于 2018-9-28 19:45:01 | 显示全部楼层
设定NTP主机来源(其中prefer表示优先主机),192.168.7.49是本地的NTP服务器,所以优先指定从该主机同步时间。3 G% T/ t- A1 `2 G

& K" [; w/ T3 N  p2 Iserver 192.168.7.49 prefer
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )点击这里给我发消息

GMT+8, 2026-4-8 21:37 , Processed in 0.054023 second(s), 26 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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