找回密码
 注册
查看: 4989|回复: 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 | 显示全部楼层
查看时间同步源的信息。
6 X3 N$ X' V  z+ s) J0 f, Q# chronyc sourcestats -v! i/ l' Y* k8 {: a/ H1 @
210 Number of sources = 1- }5 F% R, P9 O4 u1 B, c
                             .- Number of sample points in measurement set.
% R- l' q& l; d( F7 B/ _                            /    .- Number of residual runs with same sign.
1 X" H3 I7 a4 {! z                           |    /    .- Length of measurement set (time).
! g$ O/ ~+ P& w1 \/ G( S# ?4 T                           |   |    /      .- Est. clock freq error (ppm).
9 X5 E/ B  H* c5 ?                           |   |   |      /           .- Est. error in freq.& G3 s$ g: y' R+ u& V
                           |   |   |     |           /         .- Est. offset.' t. D. `5 C  u$ e
                           |   |   |     |          |          |   On the -.
# y4 ^1 T9 t2 i9 h                           |   |   |     |          |          |   samples. \: ]8 _. E" p7 Z( b
                           |   |   |     |          |          |             |
2 i$ ~. ~2 j% ]1 XName/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev4 y, `0 O9 i+ u% |1 G2 N
==============================================================================
' @. b, v5 c/ _) W- Jpromote.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
4 c% Q* \! ]5 gchrony version 1.29.1# {; |' z) G3 D; R
Copyright (C) 1997-2003, 2007, 2009-2013 Richard P. Curnow and others8 U) l+ v; ?$ r6 D7 b  J" ?
chrony comes with ABSOLUTELY NO WARRANTY.  This is free software, and
% L- m0 L2 `9 u% o& `8 B# Ryou are welcome to redistribute it under certain conditions.  See the* k/ J* Y* [% [
GNU General Public License version 2 for details.
" z: T8 [. Z( i1 H! ~chronyc> activity
9 D  C5 K' Y5 i' R- c1 F/ q2 w200 OK- j9 B- U& k3 `: x: e3 T0 m8 g( w
3 sources online
# m" R- v. k) N" a0 sources offline5 h/ P" q0 |$ ?% w" `! q: I
0 sources doing burst (return to online)
0 B/ b6 h6 ]* I+ @6 u' K2 H7 Z0 sources doing burst (return to offline)2 G1 A; h4 q7 ~' ~
0 sources with unknown address
/ p7 I. r. R/ W) K6 Y" Xchronyc> help
6 x% X. A' D- w. D! ~$ Y# JCommands:
, c: ?) i7 d7 n; kaccheck <address> : Check whether NTP access is allowed to <address>0 q9 z% r" W* {) `
activity : Check how many NTP sources are online/offline
' n/ Y8 X- Q4 t# _add peer <address> ... : Add a new NTP peer/ l* t" W2 w+ K. C
add server <address> ... : Add a new NTP server
: y8 H; ?1 [) Fallow [<subnet-addr>] : Allow NTP access to that subnet as a default4 W  p- q3 Z, U6 ]- U5 P, }7 S
allow all [<subnet-addr>] : Allow NTP access to that subnet and all children
/ t( G5 I; X1 Y. yburst <n-good>/<n-max> [<mask>/<masked-address>] : Start a rapid set of measurements9 r/ F% V% v3 i3 s$ \' |5 e+ @
clients : Report on clients that have accessed the server
' R2 G& C# a0 Y" {" `7 i5 c0 Jcmdaccheck <address> : Check whether command access is allowed to <address>
4 M0 T# S1 e) p' V& Fcmdallow [<subnet-addr>] : Allow command access to that subnet as a default& ?& T8 o7 M/ J  x0 _
cmdallow all [<subnet-addr>] : Allow command access to that subnet and all children7 M+ x8 I$ U& k' h) V& s% M
cmddeny [<subnet-addr>] : Deny command access to that subnet as a default6 t; g" A3 h% f0 b4 g0 T% r# O
……………………省略

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2017-2-28 20:25:21 | 显示全部楼层
配置NTP server 服务器 #yum install -y ntp % P5 X- J1 ^7 s$ s7 F- c% ^* O4 h
●        编辑ntp 配置  vim /etc/ntp.conf
3 X4 L; @  Z# c' edriftfile /var/lib/ntp/drift+ e: v7 l0 t1 n5 F+ k
restrict default nomodify notrap nopeer noquery6 r$ h5 i: u+ k
restrict 127.0.0.1
9 H( z2 w3 M9 J% y9 prestrict ::1
) a- c( Y9 @' T* O" v7 j) a" _+ \( G) Rserver 127.127.1.0                                
+ g6 G) E7 F5 G: mfudge 127.127.1.0 stratum 0                   ) g. L* v: w  j. C/ C
includefile /etc/ntp/crypto/pw
: N5 ?+ f) c2 H, \  Bkeys /etc/ntp/keys
+ W  k8 i  a5 ^) N/ b% n- `disable monitor
$ y. R: \4 @- \2 C7 Q* \●        编辑ntp 服务器的配置
$ P/ I; q  v. T7 ?# vim  /etc/sysconfig/iptables , M) B2 p6 i" u& ?6 Q5 p
7 c1 K; O, t9 |( p0 y9 ]
  -A INPUT -p udp --dport 123 -j ACCEPT5 d9 l; Y# R3 g6 P; m0 X+ [, |
) p5 @& K) e" g4 D0 H
# systemctl restart iptables
9 {$ ~1 V; A0 n+ _( m6 R# systemctl restart iptables.service
: H, D3 x3 y+ O0 L5 p/ m9 K●        将系统时间写入硬件
8 N. i: K; p# D2 q9 }2 O  # hwclock --systohc8 T" v- U- T' f* F% P0 h
●        重新启动NTP服务
% ]$ P& v# D  N. l5 ]    # service ntpd restart9 V4 c/ U$ z7 t1 s9 A$ R' u
: h* |4 C! F. S6 l

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2018-9-28 19:45:01 | 显示全部楼层
设定NTP主机来源(其中prefer表示优先主机),192.168.7.49是本地的NTP服务器,所以优先指定从该主机同步时间。
& H# ~% ?& d9 b9 ]; c5 [8 N+ l5 r) w, g: M
server 192.168.7.49 prefer
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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