{"id":299,"date":"2016-08-22T15:04:19","date_gmt":"2016-08-22T07:04:19","guid":{"rendered":"https:\/\/yyshell.com\/?p=299"},"modified":"2016-08-22T15:04:19","modified_gmt":"2016-08-22T07:04:19","slug":"%e5%86%85%e7%bd%91%e6%90%ad%e5%bb%bachrony%e6%97%b6%e9%97%b4%e5%90%8c%e6%ad%a5%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%ad%a5%e9%aa%a4","status":"publish","type":"post","link":"https:\/\/yyshell.com\/?p=299","title":{"rendered":"\u5185\u7f51\u642d\u5efachrony\u65f6\u95f4\u540c\u6b65\u670d\u52a1\u5668\u6b65\u9aa4"},"content":{"rendered":"<p>Linux\u7528\u6237\u5bf9\u4e8e\u65f6\u95f4\u540c\u6b65\uff0c\u57fa\u672c\u4e0a\u662f\u4f7f\u7528ntpdate\u548cntpd\u8fd9\u4e24\u4e2a\u5de5\u5177\u5b9e\u73b0\u7684\uff0c\u4f46\u662f\u8fd9\u4e24\u4e2a\u5de5\u5177\u5df2\u7ecf\u5f88\u53e4\u8001\u4e86\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f8b\u5982\uff0c\u4f60\u7684\u670d\u52a1\u5668\u7ecf\u5e38\u5f00\u5173\u673a\uff0c\u6216\u8005\u5f88\u5c11\uff0c\u5076\u5c14\u624d\u80fd\u8fde\u63a5\u5916\u90e8\u7f51\u7edc\uff0c\u6700\u5178\u578b\u7684\u6bd4\u5982\u5728\u9694\u7edd\u7684\u5185\u7f51\u4e2d\uff0c\u6ca1\u6709\u76f8\u5e94\u65f6\u95f4\u540c\u6b65\u7684\u786c\u4ef6\uff0cntpd\u652f\u6301\u5c31\u4e0d\u662f\u5f88\u597d\u4e86\u3002<\/p>\n<p>chrony\u662fredhat\u5f00\u53d1\u7684\uff0c\u5b83\u662f\u7f51\u7edc\u65f6\u95f4\u534f\u8bae\u7684 (NTP) \u7684\u53e6\u4e00\u79cd\u5b9e\u73b0\u3002centos7\/rhel7\u9ed8\u8ba4\u7684\u65f6\u95f4\u540c\u6b65\u5de5\u5177\uff0c\u5728centos6.8\u4e4b\u540e\uff0c\u8001\u7684centos\u548crhel6\u7cfb\u5217\u4e5f\u6dfb\u52a0\u4e0a\u4e86\u8fd9\u4e2a\u5de5\u5177\u3002Chrony\u53ef\u4ee5\u540c\u65f6\u505a\u4e3antp\u670d\u52a1\u7684\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u3002\u9ed8\u8ba4\u5b89\u88c5\u5b8c\u540e\u6709\u4e24\u4e2a\u7a0b\u5e8fchronyd\u548cchronyc \u3002chronyd\u662f\u4e00\u4e2a\u5728\u7cfb\u7edf\u540e\u53f0\u8fd0\u884c\u7684\u5b88\u62a4\u8fdb\u7a0b\uff0cchronyc\u662f\u7528\u6765\u76d1\u63a7chronyd\u6027\u80fd\u548c\u914d\u7f6e\u5176\u53c2\u6570\u7a0b\u5e8f\u3002<\/p>\n<p>\u670d\u52a1\u7aef\u7684\u914d\u7f6e\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:ini decode:true \">server 0.centos.pool.ntp.org iburst\r\nserver 1.centos.pool.ntp.org iburst\r\nserver 2.centos.pool.ntp.org iburst\r\nserver 3.centos.pool.ntp.org iburst\r\n\r\nstratumweight 0\r\ndriftfile \/var\/lib\/chrony\/drift\r\nrtcsync\r\nmakestep 10 3\r\nallow 192.168\/16\r\nsmoothtime 400 0.01\r\n\r\nbindcmdaddress 127.0.0.1\r\nbindcmdaddress ::1\r\n\r\nlocal stratum 8\r\nmanual\r\nkeyfile \/etc\/chrony.keys\r\ninitstepslew 10 client1 client3 client6\r\ncommandkey 1\r\ngeneratecommandkey\r\nnoclientlog\r\nlogchange 0.5\r\nlogdir \/var\/log\/chrony<\/pre>\n<p>192.168\u662f\u5141\u8bb8\u8fde\u63a5\u5230\u670d\u52a1\u5668\u7684\u5b50\u7f51\u7684\u7f51\u6bb5\u3002<\/p>\n<p>\u9632\u706b\u5899\u5f00\u901a\u7aef\u53e3<\/p>\n<pre class=\"lang:sh decode:true \">firewall-cmd --permanent --add-service=ntp\r\nfirewall-cmd --reload<\/pre>\n<p>\u5ba2\u6237\u7aef\u8bbe\u7f6e\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:ini decode:true \">server pdc.adagene.cn iburst\r\nstratumweight 0\r\ndriftfile \/var\/lib\/chrony\/drift\r\nrtcsync\r\nmakestep 10 3\r\nallow 192.168.49.196\r\nbindcmdaddress 127.0.0.1\r\nbindcmdaddress ::1\r\nlocal stratum 10\r\ninitstepslew 20 pdc.adagene.cn\r\nkeyfile \/etc\/chrony.keys\r\ncommandkey 24\r\ngeneratecommandkey\r\nnoclientlog\r\nlogchange 0.5\r\nlogdir \/var\/log\/chrony\r\nlog measurements statistics tracking\r\n<\/pre>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6211\u4eec\u8fd9\u91cc\u7684pdc.adagene.cn\u662f\u6709\u5185\u7f51\u89e3\u6790\u7684\u521a\u624dmaster\u7684\u7684\u4e3b\u673a\u540d\u3002allow\u540e\u9762\u7684ip\u5730\u5740\u4e3amaster\u4e3b\u673a\u7684ip\u5730\u5740\u3002<\/p>\n<p>\u542f\u7528chronyd\u670d\u52a1\u5373\u53ef\u540c\u6b65\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">systemctl start chronyd.service<\/pre>\n<p>\u6216\u8005\u6ca1\u6709\u542f\u52a8\u670d\u52a1\uff0c\u624b\u52a8\u540c\u6b65\uff08\u7c7b\u4f3cntpdate\u547d\u4ee4\uff09\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">chronyd -q 'server pdc.adagene.cn iburst'<\/pre>\n<p>\u9644\u51e0\u6761\u5ba2\u6237\u7aef\u67e5\u8be2\u5e38\u7528\u7684\u547d\u4ee4\uff1a<\/p>\n<p>\u67e5\u770b\u6e90\u670d\u52a1\u5668\u72b6\u6001chronyc sourcestats<\/p>\n<pre class=\"lang:sh decode:true \">[root@template ~]# chronyc sourcestats\r\n210 Number of sources = 1\r\nName\/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev\r\n==============================================================================\r\n192.168.49.196              4   3     6     +3.856    284.293   +214us    29us\r\n<\/pre>\n<p>\u67e5\u770b\u8be6\u7ec6\u540c\u6b65\u72b6\u6001chronyc sources -v<\/p>\n<pre class=\"lang:sh decode:true \">[root@template ~]# chronyc sources -v\r\n210 Number of sources = 1\r\n\r\n  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.\r\n \/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,\r\n| \/   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.\r\n||                                                 .- xxxx [ yyyy ] +\/- zzzz\r\n||      Reachability register (octal) -.           |  xxxx = adjusted offset,\r\n||      Log2(Polling interval) --.      |          |  yyyy = measured offset,\r\n||                                \\     |          |  zzzz = estimated error.\r\n||                                 |    |           \\\r\nMS Name\/IP address         Stratum Poll Reach LastRx Last sample\r\n===============================================================================\r\n^* 192.168.49.196                3   6    17    35  +7984ns[  +25us] +\/-   23ms\r\n<\/pre>\n<p>\u8ffd\u8e2a\u540c\u6b65\u60c5\u51b5chronyc tracking<\/p>\n<pre class=\"lang:sh decode:true\">[root@template ~]# chronyc tracking\r\nReference ID    : 192.168.49.196 (192.168.49.196)\r\nStratum         : 4\r\nRef time (UTC)  : Mon Aug 22 06:58:59 2016\r\nSystem time     : 0.000012924 seconds fast of NTP time\r\nLast offset     : +0.000033437 seconds\r\nRMS offset      : 0.000071534 seconds\r\nFrequency       : 34.016 ppm slow\r\nResidual freq   : +0.049 ppm\r\nSkew            : 1.057 ppm\r\nRoot delay      : 0.039409 seconds\r\nRoot dispersion : 0.002063 seconds\r\nUpdate interval : 64.2 seconds\r\nLeap status     : Normal\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u7528\u6237\u5bf9\u4e8e\u65f6\u95f4\u540c\u6b65\uff0c\u57fa\u672c\u4e0a\u662f\u4f7f\u7528ntpdate\u548cntpd\u8fd9\u4e24\u4e2a\u5de5\u5177\u5b9e\u73b0\u7684<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,12,7],"tags":[24,25,26],"class_list":["post-299","post","type-post","status-publish","format-standard","hentry","category-linux","category-12","category-7","tag-chrony","tag-ntp","tag-ntpdate"],"_links":{"self":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/299","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=299"}],"version-history":[{"count":1,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/299\/revisions"}],"predecessor-version":[{"id":300,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/299\/revisions\/300"}],"wp:attachment":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}