{"id":1266,"date":"2023-03-30T16:14:22","date_gmt":"2023-03-30T08:14:22","guid":{"rendered":"https:\/\/www.cith.ml:5444\/?p=1266"},"modified":"2023-03-30T16:45:55","modified_gmt":"2023-03-30T08:45:55","slug":"linux%e7%b3%bb%e7%bb%9f%e4%b8%ad%e4%bd%bf%e7%94%a8chrony%e8%bf%9b%e8%a1%8c%e6%97%b6%e9%97%b4%e5%90%8c%e6%ad%a5","status":"publish","type":"post","link":"https:\/\/blog.cithwu.com\/wp5444\/linux%e7%b3%bb%e7%bb%9f%e4%b8%ad%e4%bd%bf%e7%94%a8chrony%e8%bf%9b%e8%a1%8c%e6%97%b6%e9%97%b4%e5%90%8c%e6%ad%a5\/","title":{"rendered":"Centos8 \u4f7f\u7528 Chrony \u8fdb\u884c\u65f6\u95f4\u540c\u6b65"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">1)\u7cfb\u7edf\u9ed8\u8ba4\u5df2\u7ecf\u5b89\u88c5\uff0c\u5982\u672a\u5b89\u88c5\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1ayum install chrony -y<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2)\u542f\u52a8\u5e76\u52a0\u5165\u5f00\u673a\u81ea\u542f\u52a8systemctl enable chronyd.servicesystemctl start chronyd.service<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3)\u67e5\u770b\u72b6\u6001systemctl status chronyd.service<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4)\u914d\u7f6e\u6587\u4ef6\u8be6\u89e3cat \/etc\/chrony.conf<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># \u4f7f\u7528pool.ntp.org\u9879\u76ee\u4e2d\u7684\u516c\u5171\u670d\u52a1\u5668\u3002\u4ee5server\u5f00\u59cb\uff0c\u7406\u8bba\u4e0a\u4f60\u60f3\u6dfb\u52a0\u591a\u5c11\u65f6\u95f4\u670d\u52a1\u5668\u90fd\u53ef\u4ee5\u3002# Please consider joining the pool (<a href=\"http:\/\/www.pool.ntp.org\/join.html\">http:\/\/www.pool.ntp.org\/join.html<\/a>).server 0.centos.pool.ntp.org iburstserver 1.centos.pool.ntp.org iburstserver 2.centos.pool.ntp.org iburstserver 3.centos.pool.ntp.org iburst<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># \u6839\u636e\u5b9e\u9645\u65f6\u95f4\u8ba1\u7b97\u51fa\u670d\u52a1\u5668\u589e\u51cf\u65f6\u95f4\u7684\u6bd4\u7387\uff0c\u7136\u540e\u8bb0\u5f55\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff0c\u5728\u7cfb\u7edf\u91cd\u542f\u540e\u4e3a\u7cfb\u7edf\u505a\u51fa\u6700\u4f73\u65f6\u95f4\u8865\u507f\u8c03\u6574\u3002driftfile \/var\/lib\/chrony\/drift<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># chronyd\u6839\u636e\u9700\u6c42\u51cf\u6162\u6216\u52a0\u901f\u65f6\u95f4\u8c03\u6574\uff0c# \u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u7cfb\u7edf\u65f6\u949f\u53ef\u80fd\u6f02\u79fb\u8fc7\u5feb\uff0c\u5bfc\u81f4\u65f6\u95f4\u8c03\u6574\u7528\u65f6\u8fc7\u957f\u3002# \u8be5\u6307\u4ee4\u5f3a\u5236chronyd\u8c03\u6574\u65f6\u671f\uff0c\u5927\u4e8e\u67d0\u4e2a\u9600\u503c\u65f6\u6b65\u8fdb\u8c03\u6574\u7cfb\u7edf\u65f6\u949f\u3002# \u53ea\u6709\u5728\u56e0chronyd\u542f\u52a8\u65f6\u95f4\u8d85\u8fc7\u6307\u5b9a\u7684\u9650\u5236\u65f6\uff08\u53ef\u4f7f\u7528\u8d1f\u503c\u6765\u7981\u7528\u9650\u5236\uff09\u6ca1\u6709\u66f4\u591a\u65f6\u949f\u66f4\u65b0\u65f6\u624d\u751f\u6548\u3002makestep 1.0 3<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># \u5c06\u542f\u7528\u4e00\u4e2a\u5185\u6838\u6a21\u5f0f\uff0c\u5728\u8be5\u6a21\u5f0f\u4e2d\uff0c\u7cfb\u7edf\u65f6\u95f4\u6bcf11\u5206\u949f\u4f1a\u62f7\u8d1d\u5230\u5b9e\u65f6\u65f6\u949f\uff08RTC\uff09\u3002rtcsync<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Enable hardware timestamping on all interfaces that support it.# \u901a\u8fc7\u4f7f\u7528hwtimestamp\u6307\u4ee4\u542f\u7528\u786c\u4ef6\u65f6\u95f4\u6233#hwtimestamp eth0#hwtimestamp eth1#hwtimestamp *<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Increase the minimum number of selectable sources required to adjust# the system clock.#minsources 2<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># \u6307\u5b9a\u4e00\u53f0\u4e3b\u673a\u3001\u5b50\u7f51\uff0c\u6216\u8005\u7f51\u7edc\u4ee5\u5141\u8bb8\u6216\u62d2\u7eddNTP\u8fde\u63a5\u5230\u626e\u6f14\u65f6\u949f\u670d\u52a1\u5668\u7684\u673a\u5668#allow 192.168.0.0\/16#deny 192.168\/16<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Serve time even if not synchronized to a time source.local stratum 10<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># \u6307\u5b9a\u5305\u542bNTP\u9a8c\u8bc1\u5bc6\u94a5\u7684\u6587\u4ef6\u3002#keyfile \/etc\/chrony.keys<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># \u6307\u5b9a\u65e5\u5fd7\u6587\u4ef6\u7684\u76ee\u5f55\u3002logdir \/var\/log\/chrony<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"># Select which information is logged.#log measurements statistics tracking<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">5)\u8bbe\u7f6e\u65f6\u533a\u67e5\u770b\u5f53\u524d\u7cfb\u7edf\u65f6\u533a$ timedatectlLocal time: Fri 2018-2-29 13:31:04 CSTUniversal time: Fri 2018-2-29 05:31:04 UTCRTC time: Fri 2018-2-29 08:17:20Time zone: Asia\/Shanghai (CST, +0800)NTP enabled: yesNTP synchronized: yesRTC in local TZ: noDST active: n\/a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4f60\u5f53\u524d\u7684\u65f6\u533a\u4e0d\u6b63\u786e\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u64cd\u4f5c\u8bbe\u7f6e\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u67e5\u770b\u6240\u6709\u53ef\u7528\u7684\u65f6\u533a\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ timedatectl list-timezones\u7b5b\u9009\u5f0f\u67e5\u770b\u5728\u4e9a\u6d32S\u5f00\u7684\u4e0a\u6d77\u53ef\u7528\u65f6\u533a\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ timedatectl list-timezones | grep -E \u201cAsia\/S.*\u201dAsia\/SakhalinAsia\/SamarkandAsia\/SeoulAsia\/ShanghaiAsia\/SingaporeAsia\/Srednekolymsk<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bbe\u7f6e\u5f53\u524d\u7cfb\u7edf\u4e3aAsia\/Shanghai\u4e0a\u6d77\u65f6\u533a\uff1a$ timedatectl set-timezone Asia\/Shanghai<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bbe\u7f6e\u5b8c\u65f6\u533a\u540e\uff0c\u5f3a\u5236\u540c\u6b65\u4e0b\u7cfb\u7edf\u65f6\u949f\uff1a$ chronyc -a makestep200 OK<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u670d\u52a1\u5668\u7aef\u548c\u5ba2\u6237\u7aef\u4fee\u6539\/etc\/chrony.conf\u914d\u7f6e\u6587\u4ef6\uff0c\u6dfb\u52a0server xxxx.xx.xx.xx iburst<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">6)\u5728\u5ba2\u6237\u7aef\u6267\u884cchronyc sources \/\/\u5237\u65b0\u4e00\u4e0b\u540c\u6b65\u60c5\u51b5chronyc sources -v \/\/\u67e5\u770b\u65f6\u95f4\u540c\u6b65\u6e90\u7684\u72b6\u6001netstat -antpul | grep chron \/\/\u67e5\u770b\u8be5\u670d\u52a1\u7aef\u53e3\uff0c\u5e76\u5f00\u901a\u76f8\u5e94\u7aef\u53e3<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1)\u7cfb\u7edf\u9ed8\u8ba4\u5df2\u7ecf\u5b89\u88c5\uff0c\u5982\u672a\u5b89\u88c5\uff0c&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,9],"tags":[],"class_list":["post-1266","post","type-post","status-publish","format-standard","hentry","category-linux","category-9"],"_links":{"self":[{"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/posts\/1266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/comments?post=1266"}],"version-history":[{"count":2,"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/posts\/1266\/revisions"}],"predecessor-version":[{"id":1268,"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/posts\/1266\/revisions\/1268"}],"wp:attachment":[{"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/media?parent=1266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/categories?post=1266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.cithwu.com\/wp5444\/wp-json\/wp\/v2\/tags?post=1266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}