{"id":1154,"date":"2023-05-31T17:34:38","date_gmt":"2023-05-31T09:34:38","guid":{"rendered":"http:\/\/learning.sino-vt.com:8988\/?p=1154"},"modified":"2023-05-31T17:34:38","modified_gmt":"2023-05-31T09:34:38","slug":"%e5%85%b3%e4%ba%8eauditsys%e6%9c%8d%e5%8a%a1%e7%ab%af%e6%97%a5%e5%bf%97%e4%b8%8e%e6%97%a5%e5%bf%97%e5%88%87%e5%89%b2logrotate","status":"publish","type":"post","link":"http:\/\/learning.sino-vt.com:8988\/index.php\/2023\/05\/31\/%e5%85%b3%e4%ba%8eauditsys%e6%9c%8d%e5%8a%a1%e7%ab%af%e6%97%a5%e5%bf%97%e4%b8%8e%e6%97%a5%e5%bf%97%e5%88%87%e5%89%b2logrotate\/","title":{"rendered":"\u5173\u4e8eAuditsys\u670d\u52a1\u7aef\u65e5\u5fd7\u4e0e\u65e5\u5fd7\u5207\u5272logrotate"},"content":{"rendered":"<p>\u5f53\u524d4.9\u73af\u5883\u670d\u52a1\u4ea7\u751f\u7684\u65e5\u5fd7\u6587\u4ef6\uff1a<\/p>\n<table style=\"border-collapse: collapse;width: 751px;height: 365px\" border=\"1\" width=\"776\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr style=\"height: 15.60pt\">\n<td class=\"et2\" style=\"height: 15.60pt;width: 87.60pt\" width=\"146\" height=\"26\">\u670d\u52a1\u540d\u79f0<\/td>\n<td class=\"et3\" style=\"width: 115.20pt\" width=\"192\">\u5e94\u7528\u670d\u52a1\u5668<\/td>\n<td class=\"et3\" style=\"width: 172.20pt\" width=\"287\">\u63a7\u5236\u53f0Center<\/td>\n<td class=\"et3\" style=\"width: 90.60pt\" width=\"151\">ES\u670d\u52a1\u5668<\/td>\n<\/tr>\n<tr style=\"height: 15.60pt\">\n<td class=\"et2\" style=\"height: 15.60pt;width: 87.60pt\" width=\"146\" height=\"26\">\u65e5\u5fd7\u8def\u5f84<\/td>\n<td class=\"et4\">\/var\/log\/auditsys\/<\/td>\n<td class=\"et4\">\/var\/log\/auditsys\/<\/td>\n<td class=\"et4\">\/app\/es\/logs\uff08\u4ee5\u5b9e\u9645\u60c5\u51b5\u4e3a\u51c6\uff09<\/td>\n<\/tr>\n<tr style=\"height: 62.40pt\">\n<td class=\"et2\" style=\"height: 62.40pt;width: 87.60pt\" width=\"146\" height=\"104\">\u65e5\u5fd7\u6587\u4ef6\u540d<\/td>\n<td class=\"et4\">auditsys.log-*<\/td>\n<td class=\"et5\" style=\"width: 172.20pt\" width=\"287\">auditsys_center.log-*<br \/>\nauditsys_manage.log-*<\/td>\n<td class=\"et5\" style=\"width: 100.6pt\" width=\"151\">cluster-202*.log.gz<br \/>\ncluster-202*.json.gz<\/td>\n<\/tr>\n<tr style=\"height: 15.60pt\">\n<td class=\"et2\" style=\"height: 15.60pt;width: 87.60pt\" width=\"146\" height=\"26\">\u5b57\u7b26\u7f16\u7801<\/td>\n<td class=\"et4\">utf-8<\/td>\n<td class=\"et4\">utf-8<\/td>\n<td class=\"et4\">utf-8<\/td>\n<\/tr>\n<tr style=\"height: 46.80pt\">\n<td class=\"et2\" style=\"height: 46.80pt;width: 87.60pt\" width=\"146\" height=\"78\">\u65e5\u5fd7\u5207\u5272\u65b9\u5f0f<br \/>\n\uff08\u5468\/\u5929\/\u5c0f\u65f6\/\u5927\u5c0f\uff09<\/td>\n<td class=\"et4\">\u6bcf\u5468\u5207\u5272\u6216\u6587\u4ef6\u5927\u4e8e200M\u5207\u5272<\/td>\n<td class=\"et4\">\u6bcf\u5929\u5207\u5272\u6216\u6587\u4ef6\u5927\u4e8e1000M\u5207\u5272<\/td>\n<td class=\"et4\">\u6bcf\u5929\u5207\u5272\u5e76\u538b\u7f29<\/td>\n<\/tr>\n<tr style=\"height: 31.20pt\">\n<td class=\"et2\" style=\"height: 31.20pt;width: 87.60pt\" width=\"146\" height=\"52\">\u5f53\u524d\u7cfb\u7edf\u65e5\u5fd7\u6e05\u7406\u673a\u5236<\/td>\n<td class=\"et4\">\u4fdd\u7559\u6700\u8fd14\u4efd\u65e5\u5fd7<\/td>\n<td class=\"et4\">\u4fdd\u7559\u6700\u8fd14\u4efd\u65e5\u5fd7<\/td>\n<td class=\"et4\">\u901a\u8fc7\u811a\u672c\u5b9a\u65f6\u4efb\u52a1\u6e05\u7406<\/td>\n<\/tr>\n<tr style=\"height: 15.60pt\">\n<td class=\"et2\" style=\"height: 15.60pt;width: 87.60pt\" width=\"146\" height=\"26\">\u5907\u6ce8<\/td>\n<td class=\"et4\">\u5207\u5272\u65b9\u5f0f\u4e0e\u6e05\u7406\u673a\u5236\u53ef\u4ee5\u8c03\u6574<\/td>\n<td class=\"et4\">\u5207\u5272\u65b9\u5f0f\u4e0e\u6e05\u7406\u673a\u5236\u53ef\u4ee5\u8c03\u6574<\/td>\n<td class=\"et4\">\u6e05\u7406\u673a\u5236\u53ef\u4ee5\u901a\u8fc7\u811a\u672c\u8c03\u6574<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5f53\u524d\u6211\u4eec\u7cfb\u7edfcenter\u548cserver\u4ea7\u751f\u7684\u65e5\u5fd7\u4f1a\u901a\u8fc7linux\u4e2d\u7684logrotate\u505a\u5207\u5272\u6e05\u7406\u3002es\u670d\u52a1\u4ea7\u751f\u7684log\u6587\u4ef6\uff0c\u53c8es\u670d\u52a1\u672c\u8eab\u7ba1\u7406\uff0c\u53ef\u4ee5\u901a\u8fc7log4j\u63a7\u5236\u65e5\u5fd7\u6e05\u7406\uff0c\u4e5f\u53ef\u4ee5\u7528\u811a\u672c\u5b9a\u671f\u6e05\u7406\u3002<\/p>\n<p><strong>1\u3001\u4e3a\u4ec0\u4e48\u65e5\u5fd7\u9ed8\u8ba4\u53ea\u4fdd\u75594\u4efd<\/strong><\/p>\n<p>center\u548cserver\u7684\u65e5\u5fd7\u5728\u670d\u52a1\u5668\u901a\u8fc7logrotate\u9ed8\u8ba4\u662f\u4fdd\u75594\u4e2a\u65e5\u5fd7\u6587\u4ef6\uff0c\u8fd9\u4e2a\u6587\u4ef6\u6e05\u7406\u4e0d\u4f1a\u5f71\u54cd\u63a7\u5236\u53f0\u67e5\u770b\u7ba1\u7406\u5458\u65e5\u5fd7\u4e0e\u7cfb\u7edf\u65e5\u5fd7\u3002<\/p>\n<p>\u56e0\u4e3a\u8fd9\u4e9b\u65e5\u5fd7\u6587\u4ef6\u4f1a\u901a\u8fc7rsyslog\u4f20\u7ed9es\u4fdd\u5b58\uff0c\u4ece\u63a7\u5236\u53f0\u67e5\u770b\u7684\u90fd\u662fes\u7d22\u5f15\u4e2d\u7684\u6570\u636e\u3002\u6240\u4ee5\u670d\u52a1\u5668\u4e0a\u7684\u65e5\u5fd7\u6e05\u7406\u4e0d\u5f71\u54cd\u67e5\u770b\uff0c\u672c\u5730\u7684\u65e5\u5fd7\u6587\u4ef6\u53ea\u76f8\u5f53\u4e8e\u7f13\u5b58\u3002<\/p>\n<p><strong>2\u3001\u63a7\u5236\u53f0ES\u914d\u7f6e\u4e2d\u7684\u65e5\u5fd7\u6570\u636e\u4fdd\u7559\u65f6<\/strong>\u95f4<\/p>\n<p>\u63a7\u5236\u53f0ES\u914d\u7f6e\u4e2d\u7684\u65e5\u5fd7\u6570\u636e\u4fdd\u7559\u65f6\u95f4\u6307\u7684\u662f\u65e5\u5fd7\u5185\u5bb9\u5728es\u7d22\u5f15\u4e2d\u4fdd\u7559\u7684\u65f6\u95f4\uff0c\u8fd9\u4e2a\u4f1a\u5f71\u54cd\u5728\u63a7\u5236\u53f0\u53ef\u4ee5\u770b\u5230\u7684\u65e5\u5fd7\u65f6\u95f4\u8303\u56f4<\/p>\n<p><strong>3\u3001\u4e3a\u4ec0\u4e48center\u548cserver\u8fd0\u884c\u4e2d\u4ea7\u751f\u7684\u65e5\u5fd7\u4f1a\u5199\u5165\u5230messages\u4e2d\uff1f<\/strong><\/p>\n<p>\u7531\u4e8e\u6211\u4eec\u7a0b\u5e8f\u8bb0\u5f55\u65e5\u5fd7\uff0c\u9700\u8981\u901a\u8fc7rsyslog\u65b9\u5f0f\u8f93\u5165\u5230\u7684\u6307\u5b9a\u65e5\u5fd7\u6587\u4ef6\uff0cmessage\u81ea\u52a8\u76d1\u63a7\u4e86\u6240\u6709\u7684rsyslog\u65e5\u5fd7\uff0c\u6240\u4ee5\u5728\u5199\u5165\u5230\u65e5\u5fd7\u6587\u4ef6\u4e4b\u524d\u5c31\u5df2\u7ecf\u5199\u5165\u4e86messages\u4e2d\uff08\u4e2a\u522b\u573a\u666f\u53ef\u80fd\u4f1a\u6709\u5199\u5165messages\u6587\u4ef6\u8fc7\u5927\u7684\u60c5\u51b5\uff0c\u9700\u8981\u6ce8\u610f\uff09<\/p>\n<p><span style=\"font-size: 24px\"><strong>\u5173\u4e8elogrotate\u5207\u5272\u529f\u80fd<\/strong><\/span><\/p>\n<p>logrotate\u662f\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406\u65e5\u5fd7\u6587\u4ef6\u7684\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u81ea\u52a8\u5730\u65cb\u8f6c\u3001\u538b\u7f29\u3001\u5220\u9664\u65e7\u7684\u65e5\u5fd7\u6587\u4ef6\uff0c\u5e76\u521b\u5efa\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\u3002\u5b83\u53ef\u4ee5\u5e2e\u52a9\u7cfb\u7edf\u7ba1\u7406\u5458\u6709\u6548\u5730\u7ba1\u7406\u65e5\u5fd7\u6587\u4ef6\uff0c\u907f\u514d\u65e5\u5fd7\u6587\u4ef6\u8fc7\u5927\u5bfc\u81f4\u78c1\u76d8\u7a7a\u95f4\u4e0d\u8db3\u7684\u95ee\u9898\u3002logrotate\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u6765\u6307\u5b9a\u9700\u8981\u7ba1\u7406\u7684\u65e5\u5fd7\u6587\u4ef6\uff0c\u4ee5\u53ca\u65cb\u8f6c\u3001\u538b\u7f29\u3001\u5220\u9664\u7b49\u64cd\u4f5c\u7684\u89c4\u5219<\/p>\n<p>logrotate\u7684\u65e5\u5fd7\u5207\u5272\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\uff1a\/etc\/logrotate.d\/<\/p>\n<p>center\u4e2d\u65e5\u5fd7\u7684logrotate\u914d\u7f6e\uff1a\/etc\/logrotate.d\/auditsys<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1162 size-full\" src=\"http:\/\/learning.sino-vt.com:8988\/wp-content\/uploads\/2023\/05\/\u5fae\u4fe1\u56fe\u7247_20230531172611.png\" alt=\"\" width=\"618\" height=\"331\" srcset=\"http:\/\/learning.sino-vt.com:8988\/wp-content\/uploads\/2023\/05\/\u5fae\u4fe1\u56fe\u7247_20230531172611.png 618w, http:\/\/learning.sino-vt.com:8988\/wp-content\/uploads\/2023\/05\/\u5fae\u4fe1\u56fe\u7247_20230531172611-300x161.png 300w\" sizes=\"auto, (max-width: 618px) 100vw, 618px\" \/><\/p>\n<p>\u914d\u7f6e\u6587\u4ef6\u4e2d\u683c\u5f0f\u4e3a\uff1a\u65e5\u5fd7\u6587\u4ef6\u7edd\u5bf9\u8def\u5f84\uff0c\u5927\u62ec\u53f7{}\u4e2d\u5199\u5177\u4f53\u53c2\u6570\u914d\u7f6e<\/p>\n<p><strong>\u53c2\u6570\u914d\u7f6e\u4ecb\u7ecd\uff1a<\/strong><\/p>\n<ul>\n<li data-pid=\"LxCwUMFB\">maxsize:\u7528\u4e8e\u6307\u5b9a\u65e5\u5fd7\u6587\u4ef6\u7684\u6700\u5927\u5927\u5c0f\u3002\u5f53\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\u8fbe\u5230maxsize\u65f6\uff0clogrotate\u4f1a\u81ea\u52a8\u8f6e\u6362\u8be5\u6587\u4ef6\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\u3002<\/li>\n<li data-pid=\"LxCwUMFB\">monthly: \u65e5\u5fd7\u6587\u4ef6\u5c06\u6309\u6708\u8f6e\u5faa\u3002\u5176\u5b83\u53ef\u7528\u503c\u4e3a<code>daily\uff08\u5929\uff09<\/code>\uff0c<code>weekly\uff08\u5468\uff09<\/code>\u6216\u8005<code>yearly\uff08\u5e74\uff09<\/code>\u3002<\/li>\n<li data-pid=\"ig4-799G\">rotate 5: \u4e00\u6b21\u5c06\u5b58\u50a8 5 \u4e2a\u5f52\u6863\u65e5\u5fd7\u3002\u5bf9\u4e8e\u7b2c\u516d\u4e2a\u5f52\u6863\uff0c\u65f6\u95f4\u6700\u4e45\u7684\u5f52\u6863\u5c06\u88ab\u5220\u9664(\u4e5f\u5c31\u662f\u4fdd\u7559\u591a\u5c11\u4e2a\u65e7\u7684\u65e5\u5fd7\u6587\u4ef6)\u3002<\/li>\n<li data-pid=\"Z2P_Nytx\">compress: \u5728\u8f6e\u5faa\u4efb\u52a1\u5b8c\u6210\u540e\uff0c\u5df2\u8f6e\u5faa\u7684\u5f52\u6863\u5c06\u4f7f\u7528 gzip \u8fdb\u884c\u538b\u7f29\u3002<\/li>\n<li data-pid=\"rRFCkKPp\">delaycompress: \u603b\u662f\u4e0e compress \u9009\u9879\u4e00\u8d77\u7528\uff0cdelaycompress \u9009\u9879\u6307\u793a logrotate \u4e0d\u8981\u5c06\u6700\u8fd1\u7684\u5f52\u6863\u538b\u7f29\uff0c\u538b\u7f29 \u5c06\u5728\u4e0b\u4e00\u6b21\u8f6e\u5faa\u5468\u671f\u8fdb\u884c\u3002\u8fd9\u5728\u4f60\u6216\u4efb\u4f55\u8f6f\u4ef6\u4ecd\u7136\u9700\u8981\u8bfb\u53d6\u6700\u65b0\u5f52\u6863\u65f6\u5f88\u6709\u7528\u3002<\/li>\n<li data-pid=\"acFnnFnc\">missingok: \u5728\u65e5\u5fd7\u8f6e\u5faa\u671f\u95f4\uff0c\u4efb\u4f55\u9519\u8bef\u5c06\u88ab\u5ffd\u7565\uff0c\u4f8b\u5982 \u201c\u6587\u4ef6\u65e0\u6cd5\u627e\u5230\u201d \u4e4b\u7c7b\u7684\u9519\u8bef\u3002<\/li>\n<li data-pid=\"ByNnoD47\">notifempty: \u5982\u679c\u65e5\u5fd7\u6587\u4ef6\u4e3a\u7a7a\uff0c\u8f6e\u5faa\u4e0d\u4f1a\u8fdb\u884c\u3002<\/li>\n<li data-pid=\"ByNnoD47\">notifempty \uff1a\u5982\u679c\u662f\u7a7a\u6587\u4ef6\u7684\u8bdd\uff0c\u4e0d\u8f6c\u50a8<\/li>\n<li data-pid=\"ByNnoD47\">copytruncate\uff1a\u7528\u4e8e\u8fd8\u5728\u6253\u5f00\u4e2d\u7684\u65e5\u5fd7\u6587\u4ef6\uff0c\u628a\u5f53\u524d\u65e5\u5fd7\u5907\u4efd\u5e76\u622a\u65ad<\/li>\n<li data-pid=\"SrVBX5b2\">create 644 root root: \u4ee5\u6307\u5b9a\u7684\u6743\u9650\u521b\u5efa\u5168\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\uff0c\u540c\u65f6 logrotate \u4e5f\u4f1a\u91cd\u547d\u540d\u539f\u59cb\u65e5\u5fd7\u6587\u4ef6\u3002<\/li>\n<li data-pid=\"XBEx2Y5H\">postrotate\/endscript: \u5728\u6240\u6709\u5176\u5b83\u6307\u4ee4\u5b8c\u6210\u540e\uff0cpostrotate \u548c endscript \u91cc\u9762\u6307\u5b9a\u7684\u547d\u4ee4\u5c06\u88ab\u6267\u884c\uff08\u4e3b\u8981\u7528\u4e8e\u91cd\u65b0\u542f\u52a8\u65e5\u5fd7\u5199\u5165\u5230\u65b0\u7684\u65e5\u5fd7\u6587\u4ef6\uff09\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0crsyslogd \u8fdb\u7a0b\u5c06\u7acb\u5373\u518d\u6b21\u8bfb\u53d6\u5176\u914d\u7f6e\u5e76\u7ee7\u7eed\u8fd0\u884c\u3002<\/li>\n<li data-pid=\"XBEx2Y5H\">sharedscripts\u9009\u9879\u662f\u7528\u6765\u6307\u5b9a\u5728\u6240\u6709\u65e5\u5fd7\u6587\u4ef6\u90fd\u88ab\u8f6e\u6362\u4e4b\u540e\uff0c\u662f\u5426\u6267\u884c\u4e00\u6b21\u811a\u672c\u3002\u5982\u679c\u8bbe\u7f6e\u4e3asharedscripts\uff0c\u5219\u5728\u6240\u6709\u65e5\u5fd7\u6587\u4ef6\u8f6e\u6362\u4e4b\u540e\uff0c\u53ea\u4f1a\u6267\u884c\u4e00\u6b21\u811a\u672c\u3002\u5982\u679c\u672a\u8bbe\u7f6esharedscripts\uff0c\u5219\u6bcf\u4e2a\u65e5\u5fd7\u6587\u4ef6\u8f6e\u6362\u65f6\u90fd\u4f1a\u6267\u884c\u4e00\u6b21\u811a\u672c\u3002\u8fd9\u4e2a\u9009\u9879\u901a\u5e38\u7528\u4e8e\u9700\u8981\u5728\u6240\u6709\u65e5\u5fd7\u6587\u4ef6\u8f6e\u6362\u4e4b\u540e\u6267\u884c\u4e00\u6b21\u811a\u672c\u7684\u60c5\u51b5\uff0c\u6bd4\u5982\u91cd\u542f\u670d\u52a1\u6216\u8005\u53d1\u9001\u901a\u77e5\u90ae\u4ef6\u7b49\u3002<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>\u53c2\u8003\u6587\u6863\uff1a<\/p>\n<p><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/90507023\">Linux\u65e5\u5fd7\u5207\u5272\u795e\u5668logrotate\u539f\u7406\u4ecb\u7ecd\u548c\u914d\u7f6e\u8be6\u89e3 &#8211; \u77e5\u4e4e (zhihu.com)<\/a><\/p>\n<p><a href=\"https:\/\/cloud.tencent.com\/developer\/article\/1409653\">\u4f60\u771f\u7684\u641e\u61c2logrotate\u4e86\u5417\uff1f \u539f-\u817e\u8baf\u4e91\u5f00\u53d1\u8005\u793e\u533a-\u817e\u8baf\u4e91 (tencent.com)<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d4.9\u73af\u5883\u670d\u52a1\u4ea7\u751f\u7684\u65e5\u5fd7\u6587\u4ef6\uff1a \u670d\u52a1\u540d\u79f0 \u5e94\u7528\u670d\u52a1\u5668 \u63a7\u5236\u53f0Center ES\u670d\u52a1\u5668 \u65e5\u5fd7\u8def\u5f84 \/var\/ [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,9],"tags":[],"class_list":["post-1154","post","type-post","status-publish","format-standard","hentry","category-auditsys","category-9"],"_links":{"self":[{"href":"http:\/\/learning.sino-vt.com:8988\/index.php\/wp-json\/wp\/v2\/posts\/1154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/learning.sino-vt.com:8988\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/learning.sino-vt.com:8988\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/learning.sino-vt.com:8988\/index.php\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"http:\/\/learning.sino-vt.com:8988\/index.php\/wp-json\/wp\/v2\/comments?post=1154"}],"version-history":[{"count":9,"href":"http:\/\/learning.sino-vt.com:8988\/index.php\/wp-json\/wp\/v2\/posts\/1154\/revisions"}],"predecessor-version":[{"id":1164,"href":"http:\/\/learning.sino-vt.com:8988\/index.php\/wp-json\/wp\/v2\/posts\/1154\/revisions\/1164"}],"wp:attachment":[{"href":"http:\/\/learning.sino-vt.com:8988\/index.php\/wp-json\/wp\/v2\/media?parent=1154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/learning.sino-vt.com:8988\/index.php\/wp-json\/wp\/v2\/categories?post=1154"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/learning.sino-vt.com:8988\/index.php\/wp-json\/wp\/v2\/tags?post=1154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}