找回密码
 注册
查看: 4988|回复: 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 | 显示全部楼层
查看时间同步源的信息。
. a( W$ g! F1 N) \. D2 V7 p0 R, S# chronyc sourcestats -v
' s3 Z2 R' f" s# E8 ^210 Number of sources = 1
) T( s; s. N2 _9 v                             .- Number of sample points in measurement set.
4 T7 f- g. H/ E- C                            /    .- Number of residual runs with same sign.
1 {5 r: ]! i3 N& D5 b& P+ A                           |    /    .- Length of measurement set (time).6 {! E& ]5 C+ K5 ]9 `* Q- k4 t
                           |   |    /      .- Est. clock freq error (ppm).: j) Q( P& n0 r, ^
                           |   |   |      /           .- Est. error in freq.
3 F9 q% E3 J+ ]& H                           |   |   |     |           /         .- Est. offset.
3 S) F: K' R8 Z" s& K) `/ T4 ?. Z  y                           |   |   |     |          |          |   On the -.
/ M' s9 ]3 I6 K+ o) J" A+ z) W. [                           |   |   |     |          |          |   samples. \* u" M! Z" Q8 M2 `5 _6 l- @* T
                           |   |   |     |          |          |             |
+ _$ K1 L( c% @/ R1 |Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev/ P& e) {0 y! Z5 I" V5 A
==============================================================================& l4 V1 h* v1 @: ]5 `
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 ~]# chronyc2 D9 Z7 l, e+ O; R. x- A
chrony version 1.29.18 N* F" X. _1 L
Copyright (C) 1997-2003, 2007, 2009-2013 Richard P. Curnow and others
6 q( ~8 T) Z0 J! v0 l9 f& v+ `chrony comes with ABSOLUTELY NO WARRANTY.  This is free software, and
. k# o2 }, h8 K  G  Lyou are welcome to redistribute it under certain conditions.  See the: y4 |( V; V* e* M4 I8 Q- w/ H/ B
GNU General Public License version 2 for details.
6 V* W9 Q; r; S& X# ^8 \. {2 ~5 Pchronyc> activity
- \0 B% n( @  v+ r+ [  t200 OK$ R1 V7 M% B, o1 A0 U' e
3 sources online0 _/ m2 v( F- o7 Z/ ?6 E7 e- |7 W
0 sources offline; @4 ~  [7 E0 Z- s' @$ j
0 sources doing burst (return to online)
6 M. S  y$ a3 P  Q0 sources doing burst (return to offline); n+ ~; i* n% G, o2 D
0 sources with unknown address
" s- g( x& ^6 d5 U" Wchronyc> help
. ]- q7 T, I! ]9 X% _% h6 ZCommands:1 l, k5 E$ u2 N, Z
accheck <address> : Check whether NTP access is allowed to <address>
/ L/ T5 J: d1 P! O5 e  l5 gactivity : Check how many NTP sources are online/offline
3 @6 u% k% S8 e; uadd peer <address> ... : Add a new NTP peer: |/ y* ^+ l0 f+ T7 W" C) Y
add server <address> ... : Add a new NTP server
7 E. O9 U/ i8 S( }allow [<subnet-addr>] : Allow NTP access to that subnet as a default' T: S5 B, q! I+ e
allow all [<subnet-addr>] : Allow NTP access to that subnet and all children
# p0 u3 u; u' Dburst <n-good>/<n-max> [<mask>/<masked-address>] : Start a rapid set of measurements
: b3 ]6 a( z* L: p: y# F1 L: v9 r( Dclients : Report on clients that have accessed the server$ B. p. a' ]8 M* B: n
cmdaccheck <address> : Check whether command access is allowed to <address>
* ~* H3 ~! D$ V- L3 B4 ~: Kcmdallow [<subnet-addr>] : Allow command access to that subnet as a default
3 c) P' Q' J( M! Lcmdallow all [<subnet-addr>] : Allow command access to that subnet and all children
: g' ^- }0 w) s) @0 i: Lcmddeny [<subnet-addr>] : Deny command access to that subnet as a default
+ T$ X5 Z* Y1 _" G……………………省略

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2017-2-28 20:25:21 | 显示全部楼层
配置NTP server 服务器 #yum install -y ntp
9 b+ e5 @/ l' C1 V; U+ `●        编辑ntp 配置  vim /etc/ntp.conf0 A7 ]% S0 P% g2 {
driftfile /var/lib/ntp/drift+ h4 {- j, E8 N9 E
restrict default nomodify notrap nopeer noquery* k; e0 `, K  Z3 l; \
restrict 127.0.0.1 7 z" W2 y+ H' I! I: t3 S1 c- X
restrict ::1
" e* k7 `. |( n4 Qserver 127.127.1.0                                3 ]: S8 b5 J/ ^+ t- Y
fudge 127.127.1.0 stratum 0                  
7 c5 p3 c. e: m8 Pincludefile /etc/ntp/crypto/pw
# v# F' S# {9 B7 l; Rkeys /etc/ntp/keys6 S2 z5 t5 }- ]7 w+ j
disable monitor
% _6 M/ p5 C1 R6 C# x0 R7 b* ~: O" j& e8 B●        编辑ntp 服务器的配置 5 g# g# \7 [4 r$ N
# vim  /etc/sysconfig/iptables 0 |& y7 m  C% N' Z' i
3 U3 s( F: ^% r3 k9 d2 e
  -A INPUT -p udp --dport 123 -j ACCEPT, G# k+ r; E2 I' l  K
7 j9 S3 p1 m  B" g7 ?
# systemctl restart iptables
% U$ S$ x, @' ^7 g& u# systemctl restart iptables.service
0 ^* w' A8 j% v●        将系统时间写入硬件4 L/ }* E0 E$ o8 T+ j% C$ U
  # hwclock --systohc) `0 g; c- V: {$ A
●        重新启动NTP服务" r8 [7 |& S& M0 U! f; w6 Y
    # service ntpd restart
# l2 e/ `8 F6 l. z* ]& c
  V4 E9 @! U$ q8 }

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2018-9-28 19:45:01 | 显示全部楼层
设定NTP主机来源(其中prefer表示优先主机),192.168.7.49是本地的NTP服务器,所以优先指定从该主机同步时间。9 B# \$ c0 |; c3 L- a# V5 }
- V% U7 k5 {3 q, c: G/ Q1 [
server 192.168.7.49 prefer
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 03:26 , Processed in 0.295779 second(s), 26 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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