找回密码
 注册
查看: 4990|回复: 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 | 显示全部楼层
查看时间同步源的信息。/ c4 @8 ~6 [3 K+ r" T* {( C! F& @
# chronyc sourcestats -v8 u& r* l- J/ ^- u4 V. j. E
210 Number of sources = 1
4 h! \9 F! ?  E" F9 t+ t                             .- Number of sample points in measurement set.$ m. S  z8 |: ]+ \# a1 T: t9 K  l
                            /    .- Number of residual runs with same sign.
: `6 P- T0 g# i) n3 ^# {) N) r                           |    /    .- Length of measurement set (time).
  u4 l  m8 b; o% J" h8 ^, p( {2 C                           |   |    /      .- Est. clock freq error (ppm).
1 c3 C7 w5 S$ j2 }: o                           |   |   |      /           .- Est. error in freq.' f0 ~$ E! Z4 ?2 |) U; G5 i1 N( f' X
                           |   |   |     |           /         .- Est. offset.% M8 E( e& C9 }" ^) N% u4 z
                           |   |   |     |          |          |   On the -.
1 W. [3 K; y0 J  N4 r" Q3 q                           |   |   |     |          |          |   samples. \
8 J" B' c2 K( v: c& G0 J3 j) y                           |   |   |     |          |          |             |
7 a1 R: f! V$ F5 r8 dName/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev9 O$ X; \$ {! Q, e5 m
==============================================================================& a3 g  E, l- k0 _- D0 M
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( c+ }  k7 G8 e7 `% R* D  S' n
chrony version 1.29.19 R8 [3 N6 e! N3 ^
Copyright (C) 1997-2003, 2007, 2009-2013 Richard P. Curnow and others% Z8 T( S8 q1 R2 S
chrony comes with ABSOLUTELY NO WARRANTY.  This is free software, and
% V, G8 b) ~7 L% x, U. _! s/ yyou are welcome to redistribute it under certain conditions.  See the
& C' T( R. m: _" z( CGNU General Public License version 2 for details.6 v; t+ K, T: |1 C/ Z1 f8 T& R% C
chronyc> activity
% v: H5 q5 E/ S) d6 j, k& v200 OK
+ z$ y* o; O1 V3 Y, r3 E+ t3 sources online
1 l/ y( l: ?& P, ^0 sources offline3 Z  u. u, F, b) D
0 sources doing burst (return to online)
) L- s& t2 F, U* A+ c0 sources doing burst (return to offline)
  B! @: H/ U0 f' w5 f0 sources with unknown address* F8 L. {# x0 ^( t$ D; E
chronyc> help
1 [9 n4 u- }7 D' v& a! B, N6 ECommands:7 x$ M4 n% k- M1 ]  V
accheck <address> : Check whether NTP access is allowed to <address>
" G( c8 U+ l7 e+ _. T' Ractivity : Check how many NTP sources are online/offline# [+ s0 C  v% Q% w  k% K* K
add peer <address> ... : Add a new NTP peer  b2 j. ]- a# x+ {0 o
add server <address> ... : Add a new NTP server& U& [% T2 O  Q) j
allow [<subnet-addr>] : Allow NTP access to that subnet as a default
% F- B/ a3 k0 W/ s5 Wallow all [<subnet-addr>] : Allow NTP access to that subnet and all children/ n) d2 W# f1 O$ U; D* x
burst <n-good>/<n-max> [<mask>/<masked-address>] : Start a rapid set of measurements0 G8 B8 k1 O3 o7 b0 t0 ^
clients : Report on clients that have accessed the server$ C( ^  \! C9 ]0 @' G# a
cmdaccheck <address> : Check whether command access is allowed to <address>
8 A4 m, i& l- S" n) @0 P$ P4 ^) Icmdallow [<subnet-addr>] : Allow command access to that subnet as a default. |% e  Q4 e4 E6 k
cmdallow all [<subnet-addr>] : Allow command access to that subnet and all children' q& P) u1 p& V+ V9 E' T
cmddeny [<subnet-addr>] : Deny command access to that subnet as a default
* F# i! x- _" e  y% O1 O8 w$ K……………………省略

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2017-2-28 20:25:21 | 显示全部楼层
配置NTP server 服务器 #yum install -y ntp   W- V. D8 U& \) r' M0 Q2 x
●        编辑ntp 配置  vim /etc/ntp.conf) u* D: m7 w1 @2 J6 p8 V! X2 S
driftfile /var/lib/ntp/drift1 p+ r1 v% n0 M% c: I
restrict default nomodify notrap nopeer noquery- G5 g5 U1 Z8 l; s( z( {
restrict 127.0.0.1 5 H% [. W- `' T) W
restrict ::12 T; N2 T& `! w3 V5 ~
server 127.127.1.0                                
* G$ N1 O3 F; u. _/ A* dfudge 127.127.1.0 stratum 0                   9 {4 [' W1 u" a
includefile /etc/ntp/crypto/pw
! x. W; f" b4 ^5 H! O7 bkeys /etc/ntp/keys; V! p! P1 F9 j7 z/ N8 h6 e
disable monitor' t0 J* S8 U! L5 J
●        编辑ntp 服务器的配置 6 ~7 V3 k5 z! w$ A) t3 V
# vim  /etc/sysconfig/iptables ) c9 q- r+ ?6 w; X5 _7 m% ^

! g" W6 k3 n) M2 l; c. g  -A INPUT -p udp --dport 123 -j ACCEPT# _) p7 e; t+ a
! N" a( ]$ A, N4 T# x
# systemctl restart iptables) d  K8 n2 F* a
# systemctl restart iptables.service
( a/ m- J/ B! A) S; p6 R) I●        将系统时间写入硬件  F0 e8 t9 H. d' @  ^' f
  # hwclock --systohc
: B. }6 S3 n, j  P7 w; _+ W●        重新启动NTP服务
$ E/ A6 c; C" l3 W! I) J, S* x8 F    # service ntpd restart
1 G$ X+ _1 m: m" x4 |9 `1 a
# P$ u( V* y. i. P0 t* i- @

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2018-9-28 19:45:01 | 显示全部楼层
设定NTP主机来源(其中prefer表示优先主机),192.168.7.49是本地的NTP服务器,所以优先指定从该主机同步时间。- t' K" G6 w! A" ?1 X+ v

  {  S0 q8 e7 f8 f8 Hserver 192.168.7.49 prefer
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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