{"id":398,"date":"2024-04-01T19:35:11","date_gmt":"2024-04-01T11:35:11","guid":{"rendered":"http:\/\/www.esufy.com\/?p=398"},"modified":"2024-04-01T19:35:11","modified_gmt":"2024-04-01T11:35:11","slug":"nacos%e6%97%a5%e5%bf%97%e5%a4%aa%e5%a4%9a%e4%ba%86%ef%bc%8c%e6%80%8e%e4%b9%88%e5%8f%aa%e4%bf%9d%e7%95%997%e5%a4%a9%e7%9a%84%e6%97%a5%e5%bf%97%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/www.esufy.cn\/?p=398","title":{"rendered":"nacos\u65e5\u5fd7\u592a\u591a\u4e86\uff0c\u600e\u4e48\u53ea\u4fdd\u75597\u5929\u7684\u65e5\u5fd7\uff1f"},"content":{"rendered":"<div class=\"dpu8C _2kCxD \">\n<p>\u6700\u8fd1\u53d1\u73b0\u670d\u52a1\u5668\u786c\u76d8\u7206\u6ee1\u4e86\uff0c\u7ecf\u6392\u67e5\uff0c\u53d1\u73b0\u662fnacos\u7684\u95ee\u9898\uff0c\u5b83\u7684\u65e5\u5fd7\u592a\u591a\u4e86\uff0c\u670d\u52a1\u5668\u5927\u534a\u7684\u78c1\u76d8\u7a7a\u95f4\u90fd\u662f\u88ab\u5b83\u5360\u6389\u7684\u3002\u90a3\u4e48\uff0c\u6709\u6ca1\u6709\u529e\u6cd5\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u5462\uff1f<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u5176\u5b9e\u6709\u4e2a\u5f88\u5e72\u8106\u7684\u65b9\u6cd5\uff0c\u5c31\u662f\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\uff0c\u628a\u65e5\u5fd7\u5173\u6389\u3002\u4f46\u662f\uff0c\u8fd9\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684\uff0c\u56e0\u4e3a\u5bf9\u4e8e\u751f\u4ea7\u73af\u5883\uff0c\u6211\u4eec\u8fd8\u662f\u8981\u4fdd\u7559\u4e00\u5b9a\u91cf\u7684\u65e5\u5fd7\uff0c\u4ee5\u5907\u9700\u8981\u7684\u65f6\u5019\u53ef\u4ee5\u67e5\u770b\u3002\u5982\u679c\u6ca1\u6709\u65e5\u5fd7\uff0c\u5230\u65f6\u5019\u5c31\u4e0d\u597d\u67e5\u95ee\u9898\u4e86\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u4e0b\u9762\uff0c\u6211\u4eec\u5c31\u6765\u8bb2\u4e00\u8bb2\uff0c\u5982\u679c\u53ea\u60f3\u8981\u4fdd\u75597\u5929\u7684\u65e5\u5fd7\uff0c\u8be5\u600e\u4e48\u505a\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u6211\u4eec\u7684\u505a\u6cd5\u662f\u5199\u4e00\u4e2a\u811a\u672c\uff0c\u5229\u7528linux\u7684cron\u5b9a\u65f6\u4efb\u52a1\u53bb\u6267\u884c\u8fd9\u4e2a\u811a\u672c\uff0c\u8fbe\u5230\u53ea\u4fdd\u75597\u5929\u65e5\u5fd7\u7684\u6548\u679c\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<h3>1\u3001\u7f16\u5199\u811a\u672c<\/h3>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u6211\u4eec\u7f16\u5199\u4e00\u4e2a\u811a\u672c\uff0c\u547d\u540d\u4e3adel_nacos_logs.sh\uff0c\u4e0b\u9762\u662f\u811a\u672c\u5185\u5bb9\uff1a<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<pre class=\"custom\"><code class=\"hljs\">\r\n############################\r\n# \u4fee\u6539\u9879\r\n# nacos_home\uff1anacos\u7684\u76ee\u5f55\r\n# savedays\uff1a\u4fdd\u7559\u6700\u8fd1\u51e0\u5929\u7684\u65e5\u5fd7\uff0csavedays+1\u5c31\u662f\u4fdd\u7559\u7684\u5929\u6570\r\n#############################\r\n\r\n# $(cd $(dirname $0);pwd)\u8868\u793a\u811a\u672c\u6587\u4ef6\u6240\u5728\u76ee\u5f55\r\nnacos_home=$(cd $(dirname $0);pwd)\/nacos\r\nsavedays=6\r\n\r\n\r\n# \u6253\u5370\u6267\u884c\u65f6\u95f4\uff0c\u53ef\u53bb\u6389\r\necho $(date +\"%Y-%m-%d %H:%M:%S\")-----------------start clean logs &gt; $nacos_home\/del_nacos_logs.log\r\n#\u6e05\u7406logs\u6587\u4ef6\u5939\u4e0b\u7684access.log\u6587\u4ef6\r\ndelList=$(find $nacos_home\/logs\/ -mtime +$savedays -name \"access_log.*.log\")\r\nfor i in $delList\r\n do\r\n   rm -rf $i\r\n   # \u6253\u5370\u5220\u9664\u7684\u65e5\u5fd7\uff0c\u53ef\u53bb\u6389\r\n   echo $i&gt;&gt;$nacos_home\/del_nacos_logs.log\r\n done\r\n\r\n#\u6e05\u7406bin\u6587\u4ef6\u5939\u4e0b\u7684access.log\u6587\u4ef6\r\ndelList=$(find $nacos_home\/bin\/logs\/ -mtime +$savedays -name \"access_log.*.log\")\r\nfor i in $delList\r\n do\r\n   rm -rf $i\r\n   # \u6253\u5370\u5220\u9664\u7684\u65e5\u5fd7\uff0c\u53ef\u53bb\u6389\r\n   echo $i&gt;&gt;$nacos_home\/del_nacos_logs.log\r\n done\r\n\r\n#\u6e05\u7406logs\u6587\u4ef6\u5939\u4e0b\u7684\u5176\u5b83\u6587\u4ef6\r\ndelList=$(find $nacos_home\/logs\/ -mtime +$savedays -name \"*.log.*\")\r\nfor i in $delList\r\n do\r\n   rm -rf $i\r\n   # \u6253\u5370\u5220\u9664\u7684\u65e5\u5fd7\uff0c\u53ef\u53bb\u6389\r\n   echo $i&gt;&gt;$nacos_home\/del_nacos_logs.log\r\n done\r\n\r\n<\/code><\/pre>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<h3>2\u3001\u521b\u5efa\u5b9a\u65f6\u4efb\u52a1<\/h3>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u4e0a\u9762\u7f16\u5199\u597d\u7684\u7684\u811a\u672c\uff0c\u6211\u4eec\u653e\u5728\/data\u4e0b\u9762\uff0c\u8ddfnacos\u76ee\u5f55\u540c\u7ea7\u3002\u4f60\u4e5f\u53ef\u4ee5\u81ea\u5df1\u968f\u4fbf\u653e\u5728\u4e00\u4e2a\u76ee\u5f55\u4e0b\uff0c\u6216\u8005\u6839\u636e\u4f60\u7684nacos\u76ee\u5f55\u6765\u5b9a\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\uff081\uff09\u6267\u884c\u547d\u4ee4\uff0c\u6253\u5f00\u5b9a\u65f6\u7f16\u8f91\u4efb\u52a1\uff1a<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<pre class=\"custom\"><code class=\"hljs\">crontab -e\r\n\r\n<\/code><\/pre>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\uff082\uff09\u5728\u91cc\u9762\u6dfb\u52a0\u4e00\u6761\u8bb0\u5f55\uff1a<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<pre class=\"custom\"><code class=\"hljs\">13 2 * * * \/data\/del_nacos_logs.sh\r\n\r\n<\/code><\/pre>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u4e0a\u9762\u7684\u5185\u5bb9\u8868\u793a\u6bcf\u5929\u51cc\u66682\u70b913\u5206\u6267\u884c<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\uff083\uff09\u91cd\u542fcrond\u670d\u52a1\uff1a<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<pre class=\"custom\"><code class=\"hljs\">systemctl restart crond\r\n\r\n<\/code><\/pre>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<h3>3\u3001\u6d4b\u8bd5<\/h3>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u8fd9\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u81ea\u5df1\u5148\u6267\u884c\u4e00\u4e0b\u547d\u4ee4\uff0c\u8fdb\u884c\u6d4b\u8bd5<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<pre class=\"custom\"><code class=\"hljs\">\/data\/del_nacos_logs.sh\r\n\r\n<\/code><\/pre>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u7136\u540e\u53bb\u770b\u770bnacos\u65e5\u5fd7\u662f\u5426\u88ab\u5220\u6389\u4e86\uff0c\u5982\u679c\u5220\u6389\u4e86\uff0c\u53ea\u4fdd\u7559\u4e86\u6700\u8fd17\u5929\u7684\u65e5\u5fd7\uff0c\u90a3\u5c31\u5927\u529f\u544a\u6210\u4e86\u3002<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u53d1\u73b0\u670d\u52a1\u5668\u786c\u76d8\u7206\u6ee1\u4e86\uff0c\u7ecf\u6392\u67e5\uff0c\u53d1\u73b0\u662fnacos\u7684\u95ee\u9898\uff0c\u5b83\u7684\u65e5\u5fd7\u592a\u591a\u4e86\uff0c\u670d\u52a1\u5668\u5927\u534a\u7684\u78c1\u76d8\u7a7a\u95f4\u90fd\u662f\u88ab\u5b83\u5360\u6389\u7684\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":400,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23,24],"tags":[70],"_links":{"self":[{"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/posts\/398"}],"collection":[{"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=398"}],"version-history":[{"count":1,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/posts\/398\/revisions"}],"predecessor-version":[{"id":399,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/posts\/398\/revisions\/399"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/media\/400"}],"wp:attachment":[{"href":"http:\/\/www.esufy.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=398"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}