{"id":53,"date":"2010-12-09T13:13:01","date_gmt":"2010-12-09T05:13:01","guid":{"rendered":"http:\/\/www.microwolf.net\/?p=53"},"modified":"2010-12-09T13:13:01","modified_gmt":"2010-12-09T05:13:01","slug":"linux-ntp","status":"publish","type":"post","link":"http:\/\/www.microwolf.net\/?p=53","title":{"rendered":"Linux NTP"},"content":{"rendered":"<table border=\"0\" width=\"100%\">\n<tr>\n<td width=\"100%\">linux\u914d\u7f6e\u65f6\u95f4\u670d\u52a1\u5668<br \/>\n      \u5728linux\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u81ea\u5e26\u7684NTP(Network Time Protocol)\u534f\u8bae\u901a\u8fc7\u7f51\u7edc\u4f7f\u81ea\u5df1\u7684\u7cfb\u7edf\u4fdd\u6301\u7cbe\u786e\u7684\u65f6\u95f4\u3002<\/p>\n<p>      NTP\u662f\u7528\u6765\u4f7f\u7cfb\u7edf\u548c\u4e00\u4e2a\u7cbe\u786e\u7684\u65f6\u95f4\u6e90\u4fdd\u6301\u65f6\u95f4\u540c\u6b65\u7684\u534f\u8bae\u3002\u5efa\u8bae\u5927\u5bb6\u5728\u81ea\u5df1\u7ba1\u7406\u7684\u7f51\u7edc\u4e2d\u5efa\u7acb\u81f3\u5c11\u4e00\u53f0\u65f6\u95f4\u670d\u52a1\u5668\u6765\u540c\u6b65\u672c\u5730\u65f6\u95f4\uff0c\u8fd9\u6837\u53ef\u4ee5\u4f7f\u5f97\u5728\u4e0d\u540c\u7684\u7cfb\u7edf\u4e0a\u5904\u7406\u548c\u6536\u96c6\u65e5\u5fd7\u548c\u7ba1\u7406\u66f4\u52a0\u5bb9\u6613\u3002<\/p>\n<p>      1\u3001\u9996\u5148\u5b89\u88c5NTP\u670d\u52a1\u5668<\/p>\n<p>      rpm -qa|grep ntp<\/p>\n<p>      ntp-4.1.2-4.EL3.1<\/p>\n<p>      \u5982\u679c\u6ca1\u6709\u53ef\u4ee5\u4ecelinux\u5b89\u88c5\u76d8\u4e0a\u67e5\u627e\uff0c\u5b89\u88c5\u6b64ntp\u5305<\/p>\n<p>      2\u3001\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>      vi \/etc\/ntp.conf<\/p>\n<p>      \u9996\u5148\u5b9a\u4e49\u670d\u52a1\u5668<\/p>\n<p>      server pool.ntp.org #\u8fd9\u884c\u6307\u5b9a\u8fdb\u884c\u5bf9\u65f6\u65f6\u4f7f\u7528\u7684NTP\u670d\u52a1\u5668<\/p>\n<p>      restrict default nomodify notrap noquery<\/p>\n<p>      restrict 192.168.0.0 mask 255.255.255.0 notrust nomodify notrap #\u4ece192.168.0.1-192.168.0.254\u7684\u670d\u52a1\u5668\u90fd\u53ef\u4ee5\u4f7f\u7528\u6211\u4eec\u7684NTP\u670d\u52a1\u5668\u6765\u540c\u6b65\u65f6\u95f4\u3002<\/p>\n<p>      \u6ce8\u91ca\u6389\u4ee5\u4e0b\u4e00\u884c<\/p>\n<p>      #restrict default ignore<\/p>\n<p>      3\u3001\u542f\u52a8NTP\u670d\u52a1\u5668<\/p>\n<p>      #chkconfig ntpd on<\/p>\n<p>      #\/etc\/init.d\/ntpd start<\/p>\n<p>      #\/etc\/init.d\/ntpd stop<\/p>\n<p>      #\/etc\/init.d\/ntpd restart<\/p>\n<p>      \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u914d\u7f6e\u7684NTP\u670d\u52a1\u5668\u4e0d\u4f1a\u53bb\u65f6\u95f4\u6e90\u90a3\u91cc\u540c\u6b65\u65f6\u95f4\uff0c\u6240\u4ee5\u5fc5\u987b\u4fee\u6539\/etc\/ntp\/step-tickers\u6587\u4ef6\uff0c\u52a0\u5165\u6211\u4eec\u7684\u65f6\u95f4\u6e90\uff0c\u8fd9\u6837\u6bcf\u6b21\u901a\u8fc7\/etc\/init.d\/ntpd \u6765\u542f\u52a8\u670d\u52a1\u7684\u65f6\u5019\u5c31\u4f1a\u81ea\u52a8\u66f4\u65b0\u65f6\u95f4\u4e86<\/p>\n<p>      \u68c0\u67e5\u670d\u52a1\u5668\u540c\u6b65\u72b6\u6001\uff1a<\/p>\n<p>      ntpq -p<\/p>\n<p>      ntptrace 192.168.0.179<\/p>\n<p>      \u5982\u679c\u8f93\u51fa\u6b63\u786e\uff0c\u5219\u8bf4\u660e\u65f6\u95f4\u670d\u52a1\u5668\u6210\u529f\u3002<br \/>\n      # vi \/etc\/ntp\/step-tickers<br \/> <br \/>\n      \u52a0\u5165\u4e00\u884c<br \/>\n      pool.ntp.org<br \/>\n      \u8fd9\u6837\u6bcf\u6b21\u542f\u52a8\u670d\u52a1\u5668\uff0c\u4f1a\u81ea\u52a8\u4e0epool.ntp.org\u540c\u6b65\u65f6\u95f4\u3002<\/p>\n<p>      4\u3001\u914d\u7f6eLINUX\u5ba2\u6237\u7aef<\/p>\n<p>      \u5728linux\u5ba2\u6237\u7aef\u4e0a\u6267\u884cntpdate ntp_server_ip \u5c31\u53ef\u4ee5\u6839\u636e\u65f6\u95f4\u670d\u52a1\u5668\u7edf\u4e00\u5c40\u57df\u7f51\u7684\u65f6\u95f4\u4e86\uff0c\u5c06\u4e0a\u9762\u7684\u547d\u4ee4\u653e\u5230cron\u91cc\u6bcf\u5929\u65e9\u4e0a3\u70b9\u5b9a\u671f\u6267\u884c\uff0ccrontab \u2013e \u7136\u540e\u8f93\u5165<\/p>\n<p>      0 3 * * * \/usr\/sbin\/ntpdate 192.168.0.179 <\/p>\n<p>5\u3001\u914d\u7f6ewindows\u5ba2\u6237\u7aef<\/p>\n<p>\u5728window2k\u4e2d\uff0c\u5728cmd\u4e0b:net time \/setsntp:xxx.xxx.xxx.xxx \u518d\u542f\u7528windows<br \/>\n      time\u670d\u52a1\u5c31\u53ef\u4ee5\u81ea\u52a8\u5bf9\u65f6\u4e86<\/p>\n<p>      \u5728windows XP\u4e2d\uff0c\u53ea\u9700\u8981\u5728\u65e5\u671f\u4e0e\u65f6\u95f4\u4e2d\u8bbe\u7f6einternet\u65f6\u95f4\uff0c\u628a\u670d\u52a1\u5668\u8bbe\u7f6e\u4e3a\u524d\u9762\u5b89\u88c5NTP\u670d\u52a1\u5668\u7684IP\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>\u4f46\u81ea\u52a8\u5bf9\u65f6\u7684\u6700\u5927\u8bef\u5dee\u4e0e\u5468\u671f\u90fd\u662f\u6709\u9650\u5236\u7684\uff0c\u8fd9\u4e2a\u53ef\u4ee5\u81ea\u5df1\u5728\u6ce8\u518c\u8868\u4e2dw32time\u670d\u52a1\u9879\u4e2d\u624b\u52a8\u66f4\u6539\u3002 \n      <\/p>\n<\/td>\n<\/tr>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>linux\u914d\u7f6e\u65f6\u95f4\u670d\u52a1\u5668 \u5728linux\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u81ea\u5e26\u7684NTP(Network Time Protocol [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/www.microwolf.net\/index.php?rest_route=\/wp\/v2\/posts\/53"}],"collection":[{"href":"http:\/\/www.microwolf.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.microwolf.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.microwolf.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.microwolf.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=53"}],"version-history":[{"count":1,"href":"http:\/\/www.microwolf.net\/index.php?rest_route=\/wp\/v2\/posts\/53\/revisions"}],"predecessor-version":[{"id":54,"href":"http:\/\/www.microwolf.net\/index.php?rest_route=\/wp\/v2\/posts\/53\/revisions\/54"}],"wp:attachment":[{"href":"http:\/\/www.microwolf.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=53"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.microwolf.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=53"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.microwolf.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}