易陆发现互联网技术论坛

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

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

[复制链接]
发表于 2016-8-22 15:36:56 | 显示全部楼层 |阅读模式
购买主题 本主题需向作者支付 3 金钱 才能浏览
 楼主| 发表于 2017-2-16 15:55:14 | 显示全部楼层
查看时间同步源的信息。, ?! T; e) r  q) R1 F; n, X# D
# chronyc sourcestats -v6 z" F, \" ~& U8 u' L: h
210 Number of sources = 1
7 ]8 [; g, i0 S6 P% N( C/ C- E                             .- Number of sample points in measurement set.% [/ Q0 N! L5 D
                            /    .- Number of residual runs with same sign.
' q% J$ s) f; k1 H6 y+ S                           |    /    .- Length of measurement set (time)./ v: b( v2 P* e  i& L7 h
                           |   |    /      .- Est. clock freq error (ppm).' E  k3 _5 B5 ]: x
                           |   |   |      /           .- Est. error in freq.4 ]5 L- u) `, g* q7 r( a$ y
                           |   |   |     |           /         .- Est. offset.
; u6 c, v# y& l) [$ s6 W. T9 W                           |   |   |     |          |          |   On the -.0 a3 P4 \, P. O4 J2 g, g
                           |   |   |     |          |          |   samples. \( v; o; o4 e0 _0 z6 S
                           |   |   |     |          |          |             |( ~% M! ^1 u+ g9 h: v4 q! Q
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev2 @/ B7 b* o$ v! Q1 q
==============================================================================8 S( w1 ?$ f  Z! k* o
promote.cache-dns.local     0   0     0     +0.000   2000.000     +0ns  4000ms
 楼主| 发表于 2017-2-16 15:56:30 | 显示全部楼层
[root@361way ~]# chronyc
2 S5 Z& [6 |) t4 z* q7 l4 Q% echrony version 1.29.1
3 f$ s- S+ G0 mCopyright (C) 1997-2003, 2007, 2009-2013 Richard P. Curnow and others* s. Q3 b0 I1 [/ V2 [+ _% Z' A2 N
chrony comes with ABSOLUTELY NO WARRANTY.  This is free software, and
5 R; K1 t9 u1 B6 h1 Z0 u  G/ \you are welcome to redistribute it under certain conditions.  See the4 I0 X- G" _& h# s1 o
GNU General Public License version 2 for details.$ X. |6 ]7 c2 T& ^% J6 K
chronyc> activity
" _& S% G9 |8 F% R200 OK2 O8 Z, h3 n3 d" i3 T0 s8 ?
3 sources online0 X( z8 F0 |* \* g( p- m  q
0 sources offline
* L8 P, C1 U% h1 j0 sources doing burst (return to online)$ j: P) F8 `& I4 f" x
0 sources doing burst (return to offline)) n! c/ a9 ^! B" O9 {
0 sources with unknown address" i& o5 Z. y: q/ n& S
chronyc> help( f4 `% _3 f) [$ I8 E
Commands:% ^1 r( ~0 q8 O% g& G) l0 e
accheck <address> : Check whether NTP access is allowed to <address>- i1 u2 G) s% S/ W
activity : Check how many NTP sources are online/offline2 v$ K9 u0 M- K2 D
add peer <address> ... : Add a new NTP peer: A& m7 M5 x- i5 U
add server <address> ... : Add a new NTP server& g! d1 H0 t- I. Z: `% W, F
allow [<subnet-addr>] : Allow NTP access to that subnet as a default2 e& K- L: |+ z$ V
allow all [<subnet-addr>] : Allow NTP access to that subnet and all children
! w7 ]; J9 ]' F; ?burst <n-good>/<n-max> [<mask>/<masked-address>] : Start a rapid set of measurements. R* d) v$ ~+ `- _. D: C& |
clients : Report on clients that have accessed the server  J( W6 ]# E+ {7 \" u$ E, O- I. v
cmdaccheck <address> : Check whether command access is allowed to <address>* P3 _- r& @7 L3 N# O+ e. |
cmdallow [<subnet-addr>] : Allow command access to that subnet as a default9 u  G+ m  `" I$ C) W2 l. y' J
cmdallow all [<subnet-addr>] : Allow command access to that subnet and all children  e& e, }+ S. x# r/ ~- m
cmddeny [<subnet-addr>] : Deny command access to that subnet as a default" T( s5 r% j5 }! h$ Q2 @
……………………省略
 楼主| 发表于 2017-2-28 20:25:21 | 显示全部楼层
配置NTP server 服务器 #yum install -y ntp
0 B; a* s7 u1 a& u●        编辑ntp 配置  vim /etc/ntp.conf
% ], ]. {; _4 r4 V5 ]3 V+ Jdriftfile /var/lib/ntp/drift
" q1 Y- A) w' ?4 Brestrict default nomodify notrap nopeer noquery
: h" Z& I& }; B, hrestrict 127.0.0.1
3 J2 l) K; g& o5 v: \- L) ]# y8 Orestrict ::1
0 \) z# W, Z( {8 n5 E' E& v+ H+ zserver 127.127.1.0                                7 ]3 K5 @3 I8 H- V6 s- Y6 x# x
fudge 127.127.1.0 stratum 0                   . @. ]0 ~% B+ M( j
includefile /etc/ntp/crypto/pw
/ D: D, D& k, X8 S8 b  j1 xkeys /etc/ntp/keys
. z, B  K% Z$ U9 Q+ A# Pdisable monitor) M' m; x% D: a2 t8 y
●        编辑ntp 服务器的配置   u$ v9 ]5 n% R$ o- n1 Q+ d
# vim  /etc/sysconfig/iptables 9 _, o& W7 v- B; B4 M" l

' H1 ]2 y& D7 z2 B. g  -A INPUT -p udp --dport 123 -j ACCEPT
; G4 K  u2 C4 V2 c% P7 T$ Q4 S* `4 W/ k8 m( z. H: B& w
# systemctl restart iptables4 O' {: j9 p$ X
# systemctl restart iptables.service6 U" k) I) G. P; M3 f8 i; z: F. y% b
●        将系统时间写入硬件9 X$ w0 U% a# M  ?
  # hwclock --systohc+ l2 @' c" W: ]. i7 i7 y& Y
●        重新启动NTP服务, y; N% s, J  i' Z
    # service ntpd restart
6 G' t( y( R- S9 |9 ^: S
2 y" O8 K- D+ g5 M
 楼主| 发表于 2018-9-28 19:45:01 | 显示全部楼层
设定NTP主机来源(其中prefer表示优先主机),192.168.7.49是本地的NTP服务器,所以优先指定从该主机同步时间。3 {8 a- m# [. R0 R- B

; t6 t' ^( v$ }% Hserver 192.168.7.49 prefer
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

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

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

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

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

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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