{"id":273,"date":"2018-05-23T23:18:18","date_gmt":"2018-05-23T15:18:18","guid":{"rendered":"https:\/\/wp.yaanren.win\/?p=273"},"modified":"2018-05-23T23:18:18","modified_gmt":"2018-05-23T15:18:18","slug":"%e5%9c%a8-ubuntu-%e4%b8%ad%e4%bd%bf%e7%94%a8-ntp-%e8%bf%9b%e8%a1%8c%e6%97%b6%e9%97%b4%e5%90%8c%e6%ad%a5%e8%ae%be%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/wp.625300.xyz\/?p=273","title":{"rendered":"\u5728 Ubuntu \u4e2d\u4f7f\u7528 NTP \u8fdb\u884c\u65f6\u95f4\u540c\u6b65\u8bbe\u7f6e"},"content":{"rendered":"<div class=\"title\">\n<p class=\"YaHei\">\u8f6c\u8f7d\u81ea\uff1ahttp:\/\/www.jb51.net\/article\/110814.htm<\/p>\n<\/div>\n<div class=\"lbd clearfix\"><\/div>\n<div class=\"art_desc mt10\">\n<div id=\"art_demo\">\u672c\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd\u4e86\u5728 Ubuntu \u4e2d\u4f7f\u7528 NTP \u8fdb\u884c\u65f6\u95f4\u540c\u6b65\u8bbe\u7f6e\uff0c\u901a\u5e38\u5ba2\u6237\u7aef\u5411\u670d\u52a1\u5668\u8bf7\u6c42\u5f53\u524d\u7684\u65f6\u95f4\uff0c\u5e76\u6839\u636e\u7ed3\u679c\u6765\u8bbe\u7f6e\u5176\u65f6\u949f\u3002<\/div>\n<\/div>\n<div class=\"lbd clearfix\"><\/div>\n<div id=\"content\">\n<p>NTP \u662f\u901a\u8fc7\u7f51\u7edc\u6765\u540c\u6b65\u65f6\u95f4\u7684\u4e00\u79cd TCP\/IP \u534f\u8bae\u3002\u901a\u5e38\u5ba2\u6237\u7aef\u5411\u670d\u52a1\u5668\u8bf7\u6c42\u5f53\u524d\u7684\u65f6\u95f4\uff0c\u5e76\u6839\u636e\u7ed3\u679c\u6765\u8bbe\u7f6e\u5176\u65f6\u949f\u3002<\/p>\n<p>\u8fd9\u4e2a\u63cf\u8ff0\u662f\u633a\u7b80\u5355\u7684\uff0c\u5b9e\u73b0\u8fd9\u4e00\u529f\u80fd\u5374\u662f\u6781\u4e3a\u590d\u6742\u7684 &#8211; \u9996\u5148\u8981\u6709\u591a\u5c42 NTP \u670d\u52a1\u5668\uff0c\u7b2c\u4e00\u5c42 NTP \u670d\u52a1\u5668\u8fde\u63a5\u539f\u5b50\u65f6\u949f\uff0c\u7b2c\u4e8c\u5c42\u3001\u7b2c\u4e09\u5c42\u670d\u52a1\u5668\u5219\u62c5\u8d77\u8d1f\u8f7d\u5747\u8861\u7684\u8d23\u4efb\uff0c\u4ee5\u5904\u7406\u56e0\u7279\u7f51\u4f20\u6765\u7684\u6240\u6709\u8bf7\u6c42\u3002\u53e6\u5916\uff0c\u5ba2\u6237\u7aef\u53ef\u80fd\u4e5f\u8d85\u4e4e\u4f60\u60f3\u8c61\u7684\u590d\u6742 &#8211; \u5b83\u5fc5\u987b\u6392\u9664\u901a\u8baf\u5ef6\u8fdf\uff0c\u8c03\u6574\u65f6\u95f4\u7684\u540c\u65f6\u4e0d\u5e72\u6270\u5176\u5b83\u5728\u670d\u52a1\u5668\u4e2d\u8fd0\u884c\u7684\u8fdb\u7a0b\u3002\u5e78\u8fd0\u7684\u662f\uff0c\u6240\u6709\u7684\u8fd9\u4e9b\u590d\u6742\u6027\u90fd\u8fdb\u884c\u4e86\u5c01\u88c5\uff0c\u4f60\u662f\u4e0d\u53ef\u89c1\u4e5f\u4e0d\u9700\u8981\u89c1\u5230\u7684\u3002<\/p>\n<p>\u5728 Ubuntu \u4e2d\uff0c\u662f\u4f7f\u7528\u00a0<code>ntpdate\u00a0<\/code>\u548c\u00a0<code>ntpd\u00a0<\/code>\u6765\u540c\u6b65\u65f6\u95f4\u7684\u3002<\/p>\n<p><strong>timedatectl<\/strong><\/p>\n<p>\u5728\u6700\u65b0\u7684 Ubuntu \u7248\u672c\u4e2d\uff0c<code>timedatectl\u00a0<\/code>\u66ff\u4ee3\u4e86\u8001\u65e7\u7684\u00a0<code>ntpdate<\/code>\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>timedatectl\u00a0<\/code>\u5728\u7cfb\u7edf\u542f\u52a8\u7684\u65f6\u5019\u4f1a\u7acb\u523b\u540c\u6b65\u65f6\u95f4\uff0c\u5e76\u5728\u7a0d\u540e\u7f51\u7edc\u8fde\u63a5\u6fc0\u6d3b\u540e\u901a\u8fc7 socket \u518d\u6b21\u68c0\u67e5\u4e00\u6b21\u3002<\/p>\n<p>\u5982\u679c\u5df2\u5b89\u88c5\u4e86\u00a0<code>ntpdate\u00a0<\/code>\/\u00a0<code>ntp<\/code>\uff0c<code>timedatectl\u00a0<\/code>\u4f1a\u9000\u800c\u8ba9\u4f60\u4f7f\u7528\u4e4b\u524d\u7684\u8bbe\u7f6e\u3002\u8fd9\u6837\u786e\u4fdd\u4e86\u4e24\u4e2a\u65f6\u95f4\u540c\u6b65\u670d\u52a1\u4e0d\u4f1a\u76f8\u4e92\u51b2\u7a81\uff0c\u540c\u65f6\u5728\u4f60\u5347\u7ea7\u7684\u65f6\u5019\u8fd8\u4fdd\u7559\u539f\u672c\u7684\u884c\u4e3a\u548c\u914d\u7f6e\u3002\u4f46\u8fd9\u4e5f\u610f\u5473\u7740\u4ece\u65e7\u7248\u672c\u7684\u53d1\u884c\u7248\u5347\u7ea7\u65f6\u00a0<code>ntp<\/code>\/<code>ntpdate\u00a0<\/code>\u4ecd\u4f1a\u5b89\u88c5\uff0c\u56e0\u6b64\u4f1a\u5bfc\u81f4\u65b0\u7684\u57fa\u4e8e systemd \u7684\u65f6\u95f4\u670d\u52a1\u88ab\u7981\u7528\u3002<\/p>\n<p><strong>timesyncd<\/strong><\/p>\n<p>\u5728\u6700\u65b0\u7684 Ubuntu \u7248\u672c\u4e2d\uff0c<code>timesyncd\u00a0<\/code>\u66ff\u4ee3\u4e86\u00a0<code>ntpd\u00a0<\/code>\u7684\u5ba2\u6237\u7aef\u7684\u90e8\u5206\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u00a0<code>timesyncd\u00a0<\/code>\u4f1a\u5b9a\u671f\u68c0\u6d4b\u5e76\u540c\u6b65\u65f6\u95f4\u3002\u5b83\u8fd8\u4f1a\u5728\u672c\u5730\u5b58\u50a8\u66f4\u65b0\u7684\u65f6\u95f4\uff0c\u4ee5\u4fbf\u5728\u7cfb\u7edf\u91cd\u542f\u65f6\u505a\u65f6\u95f4\u5355\u6b65\u8c03\u6574\u3002<\/p>\n<p>\u901a\u8fc7\u00a0<code>timedatectl<\/code>\u00a0\u548c<code>\u00a0timesyncd\u00a0<\/code>\u8bbe\u7f6e\u7684\u5f53\u524d\u65f6\u95f4\u72b6\u6001\u548c\u65f6\u95f4\u914d\u7f6e\uff0c\u53ef\u4ee5\u4f7f\u7528\u00a0<code>timedatectl status\u00a0<\/code>\u547d\u4ee4\u6765\u8fdb\u884c\u786e\u8ba4\u3002<\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">timedatectl status\n   Local time: Fri 2016-04-29 06:32:57 UTC\n Universal time: Fri 2016-04-29 06:32:57 UTC\n    RTC time: Fri 2016-04-29 07:44:02\n    Time zone: Etc\/UTC (UTC, +0000)\n Network time on: yes\nNTP synchronized: no\n RTC in local TZ: no<\/pre>\n<\/div>\n<p>\u5982\u679c\u5b89\u88c5\u4e86 NTP\uff0c\u5e76\u7528\u5b83\u66ff\u4ee3\u00a0<code>timedatectl\u00a0<\/code>\u6765\u540c\u6b65\u65f6\u95f4\uff0c\u5219<code>\u00a0NTP synchronized\u00a0<\/code>\u5c06\u88ab\u8bbe\u7f6e\u4e3a\u00a0<code>yes<\/code>\u3002<\/p>\n<p><code>timedatectl\u00a0<\/code>\u548c\u00a0<code>timesyncd\u00a0<\/code>\u7528\u6765\u83b7\u53d6\u65f6\u95f4\u7684 nameserver \u53ef\u4ee5\u901a\u8fc7<code>\u00a0\/etc\/systemd\/timesyncd.conf\u00a0<\/code>\u6765\u6307\u5b9a\uff0c\u53e6\u5916\u5728\u00a0<code>\/etc\/systemd\/timesyncd.conf.d\/\u00a0<\/code>\u4e0b\u8fd8\u6709\u7075\u6d3b\u7684\u9644\u52a0\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p><strong>ntpdate<\/strong><\/p>\n<p>\u7531\u4e8e\u00a0<code>timedatectl\u00a0<\/code>\u7684\u5b58\u5728\uff0c\u5404\u53d1\u884c\u7248\u5df2\u7ecf\u5f03\u7528\u4e86\u00a0<code>ntpdate<\/code>\uff0c\u9ed8\u8ba4\u4e0d\u518d\u8fdb\u884c\u5b89\u88c5\u3002\u5982\u679c\u4f60\u5b89\u88c5\u4e86\uff0c\u5b83\u4f1a\u5728\u7cfb\u7edf\u542f\u52a8\u7684\u65f6\u5019\u6839\u636e Ubuntu \u7684 NTP \u670d\u52a1\u5668\u6765\u8bbe\u7f6e\u4f60\u7535\u8111\u7684\u65f6\u95f4\u3002\u4e4b\u540e\u6bcf\u5f53\u4e00\u4e2a\u65b0\u7684\u7f51\u7edc\u63a5\u53e3\u542f\u52a8\u65f6\uff0c\u5b83\u5c31\u4f1a\u91cd\u65b0\u5c1d\u8bd5\u540c\u6b65\u65f6\u95f4 \u2014\u2014 \u5728\u8fd9\u671f\u95f4\u53ea\u8981\u5176\u6db5\u76d6\u7684\u65f6\u95f4\u5dee\u4e0d\u662f\u592a\u5927\uff0c\u5b83\u5c31\u4f1a\u6162\u6162\u504f\u79fb\u65f6\u95f4\u3002\u8be5\u884c\u4e3a\u53ef\u4ee5\u901a\u8fc7<code>\u00a0-B<\/code>\/<code>-b\u00a0<\/code>\u5f00\u5173\u6765\u8fdb\u884c\u63a7\u5236\u3002<\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">ntpdate ntp.ubuntu.com\n<\/pre>\n<\/div>\n<p><strong>\u65f6\u95f4\u670d\u52a1\u5668<\/strong><\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u57fa\u4e8e systemd \u7684\u5de5\u5177\u90fd\u662f\u4ece<code>\u00a0ntp.ubuntu.com\u00a0<\/code>\u8bf7\u6c42\u65f6\u95f4\u540c\u6b65\u7684\u3002\u7ecf\u5178\u7684\u57fa\u4e8e<code>\u00a0ntpd\u00a0<\/code>\u7684\u670d\u52a1\u57fa\u672c\u4e0a\u90fd\u662f\u4f7f\u7528\u00a0<code>[0-3].ubuntu.pool.ntp.org<\/code>\u00a0\u6c60\u4e2d\u7684\u00a0<code>2.ubuntu.pool.ntp.org<\/code>\uff0c\u8fd8\u6709<code>\u00a0ntp.ubuntu.com<\/code>\uff0c\u6b64\u5916\u9700\u8981\u7684\u8bdd\u8fd8\u652f\u6301 IPv6\u3002\u5982\u679c\u60f3\u5f3a\u5236\u4f7f\u7528 IPv6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>\u00a0ipv6.ntp.ubuntu.com<\/code>\uff0c\u4e0d\u8fc7\u8fd9\u5e76\u975e\u9ed8\u8ba4\u914d\u7f6e\u3002<\/p>\n<p><strong>ntpd<\/strong><\/p>\n<p>ntp \u7684\u5b88\u62a4\u8fdb\u7a0b\u00a0<code>ntpd\u00a0<\/code>\u4f1a\u8ba1\u7b97\u4f60\u7684\u7cfb\u7edf\u65f6\u949f\u7684\u65f6\u95f4\u504f\u79fb\u91cf\u5e76\u4e14\u6301\u7eed\u7684\u8fdb\u884c\u8c03\u6574\uff0c\u6240\u4ee5\u4e0d\u4f1a\u51fa\u73b0\u65f6\u95f4\u5dee\u8ddd\u8f83\u5927\u7684\u66f4\u6b63\uff0c\u6bd4\u5982\u8bf4\uff0c\u4e0d\u4f1a\u5bfc\u81f4\u4e0d\u8fde\u7eed\u7684\u65e5\u5fd7\u3002\u8be5\u8fdb\u7a0b\u53ea\u82b1\u8d39\u5c11\u91cf\u7684\u8fdb\u7a0b\u8d44\u6e90\u548c\u5185\u5b58\uff0c\u4f46\u5bf9\u4e8e\u73b0\u4ee3\u7684\u670d\u52a1\u5668\u6765\u8bf4\u5b9e\u5728\u662f\u5fae\u4e0d\u8db3\u9053\u7684\u4e86\u3002<\/p>\n<p><strong>\u5b89\u88c5<\/strong><\/p>\n<p>\u8981\u5b89\u88c5 ntpd\uff0c\u5728\u7ec8\u7aef\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\uff1a<\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">sudo apt install ntp<\/pre>\n<\/div>\n<p><strong>\u914d\u7f6e<br \/>\n<\/strong><\/p>\n<p>\u7f16\u8f91<code>\u00a0\/etc\/ntp.conf\u00a0<\/code>\u2014\u2014 \u589e\u52a0\/\u79fb\u9664\u00a0<code>server\u00a0<\/code>\u884c\u3002\u9ed8\u8ba4\u914d\u7f6e\u6709\u4ee5\u4e0b\u670d\u52a1\u5668\uff1a<\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\"># Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board\n# on 2011-02-08 (LP: #104525). See http:\/\/www.pool.ntp.org\/join.html for\n# more information.\nserver 0.ubuntu.pool.ntp.org\nserver 1.ubuntu.pool.ntp.org\nserver 2.ubuntu.pool.ntp.org\nserver 3.ubuntu.pool.ntp.org<\/pre>\n<\/div>\n<p>\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u4e4b\u540e\uff0c\u4f60\u9700\u8981\u91cd\u65b0\u52a0\u8f7d\u00a0<code>ntpd<\/code>\uff1a<\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\">sudo systemctl reload ntp.service<\/pre>\n<\/div>\n<p><strong>\u67e5\u770b\u72b6\u6001<\/strong><\/p>\n<p>\u4f7f\u7528\u00a0<code>ntpq\u00a0<\/code>\u6765\u67e5\u770b\u66f4\u591a\u4fe1\u606f\uff1a<\/p>\n<div class=\"jb51code\">\n<pre class=\"brush:bash;\"># sudo ntpq -p\n   remote      refid   st t when poll reach  delay  offset jitter\n========================================================\n+stratum2-2.NTP. 129.70.130.70  2 u  5  64 377  68.461 -44.274 110.334\n+ntp2.m-online.n 212.18.1.106   2 u  5  64 377  54.629 -27.318 78.882\n*145.253.66.170 .DCFa.      1 u  10  64 377  83.607 -30.159 68.343\n+stratum2-3.NTP. 129.70.130.70  2 u  5  64 357  68.795 -68.168 104.612\n+europium.canoni 193.79.237.14  2 u  63  64 337  81.534 -67.968 92.792<\/pre>\n<\/div>\n<p><strong>PPS \u652f\u6301<\/strong><\/p>\n<p>\u4ece Ubuntu 16.04 \u5f00\u59cb\uff0cntp \u652f\u6301 PPS \u89c4\u8303\uff0c\u7ed9 ntp \u63d0\u4f9b\u4e86\u672c\u5730\u65f6\u95f4\u6e90\uff0c\u4ee5\u63d0\u4f9b\u66f4\u9ad8\u7684\u7cbe\u5ea6\u3002\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\uff0c\u4e5f\u5e0c\u671b\u5927\u5bb6\u591a\u591a\u652f\u6301\u811a\u672c\u4e4b\u5bb6<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u8f7d\u81ea\uff1ahttp:\/\/www.jb51.net\/article\/110814.htm \u672c\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd\u4e86\u5728 U&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[],"class_list":["post-273","post","type-post","status-publish","format-standard","hentry","category-32"],"_links":{"self":[{"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/posts\/273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=273"}],"version-history":[{"count":0,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=\/wp\/v2\/posts\/273\/revisions"}],"wp:attachment":[{"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.625300.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}