{"id":1457,"date":"2023-03-23T22:29:51","date_gmt":"2023-03-23T14:29:51","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1457"},"modified":"2023-04-28T20:42:34","modified_gmt":"2023-04-28T12:42:34","slug":"linux-server-time-synchronization","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/23\/linux-server-time-synchronization\/","title":{"rendered":"Linux\u670d\u52a1\u5668\u65f6\u95f4\u540c\u6b65"},"content":{"rendered":"<p>NTP\uff08\u7f51\u7edc\u65f6\u95f4\u534f\u8bae\u662f\u5728\u6570\u636e\u7f51\u7edc\u6f5c\u4f0f\u65f6\u95f4\u53ef\u53d8\u7684\u8ba1\u7b97\u673a\u7cfb\u7edf\u4e4b\u95f4\u901a\u8fc7\u5206\u7ec4\u4ea4\u6362\u8fdb\u884c\u65f6\u949f\u540c\u6b65\u7684\u4e00\u4e2a\u7f51\u7edc\u534f\u8bae\uff0c\u4f4d\u4e8eOSI\u6a21\u578b\u7684\u5e94\u7528\u5c42\uff09<\/p>\n<h2>\u65f6\u95f4\u540c\u6b65<\/h2>\n<p>\u524d\u63d0\u662f\u53ef\u4ee5\u8fde\u63a5\u4e92\u8054\u7f51<\/p>\n<p><!-- more --><\/p>\n<pre><code>yum install ntpdate<\/code><\/pre>\n<p>NTP\u5e38\u7528\u670d\u52a1\u5668\uff1a<\/p>\n<ul>\n<li>\u4e2d\u56fd\u56fd\u5bb6\u6388\u65f6\u4e2d\u5fc3\uff1a<code>ntp.ntsc.ac.cn<\/code><\/li>\n<li>NTP\u670d\u52a1\u5668(\u4e0a\u6d77)\uff1a<code>ntp.api.bz<\/code><\/li>\n<li>NTP\u5b98\u7f51\u63a8\u8350\u7684\u5730\u5740\u6c60\uff1a<code>pool.ntp.org<\/code><\/li>\n<li>\u4e2d\u56fd\u533a\u5730\u5740\u6c60\uff1a<code>cn.pool.ntp.org<\/code><\/li>\n<\/ul>\n<pre><code># date\nThu Dec 19 15:51:04 CST 2019\n# ntpdate -u ntp.api.bz\n19 Dec 15:53:44 ntpdate[25083]: step time server 114.118.7.163 offset 146.353887 sec\n# date\nThu Dec 19 15:53:51 CST 2019\n# ntpdate -u ntp.ntsc.ac.cn\n19 Dec 16:14:16 ntpdate[25221]: adjust time server 114.118.7.161 offset 0.000608 sec<\/code><\/pre>\n<p>\u65f6\u533a\u914d\u7f6e\uff1a<\/p>\n<pre><code># cp \/usr\/share\/zoneinfo\/Asia\/Shanghai \/etc\/localtime\ncp: overwrite \u2018\/etc\/localtime\u2019? y<\/code><\/pre>\n<h2>NTP\u670d\u52a1\u5668<\/h2>\n<pre><code># yum install ntp\n# systemctl start ntpd\n# systemctl status ntpd\n# systemctl enable ntpd\n# systemctl restart ntpd\n# systemctl stop ntpd<\/code><\/pre>\n<h2>\u4e0e\u5c40\u57df\u7f51\u5185NTP\u670d\u52a1\u5668\u540c\u6b65<\/h2>\n<pre><code># yum install ntpdate\n# ntpdate -u 192.168.1.20<\/code><\/pre>\n<p>\u6ce8\u610fNTP\u670d\u52a1\u5668\u4e0a\u8981\u5728\u9632\u706b\u5899\u4e2d\u653e\u884c<code>UDP 123<\/code>\u53f7\u7aef\u53e3<\/p>\n<pre><code>firewall-cmd --permanent --add-port=123\/udp\nfirewall-cmd --reload<\/code><\/pre>\n<h2>\u540c\u6b65\u65b9\u6848<\/h2>\n<p>\uff081\uff09NTP\u670d\u52a1\u5668\u4e0e\u4e92\u8054\u7f51\u8fdb\u884c\u65f6\u95f4\u540c\u6b65<br \/>\n\uff082\uff09\u5c40\u57df\u7f51\u5185\u5176\u4ed6\u673a\u5668\u4e0eNTP\u670d\u52a1\u5668\u8fdb\u884c\u65f6\u95f4\u540c\u6b65<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NTP\uff08\u7f51\u7edc\u65f6\u95f4\u534f\u8bae\u662f\u5728\u6570\u636e\u7f51\u7edc\u6f5c\u4f0f\u65f6\u95f4\u53ef\u53d8\u7684\u8ba1\u7b97\u673a\u7cfb\u7edf\u4e4b\u95f4\u901a\u8fc7\u5206\u7ec4\u4ea4\u6362\u8fdb\u884c\u65f6\u949f\u540c\u6b65\u7684\u4e00\u4e2a\u7f51\u7edc\u534f\u8bae\uff0c\u4f4d\u4e8eOSI [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[331],"tags":[359],"class_list":["post-1457","post","type-post","status-publish","format-standard","hentry","category-linux","tag-ntp"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1457"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1457\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}