{"id":201480,"date":"2025-05-10T09:37:48","date_gmt":"2025-05-10T01:37:48","guid":{"rendered":"https:\/\/server.hk\/cnblog\/201480\/"},"modified":"2025-05-10T09:37:48","modified_gmt":"2025-05-10T01:37:48","slug":"%e7%bc%93%e5%ad%98%e6%95%b0%e6%8d%ae%e4%b8%a2%e4%ba%86%ef%bc%8c%e5%8e%9f%e6%9d%a5%e6%98%afredis%e6%8c%81%e4%b9%85%e5%8c%96%e6%b2%a1%e7%8e%a9%e6%98%8e%e7%99%bd","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/201480\/","title":{"rendered":"\u7f13\u5b58\u6570\u636e\u4e22\u4e86\uff0c\u539f\u6765\u662fRedis\u6301\u4e45\u5316\u6ca1\u73a9\u660e\u767d"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u7f13\u5b58\u6570\u636e\u4e22\u4e86\uff0c\u539f\u6765\u662fRedis\u6301\u4e45\u5316\u6ca1\u73a9\u660e\u767d<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u5bf9\u4e8e\u4e00\u4e2a\u6570\u636e\u5e93\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u7262\u56fa\u624e\u5b9e\u7684\u57fa\u7840\u662f\u5341\u5206\u91cd\u8981\u7684\uff0cgolang\u5b66\u4e60\u7f51\u5c31\u6765\u5e26\u5927\u5bb6\u4e00\u70b9\u70b9\u7684\u638c\u63e1\u57fa\u7840\u77e5\u8bc6\u70b9\u3002\u4eca\u5929\u672c\u7bc7\u6587\u7ae0\u5e26\u5927\u5bb6\u4e86\u89e3\u300a\u7f13\u5b58\u6570\u636e\u4e22\u4e86\uff0c\u539f\u6765\u662fRedis\u6301\u4e45\u5316\u6ca1\u73a9\u660e\u767d\u300b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e86Redis\u3001\u7f13\u5b58\u6570\u636e\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u5feb\u70b9\u6536\u85cf\u8d77\u6765\u5427\uff0c\u5426\u5219\u9700\u8981\u65f6\u5c31\u627e\u4e0d\u5230\u4e86\uff01<\/p>\n<p><span style=\"font-size: 14px\"><em>\u6211\u4eec\u90fd\u77e5\u9053Redis\u662f\u5fae\u670d\u52a1\u67b6\u6784\u4e2d\u91cd\u8981\u7684\u57fa\u7840\u6570\u636e\u5e93\u4e2d\u95f4\u4ef6\uff0c\u901a\u8fc7Redis\u53ef\u4ee5\u5c06\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u7f13\u5b58\u5230\u5185\u5b58\u4e2d\uff0c\u5f53\u670d\u52a1\u7aef\u6709\u6570\u636e\u67e5\u8be2\u8bf7\u6c42\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u76f4\u63a5\u4ece\u5185\u5b58\u4e2d\u83b7\u53d6\u6570\u636e\u3002\u5982\u6b64\uff0c\u4e00\u65b9\u9762\u670d\u52a1\u7aef\u53ef\u4ee5\u83b7\u5f97\u6bd4\u8f83\u5feb\u7684\u6570\u636e\u8bf7\u6c42\u54cd\u5e94\uff0c\u53e6\u4e00\u65b9\u9762\u964d\u4f4e\u4e86\u540e\u7aef\u5173\u7cfb\u6570\u636e\u5e93\u7684\u4e1a\u52a1\u8bf7\u6c42\u538b\u529b\u3002\u4f46\u662f\u6b63\u6240\u8c13\u5c3a\u6709\u6240\u77ed\uff0c\u5bf8\u6709\u6240\u957f\uff0cRedis\u6700\u5927\u7684\u4f18\u52bf\u5c31\u662f\u5185\u5b58\u6570\u636e\u4e5f\u662f\u6700\u5927\u7684\u52a3\u52bf\uff0c\u56e0\u4e3a\u4e00\u65e6\u670d\u52a1\u5668\u5b95\u673a\u6216\u8005\u670d\u52a1\u5668\u91cd\u542f\uff0c\u5185\u5b58\u4e2d\u7f13\u5b58\u7684\u6570\u636e\u4e5f\u4f1a\u4e22\u5931\u3002\u9488\u5bf9\u8fd9\u6837\u7684\u573a\u666f\uff0cRedis\u63d0\u4f9b\u4e86\u4e09\u79cd\u6570\u636e\u6301\u4e45\u5316\u673a\u5236\uff0c\u5206\u522b\u662fAOF\u3001RDB\u4ee5\u53ca\u6df7\u5408\u6301\u4e45\u5316\u6765\u5e94\u5bf9\u8fd9\u79cd\u5f02\u5e38\u60c5\u51b5\u3002\u672c\u6587\u4e3b\u8981\u4eceRedis\u5b9e\u73b0\u6301\u4e45\u5316\u9047\u5230\u7684\u95ee\u9898\u51fa\u53d1\uff0c\u7ad9\u5728\u8bbe\u8ba1\u8005\u7684\u89d2\u5ea6\u601d\u8003\u76f8\u5173\u95ee\u9898\u7684\u89e3\u51b3\u601d\u8def\u3002<\/em><\/span><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230129\/167495490263d5c896c0d81.png\" style=\"max-width:100%\" class=\"aligncenter\"><br \/>\n<em>\u200b<\/em> <\/p>\n<h2><span style=\"color: #515151\">AOF\u6301\u4e45\u5316<\/span><\/h2>\n<p><span style=\"font-size: 14px\"><em>AOF\u6301\u4e45\u5316\u65b9\u5f0f\uff0c\u5373Append Only File\uff0cRedis\u901a\u8fc7\u8bb0\u5f55\u6267\u884c\u4fee\u6539\u64cd\u4f5c\u547d\u4ee4\u8fd9\u79cd\u8bb0\u5c0f\u672c\u672c\u7684\u65b9\u5f0f\u8fdb\u884c\u5185\u5b58\u6570\u636e\u6301\u4e45\u5316\u3002\u5f53\u9700\u8981\u901a\u8fc7AOF\u65e5\u5fd7\u8fdb\u884c\u6062\u590d\u6570\u636e\u65f6\uff0cRedis\u670d\u52a1\u7aef\u542f\u52a8\u540e\u53ef\u4ee5\u4ece\u65e5\u5fd7\u6587\u4ef6\u4e2d\u56de\u653e\u6267\u884c\u547d\u4ee4\u6765\u5b9e\u73b0\u5185\u5b58\u6570\u636e\u6062\u590d\u3002\u5f53\u7136\u4e86\uff0cAOF\u65e5\u5fd7\u4e2d\u8bb0\u5f55\u7684\u90fd\u662f\u4fee\u6539\u7684\u547d\u4ee4\uff0c\u67e5\u8be2\u547d\u4ee4\u4e0d\u4f1a\u4fee\u6539\u6570\u636e\u6240\u4ee5\u4e0d\u9700\u8981\u8fdb\u884c\u8bb0\u5f55\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\u53ef\u80fd\u5927\u5bb6\u90fd\u6bd4\u8f83\u719f\u6089WAL(Write Ahead Log)\uff0c\u5373\u65e5\u5fd7\u9884\u5199\u673a\u5236\uff0c\u5b83\u662f\u6570\u636e\u5e93\u975e\u5e38\u5e38\u7528\u7684\u786e\u4fdd\u6570\u636e\u64cd\u4f5c\u539f\u5b50\u6027\u4ee5\u53ca\u6301\u4e45\u6027\u7684\u6280\u672f\u624b\u6bb5\u3002\u62ffMysql\u4e3e\u6817\u5b50\uff0cMysql\u7684WAL\u4f53\u73b0\u5728undo log\u4ee5\u53caredo log\u7b49\u8fd9\u4e9b\u65e5\u5fd7\u6587\u4ef6\u4e2d\uff0c\u6570\u636e\u5e93\u5728\u6267\u884c\u4fee\u6539\u64cd\u4f5c\u7684\u65f6\u5019\u5e76\u4e0d\u662f\u7acb\u523b\u5c06\u6570\u636e\u66f4\u65b0\u5230\u78c1\u76d8\u4e0a\uff0c\u800c\u662f\u5148\u8bb0\u5f55\u5728\u65e5\u5fd7\u4e2d\uff0c\u4e3b\u8981\u76ee\u7684\u662f\u5982\u679c\u51fa\u73b0\u5f02\u5e38\uff0c\u53ef\u4ee5\u76f4\u63a5\u4eceredo log\u4e2d\u8fdb\u884c\u6570\u636e\u6062\u590d\uff0c\u4e5f\u5c31\u662f\u8bf4\u8ba9Mysql\u77e5\u9053\u4e0a\u6b21\u610f\u5916\u53d1\u751f\u7684\u65f6\u5019\u64cd\u4f5c\u5230\u5e95\u6709\u6ca1\u6709\u6210\u529f\uff0c\u53e6\u5916\u8fd8\u53ef\u4ee5\u5c06Mysql\u7684\u968f\u673a\u5199\u8f6c\u6362\u4e3a\u987a\u5e8f\u5199\uff0c\u63d0\u5347IO\u6027\u80fd\u3002\u4f46\u662fAOF\u5374\u4e0d\u540c\uff0c\u5b83\u662f\u5728Redis\u5c06\u6570\u636e\u5199\u5165\u5185\u5b58\u4e4b\u540e\uff0c\u518d\u5c06\u76f8\u5173\u7684\u64cd\u4f5c\u547d\u4ee4\u5199\u5165AOF\u6587\u4ef6\u4e2d\u3002<\/em><\/span><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230129\/167495490363d5c897228c3.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<p><span style=\"font-size: 14px\"><em>\u90a3\u4e48\u95ee\u9898\u6765\u4e86\uff0c\u4e3a\u4ec0\u4e48Redis\u8981\u91c7\u53d6\u8fd9\u79cd\u72ec\u7279\u7684\u6570\u636e\u8bb0\u5f55\u65b9\u5f0f\uff0c\u800c\u4e0d\u662f\u4e1a\u754c\u5e38\u7528\u7684WAL\u7684\u65b9\u5f0f\u5462\uff1f\u5176\u5b9e\u53ef\u4ee5\u4ece\u4ee5\u4e0b\u4e24\u4e2a\u5c42\u9762\u601d\u8003\u539f\u56e0\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\uff081\uff09AOF\u6587\u4ef6\u4e2d\u4fdd\u5b58\u4e86\u6267\u884c\u7f13\u5b58\u7684\u547d\u4ee4\uff0c\u4ee5\u4fbf\u4e8e\u4fdd\u8bc1\u5728\u9700\u8981\u6062\u590d\u6570\u636e\u7684\u65f6\u5019\u53ef\u4ee5\u8fdb\u884c\u547d\u4ee4\u91cd\u653e\u6062\u590d\u6570\u636e\uff0c\u56e0\u6b64\u9700\u8981\u4fdd\u8bc1\u6267\u884c\u547d\u4ee4\u7684\u5408\u6cd5\u6027\uff0c\u800c\u901a\u8fc7\u5148\u7f13\u5b58\u6570\u636e\u518d\u8fdb\u884c\u547d\u4ee4\u8ffd\u52a0\u65e5\u5fd7\u7684\u65b9\u5f0f\u53ef\u4ee5\u786e\u4fdd\u8ffd\u52a0\u5230AOF\u6587\u4ef6\u4e2d\u7684\u7684\u547d\u4ee4\u90fd\u662f\u5408\u6cd5\u6709\u6548\u7684\uff0credis\u5728\u6062\u590d\u6570\u636e\u7684\u65f6\u5019\u4e0d\u9700\u8981\u518d\u53bb\u68c0\u67e5\u547d\u4ee4\u662f\u5426\u6709\u6548\uff0c\u8fdb\u4e00\u6b65\u63d0\u5347\u5185\u5b58\u6570\u636e\u6062\u590d\u7684\u6548\u7387\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\uff082\uff09\u53e6\u5916\u7531\u4e8e\u662f\u5728\u4fee\u6539\u64cd\u4f5c\u547d\u4ee4\u4e4b\u540e\u8fdb\u884c\u65e5\u5fd7\u8bb0\u5f55\uff0c\u65e5\u5fd7\u8bb0\u5f55\u7684\u65f6\u5019\u9700\u8981\u8fdb\u884c\u78c1\u76d8IO\u64cd\u4f5c\uff0c\u56e0\u6b64\u4e0d\u4f1a\u963b\u585e\u5f53\u524d\u7684\u4fee\u6539\u547d\u4ee4\u3002<\/em><\/span><\/p>\n<h3><span style=\"color: #515151\">AOF\u6587\u4ef6\u5185\u5bb9\u662f\u4ec0\u4e48\uff1f<\/span><\/h3>\n<p><span style=\"font-size: 14px\"><em>\u5728\u641e\u6e05\u695aRedis\u4e3a\u4ec0\u4e48\u91c7\u7528AOF\u6587\u4ef6\u8bb0\u5f55\u4fee\u6539\u547d\u4ee4\u4e4b\u540e\uff0c\u6211\u4eec\u518d\u6765\u770b\u770bAOF\u6587\u4ef6\u4e2d\u5230\u5e95\u5305\u542b\u4e86\u54ea\u4e9b\u5185\u5bb9\u3002<\/em><\/span><\/p>\n<\/p>\n<p>redis&gt; SET mufeng handsome<br \/>OK<\/p>\n<p><span style=\"font-size: 14px\"><em>Redis\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u7aef\u4e4b\u95f4\u91c7\u7528RESP\u534f\u8bae\u8fdb\u884c\u901a\u4fe1\uff0c\u5b83\u662f\u4e00\u79cd\u5e94\u7528\u5c42\u534f\u8bae\uff0c\u5bf9\u4e8eRedis\u8fd9\u79cd\u4ee5\u6548\u7387\u4e3a\u8ffd\u6c42\u76ee\u6807\u7684\u4e2d\u95f4\u4ef6\uff0c\u901a\u4fe1\u534f\u8bae\u5fc5\u5b9a\u8981\u7b80\u5355\u9ad8\u6548\u3002\u5c31\u4e0a\u9762\u4e00\u6761\u7f13\u5b58\u64cd\u4f5c\u547d\u4ee4\u6765\u8bf4\uff1aset mufeng handsome \u5bf9\u5e94\u7684RESP\u62a5\u6587\u5c31\u662f*3$3set$6mufeng$8handsome\uff0c\u4e3a\u4e86\u65b9\u4fbf\u67e5\u770b\u8fdb\u884c\u4e86\u624b\u52a8\u6362\u884c\u3002<\/em><\/span><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230129\/167495490363d5c897760b5.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<p><span style=\"font-size: 14px\"><em>\u6211\u4eec\u6765\u62c6\u89e3\u4e0b\u62a5\u6587\u4e2d\u5404\u4e2a\u5c5e\u6027\u7684\u542b\u4e49\uff0c\u201c*3\u201d\u4ee3\u8868\u672c\u6b21\u64cd\u4f5c\u547d\u4ee4\u5c06\u7531\u4e09\u4e2a\u5206\u5e03\u7ec4\u6210\uff0c\u6bcf\u4e00\u90e8\u5206\u90fd\u662f\u901a\u8fc7&#8221;$\u6570\u5b57&#8221;\u7684\u5f62\u5f0f\u4f5c\u4e3a\u8d77\u59cb\uff0c\u540e\u9762\u4e3a\u5bf9\u5e94\u7684\u547d\u4ee4\u3001\u952e\u6216\u8005\u503c\u3002\u5982\u6b64\u5904\u7684&#8221;$6&#8243;\u5c31\u8868\u793a\u540e\u9762\u7684\u547d\u4ee4\u662f\u4e00\u4e2a6\u4e2a\u5b57\u8282\u7684\u952e\u503c\u3002\u6240\u4ee5\uff0cappenonly.aof\u6587\u4ef6\u4e2d\u5b9e\u9645\u4fdd\u5b58\u7684\u5c31\u662f\u8fd9\u79cd\u683c\u5f0f\u7684\u5185\u5bb9\u3002<\/em><\/span><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230129\/167495490363d5c897cb79b.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<h3><span style=\"color: #515151\">AOF\u6709\u6ca1\u6709\u4e22\u6570\u636e\u7684\u98ce\u9669\uff1f<\/span><\/h3>\n<p><span style=\"font-size: 14px\"><em>\u4e0a\u6587\u8bf4\u5230Redis\u901a\u8fc7AOF\u6587\u4ef6\u5b9e\u73b0\u5185\u5b58\u6570\u636e\u6301\u4e45\u5316\uff0c\u90a3\u4e48\u662f\u4e0d\u662f\u5c31\u4ee3\u8868\u7f13\u5b58\u6570\u636e\u4fdd\u5b58\u5c31\u4e07\u65e0\u4e00\u5931\u4e86\uff1f\u8fd9\u6837\u7684\u6301\u4e45\u5316\u65b9\u5f0f\u8fd8\u6709\u6ca1\u6709\u6570\u636e\u4e22\u5931\u7684\u98ce\u9669\u5462\uff1f\u5927\u5bb6\u53ef\u4ee5\u8bbe\u60f3\u4e00\u4e0b\u5047\u8bbe\u5728\u64cd\u4f5c\u5b8cRedis\u4e4b\u540e\uff0c\u8fd8\u6ca1\u6765\u5f97\u53ca\u5c06\u547d\u4ee4\u5199\u5165AOF\u6587\u4ef6\u5c31\u5b95\u673a\u4e86\uff0c\u90a3\u4e48\u8fd9\u4e2a\u64cd\u4f5c\u547d\u4ee4\u5c31\u4f1a\u4e22\u5931\uff0c\u5bf9\u5e94\u7684\u7f13\u5b58\u6570\u636e\u6700\u65b0\u503c\u4e5f\u4f1a\u4e22\u5931\u3002\u56e0\u4e3a\u5373\u4fbf\u5b95\u673a\u5f02\u5e38\u6062\u590d\u4e4b\u540e\uff0c\u4e5f\u6ca1\u529e\u6cd5\u4eceAOF\u6587\u4ef6\u4e2d\u6267\u884c\u4e22\u5931\u7684\u64cd\u4f5c\u547d\u4ee4\u4e86\u3002\u56e0\u6b64\uff0c\u5199\u5165AOF\u7f13\u51b2\u533a\u7684\u6570\u636e\u4ec0\u4e48\u65f6\u5019\u8fdb\u884c\u6301\u4e45\u5316\u843d\u76d8\uff0c\u76f4\u63a5\u51b3\u5b9a\u7740AOF\u6301\u4e45\u5316\u65b9\u5f0f\u7f13\u5b58\u6570\u636e\u4e22\u5931\u7684\u98ce\u9669\u5927\u5c0f\u3002<\/em><\/span><\/p>\n<h3><em>\u4e09\u79cdAOF\u843d\u76d8\u7b56\u7565<\/em><\/h3>\n<p><span style=\"font-size: 14px\"><em>\u9488\u5bf9AOF\u7f13\u5b58\u4e2d\u7684\u6570\u636e\u5728\u4ec0\u4e48\u65f6\u673a\u5199\u5165\u78c1\u76d8\uff0cRedis\u63d0\u4f9b\u4e86\u4e09\u79cdAOF\u65e5\u5fd7\u5199\u5165\u7b56\u7565\u4f9b\u7528\u6237\u8fdb\u884c\u9009\u62e9\uff0c\u901a\u8fc7\u540e\u53f0\u7ebf\u7a0b\u6267\u884c\u4e0d\u540c\u65f6\u673a\u7684AOF\u6587\u4ef6\u6570\u636e\u540c\u6b65\u64cd\u4f5c\uff0c\u5728redis.conf\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684\u914d\u7f6e\u9879appendfsync\u53ef\u4ee5\u8fdb\u884c\u914d\u7f6e\u3002<\/em><\/span><\/p>\n<h4><em>\u3010appendfsync:no\u3011<\/em><em>\u200b<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>Redis\u4e0d\u7528\u7ba1AOF\u7f13\u51b2\u533a\u7684\u6570\u636e\u4ec0\u4e48\u65f6\u5019\u5199\u5165\u78c1\u76d8\uff0c\u5c06AOF\u7f13\u51b2\u533a\u540c\u6b65\u6570\u636e\u7684\u64cd\u4f5c\u6743\u4ea4\u7ed9\u64cd\u4f5c\u7cfb\u7edf\uff0c\u64cd\u4f5c\u7cfb\u7edf\u51b3\u5b9a\u4ec0\u4e48\u65f6\u5019\u5c06\u7f13\u51b2\u533a\u7684\u6570\u636e\u5199\u5165\u78c1\u76d8\u4e2d\u3002<\/em><\/span><\/p>\n<h4><em>\u3010appendfsync:everysec\u3011<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>\u5f53Redis\u5c06\u6570\u636e\u5199\u5165AOF\u7f13\u51b2\u533a\u540e\uff0c\u6bcf\u96941s\u5c06\u7f13\u51b2\u533a\u7684\u6570\u636e\u8fdb\u884c\u78c1\u76d8\u5199\u5165\u3002<\/em><\/span><\/p>\n<h4><em>\u3010appendfsync:always\u3011<\/em><em>\u200b<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>\u6bcf\u6267\u884c\u4e00\u4e2a\u4fee\u6539\u547d\u4ee4\uff0c\u90fd\u9700\u8981\u5c06\u4fee\u6539\u7684\u547d\u4ee4\u8fdb\u884c\u843d\u76d8\u64cd\u4f5c\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\u867d\u7136Redis\u63d0\u4f9b\u4e86\u8fd9\u4e09\u79cdAOF\u65e5\u5fd7\u843d\u76d8\u7b56\u7565\u4f9b\u7528\u6237\u8fdb\u884c\u9009\u62e9\uff0c\u4f46\u662f\u8fd9\u4e09\u79cd\u7b56\u7565\u5b9e\u9645\u4e0a\u5404\u6709\u4f18\u7f3a\u70b9\u3002<\/em><\/span><\/p>\n<h4><em>\u3010appendfsync:no\u3011<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>\u5982\u679c\u8bbe\u7f6e\u4e86\u7531\u64cd\u4f5c\u7cfb\u7edf\u8fdb\u884cAOF\u7f13\u51b2\u533a\u6570\u636e\u5199\u5165\uff0c\u90a3\u4e48\u5c31\u76f8\u5f53\u4e8e\u5199\u6570\u636e\u7684\u65f6\u673a\u5b8c\u5168\u4ea4\u7531\u64cd\u4f5c\u7cfb\u7edf\u6765\u51b3\u5b9a\uff0c\u6b64\u65f6redis\u5bf9\u4e8e\u7f13\u51b2\u533a\u6570\u636e\u5e76\u4e0d\u53ef\u4ee5\u63a7\u5236\u3002<\/em><\/span><\/p>\n<h4><em>\u3010appendfsync:everysec\u3011<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>\u5982\u679c\u8bbe\u7f6e\u6210\u6bcf\u9694\u4e00\u79d2\u8fdb\u884c\u7f13\u5b58\u6570\u636e\u5199\u5165\uff0c\u867d\u7136\u4e0d\u4f1a\u50cf\u540c\u6b65\u5199\u5165\u90a3\u6837\u5b58\u5728\u4e00\u5b9a\u7684\u6027\u80fd\u6d88\u8017\uff0c\u4f46\u662f\u7531\u4e8e\u5b58\u5728\u4e00\u79d2\u7684\u65f6\u95f4\u95f4\u9694\uff0c\u5982\u679c\u5728\u6b64\u671f\u95f4\u51fa\u73b0\u670d\u52a1\u5668\u5b95\u673a\uff0c\u90a3\u4e48\u5c31\u4f1a\u635f\u5931\u8fd9\u4e00\u79d2\u7684\u7f13\u5b58\u6570\u636e\u3002<\/em><\/span><\/p>\n<h4><em>\u3010appendfsync:always\u3011<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>\u867d\u7136\u53ef\u4ee5\u57fa\u672c\u5b9e\u73b0\u6570\u636e\u4e0d\u4e22\u5931\uff0c\u4f46\u662f\u7531\u4e8e\u6bcf\u6b21\u8fdb\u884c\u5185\u5b58\u6570\u636e\u4fee\u6539\u90fd\u8981\u8fdb\u884c\u843d\u76d8\u64cd\u4f5c\uff0c\u56e0\u6b64\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u4f1a\u5f71\u54cd\u4e3b\u7ebf\u7a0b\u6027\u80fd\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\u5177\u4f53\u91c7\u53d6\u600e\u6837\u7684\u914d\u7f6e\u7b56\u7565\u8fd8\u662f\u8981\u6839\u636e\u5b9e\u9645\u7684\u4e1a\u52a1\u573a\u666f\u6765\u51b3\u5b9a\uff0c\u4e00\u822c\u63a8\u8350\u4f7f\u7528\u7b2c\u4e8c\u79cd\u914d\u7f6e\u7b56\u7565\u3010appendfsync:everysec\u3011\uff0c\u5728\u53ef\u9760\u6027\u4ee5\u53ca\u6027\u80fd\u65b9\u9762\u76f8\u5bf9\u5e73\u8861\u4e00\u70b9\u3002<\/em><\/span><\/p>\n<h3><span style=\"color: #515151\">AOF\u6587\u4ef6\u4f1a\u8d8a\u6765\u8d8a\u5927\u5417\uff1f<\/span><\/h3>\n<p><span style=\"font-size: 14px\"><em>\u5728\u4e86\u89e3\u4e86AOF\u65e5\u5fd7\u78c1\u76d8\u5199\u5165\u65f6\u673a\u4e4b\u540e\uff0c\u6211\u4eec\u7ee7\u7eed\u6765\u601d\u8003\u4e0b\u4e00\u4e2a\u95ee\u9898\u3002\u65e0\u8bba\u91c7\u53d6\u4ec0\u4e48\u6837\u7684\u540c\u6b65\u6570\u636e\u7b56\u7565\uff0c\u6700\u7ec8\u90fd\u662f\u8981\u5c06\u4fee\u6539\u547d\u4ee4\u5199\u5165AOF\u6587\u4ef6\u4e2d\uff0c\u56e0\u6b64\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\uff0c\u8fd9\u4e2a\u6587\u4ef6\u5fc5\u5b9a\u4f1a\u8d8a\u6765\u8d8a\u5927\u3002\u90a3\u4e48\u5982\u679c\u6587\u4ef6\u53d8\u5f97\u5f88\u5927\u4e4b\u540e\uff0c\u65e0\u8bba\u662f\u6587\u4ef6\u6570\u636e\u65b0\u5199\u5165\u8fd8\u662fRedis\u901a\u8fc7AOF\u6587\u4ef6\u8fdb\u884c\u6570\u636e\u6062\u590d\uff0c\u5927\u6587\u4ef6\u7684\u64cd\u4f5c\u90fd\u4f1a\u9020\u6210IO\u6027\u80fd\u635f\u8017\u3002\u5047\u5982\u4f60\u662fRedis\u7684\u8bbe\u8ba1\u8005\uff0c\u5982\u679c\u9047\u5230\u8fd9\u79cd\u60c5\u51b5\u4f60\u4f1a\u600e\u4e48\u8fdb\u884c\u8bbe\u8ba1\u4f18\u5316\u5462\uff1f\u6211\u60f3\u65e0\u975e\u6709\u4e24\u4e2a\u4f18\u5316\u601d\u8def\uff0c\u4e00\u4e2a\u662f\u5316\u6574\u4e3a\u96f6\uff0c\u4e00\u4e2a\u662f\u60f3\u529e\u6cd5\u7f29\u5c0f\u5927\u6587\u4ef6\u3002<\/em><\/span><\/p>\n<h3><em>\u5316\u6574\u4e3a\u96f6<\/em><\/h3>\n<p><span style=\"font-size: 14px\"><em>\u5f53\u5355\u4e2a\u6587\u4ef6\u8fc7\u5927\u65f6\uff0c\u6211\u4eec\u5f88\u5bb9\u6613\u60f3\u5230\u7684\u4f18\u5316\u65b9\u6cd5\u5c31\u662f\u5c06\u8fd9\u4e2a\u5927\u6587\u4ef6\u62c6\u5206\u4e3a\u82e5\u5e72\u4e2a\u5c0f\u6587\u4ef6\u3002\u8fd9\u5c31\u597d\u6bd4\u7cfb\u7edf\u4e2d\u4e00\u65e6\u51fa\u73b0\u8fc7\u5343\u4e07\u6570\u636e\u5e93\u8868\u7684\u65f6\u5019\uff0c\u6211\u4eec\u5c31\u8981\u7ed3\u5408\u5b9e\u9645\u7684\u4e1a\u52a1\u573a\u666f\u8003\u8651\u8981\u4e0d\u8981\u8fdb\u884c\u5206\u5e93\u5206\u8868\u4e86\u3002\u6240\u4ee5\u5982\u679c\u5355\u4e2aAOF\u6587\u4ef6\u592a\u5927\uff0c\u90a3\u4e48\u662f\u4e0d\u662f\u53ef\u4ee5\u8003\u8651\u5c06\u5176\u6309\u7167\u56fa\u5b9a\u5927\u5c0f\u8fdb\u884c\u62c6\u5206\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u5355\u4e2aAOF\u6587\u4ef6\u8fc7\u5927\u7684\u95ee\u9898\u3002\u90a3\u4e48Redis\u5c0f\u4e8e7.0\u7248\u672c\u4e3a\u4ec0\u4e48\u6ca1\u6709\u91c7\u7528\u8fd9\u79cd\u65b9\u6848\u5462\uff1f\u4e3b\u8981\u662f\u8fd9\u79cd\u65b9\u6848\u5e76\u4e0d\u7b26\u5408Redis\u8ffd\u6c42\u7b80\u5355\u9ad8\u6548\u7684\u8bbe\u8ba1\u601d\u60f3\u3002\u5047\u8bbe\u91c7\u7528\u4e86\u8fd9\u79cd\u6570\u636e\u5206\u5757\u7684\u65b9\u5f0f\uff0c\u90a3\u5fc5\u5b9a\u9700\u8981\u5b9e\u73b0\u6587\u4ef6\u5927\u5c0f\u68c0\u6d4b\u3001\u6587\u4ef6\u521b\u5efa\u3001\u6587\u4ef6\u7d22\u5f15\u7ef4\u62a4\u7b49\u7b49\u4e00\u7cfb\u5217\u6280\u672f\u7ec6\u8282\u95ee\u9898\uff0c\u5bf9\u4e8e\u4f4e\u7248\u672c\u7684Redis\u6765\u8bf4\u8fd9\u4e9b\u90fd\u592a\u7e41\u7410\u4e86\uff0c\u8fd8\u4e0d\u5982\u4e00\u4e2aAOF\u6587\u4ef6\u6765\u7684\u723d\u5feb\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><strong><em>PS\uff1a<\/em><\/strong><\/span><span style=\"font-size: 14px\"><em>\u5728\u6700\u65b0\u7684Redis 7.0\u7248\u672c\u4e2d\uff0cRedis\u5df2\u7ecf\u652f\u6301\u591aAOF\u6587\u4ef6\u5206\u7247\u673a\u5236\uff0c\u539f\u59cb\u7684\u5355\u4e2aAOF\u6587\u4ef6\u4f1a\u88ab\u62c6\u5206\u4e3a\u4e00\u4e2a\u57fa\u7840\u6587\u4ef6\u4ee5\u53ca\u591a\u4e2a\u589e\u91cf\u6587\u4ef6\u3002\u65b0\u7248\u672c\u4e2d\u4e4b\u6240\u4ee5\u5f00\u59cb\u652f\u6301\u591a\u6587\u4ef6\u5b58\u50a8\uff0c\u6211\u60f3\u4e5f\u662f\u968f\u7740\u4e1a\u52a1\u53d1\u5c55\u5185\u5b58\u6570\u636e\u53ef\u80fd\u4f1a\u5f88\u5e9e\u5927\uff0cRedis\u8bbe\u8ba1\u8005\u53d1\u73b0\u5982\u679c\u8fd8\u662f\u4f7f\u7528\u5355\u6587\u4ef6\u5b58\u50a8\uff0c\u5927AOF\u6587\u4ef6\u64cd\u4f5c\u4ee5\u53ca\u6570\u636e\u6062\u590d\u90fd\u662f\u4e00\u4e2a\u6311\u6218\u3002<\/em><\/span><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230129\/167495490463d5c89880b69.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<h3><em>AOF\u91cd\u5199<\/em><\/h3>\n<p><span style=\"font-size: 14px\"><em>\u65e2\u7136\u8fdb\u884c\u6587\u4ef6\u5207\u5272\u592a\u7e41\u7410\u4e86\uff0c\u90a3\u4e48\u5c31\u5355\u4e2aAOF\u6587\u4ef6\u6765\u8bf4\u600e\u4e48\u624d\u80fd\u51cf\u5c0f\u6587\u4ef6\u5927\u5c0f\u5462\uff1f\u90a3\u5c31\u8981\u4eceAOF\u6587\u4ef6\u7684\u8bb0\u5f55\u5185\u5bb9\u5165\u624b\uff0c\u901a\u8fc7\u4e0a\u6587\u6211\u4eec\u4e86\u89e3\u5230AOF\u6587\u4ef6\u4e2d\u5b9e\u9645\u5b58\u50a8\u4e86\u4fee\u6539\u5185\u5b58\u6570\u636e\u7684\u64cd\u4f5c\u547d\u4ee4\uff0c\u56e0\u6b64\u6211\u4eec\u5728\u5206\u6790\u5b8c\u8fd9\u4e9b\u64cd\u4f5c\u547d\u4ee4\u4e4b\u540e\u53d1\u73b0\uff0c\u5f53\u591a\u6761\u547d\u4ee4\u64cd\u4f5c\u540c\u4e00\u4e2akey\u7684\u65f6\u5019\uff0c\u5b9e\u9645\u6211\u4eec\u9700\u8981\u7684\u662f\u6700\u65b0\u7684\u4e00\u6761\u64cd\u4f5c\u547d\u4ee4\uff0c\u9664\u6b64\u4e4b\u5916\u7684\u5386\u53f2\u64cd\u4f5c\u547d\u4ee4\u6211\u4eec\u5e76\u4e0d\u9700\u8981\u5173\u5fc3\u3002\u6bd4\u5982\u3010set mufeng handsome\u3011\u3001\u3010set mufeng cool\u3011\uff0c\u5982\u679c\u5148\u540e\u6267\u884c\u4e86\u8fd9\u4e24\u4e2a\u547d\u4ee4\uff0c\u90a3\u4e48\u5728\u6700\u7ec8\u6062\u590d\u6570\u636e\u7684\u65f6\u5019\uff0c\u53ea\u8981\u6062\u590d\u3010set mufeng cool\u3011\u5373\u53ef\u3002\u56e0\u6b64AOF\u91cd\u5199\u7684\u672c\u8d28\u5c31\u662f\u5408\u5e76\u547d\u4ee4\uff0c\u4e5f\u5c31\u662f\u8bf4\u5c06\u591a\u6761\u5bf9\u540c\u4e00key\u8fdb\u884c\u64cd\u4f5c\u7684\u547d\u4ee4\u8fdb\u884c\u5408\u5e76\uff0c\u5b9e\u9645\u5c31\u662f\u4f7f\u7528\u6700\u65b0\u7684key\u503c\u64cd\u4f5c\u547d\u4ee4\u6765\u4ee3\u66ff\u4e4b\u524d\u6240\u6709\u5173\u4e8e\u8fd9\u4e2akey\u503c\u7684\u547d\u4ee4\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>Redis\u901a\u8fc7fork\u5b50\u8fdb\u7a0b\u6765\u5b8c\u6210AOF\u6587\u4ef6\u91cd\u5199\uff0c\u56e0\u6b64\u5728\u8bb2AOF\u91cd\u5199\u8fc7\u7a0b\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u4e86\u89e3\u4e0b\u4ec0\u4e48\u662ffork\u5b50\u8fdb\u7a0b\u7684\u539f\u7406\uff0c\u8fd9\u6837\u66f4\u52a0\u6709\u5229\u4e8e\u6211\u4eec\u540e\u9762\u4e86\u89e3AOF\u6587\u4ef6\u91cd\u5199\u7684\u8fc7\u7a0b\u3002<\/em><\/span><\/p>\n<h4><em>\u4ec0\u4e48\u662ffork\uff1f<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>fork\u51fd\u6570\u662flinux\u5185\u6838\u63d0\u4f9b\u7ed9\u7528\u6237\u521b\u5efa\u8fdb\u7a0b\u7684API\uff0c\u5e94\u7528\u7a0b\u5e8f\u901a\u8fc7\u8c03\u7528fork\u51fd\u6570\u521b\u5efa\u5b50\u8fdb\u7a0b\uff0c\u8fd9\u4e2a\u5b50\u8fdb\u7a0b\u53ef\u4ee5\u548c\u539f\u6765\u7236\u8fdb\u7a0b\u5e72\u540c\u6837\u7684\u4e8b\u60c5\uff0c\u4e5f\u53ef\u4ee5\u548c\u539f\u6765\u4e3b\u8fdb\u7a0b\u5e72\u4e0d\u540c\u7684\u4e8b\u60c5\uff0c\u8fd9\u4e3b\u8981\u53d6\u51b3\u4e8e\u5bf9\u5e94\u7684\u53c2\u6570\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u5c31\u597d\u6bd4\u5b59\u609f\u7a7a\u62d4\u4e86\u4e00\u6839\u81ea\u5df1\u7684\u7334\u6bdb\u53d8\u51fa\u6765\u4e00\u4e2a\u548c\u81ea\u5df1\u4e00\u6a21\u4e00\u6837\u7684\u5b59\u609f\u7a7a\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\u56e0\u6b64\u5728fork\u5b50\u8fdb\u7a0b\u7684\u8fc7\u7a0b\u4e4b\u4e2d\uff0c\u5b50\u8fdb\u7a0b\u590d\u5236\u4e86\u7236\u8fdb\u7a0b\u7684\u4ee3\u7801\u6bb5\u3001\u6570\u636e\u6bb5\u3001\u5806\u6808\u3001\u9875\u8868\u7b49\uff0c\u540c\u65f6\u5b50\u8fdb\u7a0b\u62e5\u6709\u72ec\u7acb\u7684\u865a\u62df\u5185\u5b58\u7a7a\u95f4\uff08\u5f53\u7136\u662f\u4ece\u7236\u8fdb\u7a0b\u90a3\u91cc\u590d\u5236\u8fc7\u6765\u7684\uff09\u3002\u5982\u4e0b\u6240\u793a\uff0c\u5b9e\u9645\u4e0afork()\u6700\u7ec8\u8c03\u7528\u7684\u662f\u5185\u6838copy_process\u65b9\u6cd5\u590d\u5236\u8fdb\u7a0b\u3002<\/em><\/span><em>\u200b<\/em><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230129\/167495490463d5c898c6ba2.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<p><span style=\"font-size: 14px\"><em>\u7236\u8fdb\u7a0bfork\u5b50\u8fdb\u7a0b\u7684\u65f6\u5019\uff0c\u5b50\u8fdb\u7a0b\u62e5\u6709\u72ec\u7acb\u7684\u865a\u62df\u5185\u5b58\u7a7a\u95f4\uff0c\u90a3\u4e48\u5bf9\u5e94\u7684\u7269\u7406\u5185\u5b58\u7a7a\u95f4\u662f\u4e0d\u662f\u4e5f\u662f\u72ec\u7acb\u7684\u5462\uff1f\u6211\u4eec\u90fd\u77e5\u9053\u5728\u8ba1\u7b97\u673a\u4e2d\uff0c\u5185\u5b58\u5c5e\u4e8e\u975e\u5e38\u5b9d\u8d35\u7684\u7cfb\u7edf\u8d44\u6e90\uff0c\u6240\u4ee5\u5927\u4f6c\u4eec\u5728\u8bbe\u8ba1\u7684\u65f6\u5019\u90fd\u5c3d\u53ef\u80fd\u7684\u51cf\u5c11\u5185\u5b58\u7a7a\u95f4\u5360\u7528\u4ece\u800c\u63d0\u9ad8\u7cfb\u7edf\u8d44\u6e90\u5229\u7528\u7387\u3002fork\u5b50\u8fdb\u7a0b\u8fc7\u7a0b\u4e2d\u7528\u5230\u7684Copy-On-Write\u5c31\u662f\u5178\u578b\u7684\u5185\u5b58\u8d44\u6e90\u7ba1\u7406\u4f18\u5316\u673a\u5236\uff0c\u5982\u679c\u5b50\u8fdb\u7a0b\u53ea\u662f\u8bfb\u53d6\u6570\u636e\u4e0d\u8fdb\u884c\u4efb\u4f55\u7684\u6570\u636e\u5199\u5165\uff0c\u90a3\u4e48\u5c31\u548c\u7236\u8fdb\u7a0b\u516c\u7528\u5185\u5b58\u7a7a\u95f4\u3002\u5f53\u5b50\u8fdb\u7a0b\u9700\u8981\u8fdb\u884c\u6570\u636e\u5199\u5165\u7684\u65f6\u5019\uff0c\u53d1\u73b0\u6ca1\u6709\u5185\u63a7\u7a7a\u95f4\u53ef\u4ee5\u5199\u5165\uff0c\u6b64\u65f6\u4f1a\u89e6\u53d1\u4e00\u4e2a\u7cfb\u7edf\u4e2d\u65ad\u6765\u5206\u914d\u5185\u5b58\u7a7a\u95f4\u7ed9\u5b50\u8fdb\u7a0b\u8fdb\u884c\u6570\u636e\u5199\u5165\u3002<\/em><\/span><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230129\/167495490563d5c899680e7.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<h3><em>\u4ec0\u4e48\u65f6\u673a\u89e6\u53d1AOF\u91cd\u5199\uff1f<\/em><\/h3>\n<h4><em>\u6267\u884cbgrewriteaof \u547d\u4ee4<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>\u5f53\u6211\u4eec\u5728\u5ba2\u6237\u7aef\u624b\u52a8\u6267\u884cbgrewriteaof \u547d\u4ee4\u540e\uff0c\u53ef\u4ee5\u89e6\u53d1AOF\u6587\u4ef6\u8fdb\u884c\u91cd\u5199\uff0c\u5bf9\u5e94Redis\u6e90\u7801\u4e2d\u8fdb\u884c\u91cd\u5199\u7684bgrewriteaofCommand \u51fd\u6570\u4f1a\u68c0\u6d4b\u68c0\u6d4b\u662f\u5426\u6ee1\u8db3\u8fdb\u884c\u91cd\u5199\u7684\u6761\u4ef6\uff0c\u4e3b\u8981\u68c0\u6d4b\u4ee5\u4e0b\u4e24\u4e2a\u6761\u4ef6\uff1a<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em><strong>\u3010Condition1\u3011\uff1a<\/strong>\u68c0\u6d4b\u5f53\u524d\u662f\u5426\u5b58\u5728\u5df2\u7ecf\u5728\u6267\u884c\u7684AOF\u91cd\u5199\u5b50\u8fdb\u7a0b\uff0c\u5982\u679c\u5b58\u5728\u7684\u8bddRedis\u5c06\u4e0d\u518d\u6267\u884cAOF\u6587\u4ef6\u91cd\u5199\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em><strong>\u3010Condition2\u3011\uff1a<\/strong>\u68c0\u6d4b\u5f53\u524d\u662f\u5426\u5b58\u5728\u5df2\u7ecf\u5728\u521b\u5efaRDB\u6587\u4ef6\u7684\u5b50\u8fdb\u7a0b\uff0c\u5982\u679c\u5b58\u5728\u7684\u8bddRedis\u5c06AOF\u6587\u4ef6\u91cd\u5199\u4efb\u52a1\u7f6e\u4e3a\u5f85\u8c03\u5ea6\u72b6\u6001\uff0c\u540e\u7eed\u5982\u679c\u6ee1\u8db3\u4e86\u91cd\u5199\u6761\u4ef6\uff0c\u5219\u7ee7\u7eed\u6267\u884cAOF\u6587\u4ef6\u91cd\u5199\u4efb\u52a1\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\u4e5f\u5c31\u662f\u8bf4\uff0cRedis\u68c0\u6d4b\u5230\u5f53\u524d\u65e2\u6ca1\u6709AOF\u91cd\u5199\u5b50\u8fdb\u7a0b\u4e5f\u6ca1\u6709RDB\u6587\u4ef6\u521b\u5efa\u5b50\u8fdb\u7a0b\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u8fdb\u884cAOF\u6587\u4ef6\u91cd\u5199\u3002\u5bf9\u5e94\u6e90\u7801\u5982\u4e0b\uff1a<\/em><\/span><\/p>\n<p><span style=\"color: #d73a49\">\/\/<\/span>of_child_pid<span style=\"color: #997\">(<\/span>aof rewrite\u8fdb\u7a0bpid<span style=\"color: #997\">)<\/span>\u3001rdb_child_pid<span style=\"color: #997\">(<\/span>rdb dump\u8fdb\u7a0bpid<span style=\"color: #997\">)<\/span><br \/>void bgrewriteaofCommand<span style=\"color: #997\">(<\/span>redisClient <span style=\"color: #d73a49\">*<\/span>c<span style=\"color: #997\">)<\/span><span style=\"color: #997\">{<\/span><br \/> if <span style=\"color: #997\">(<\/span>server<span style=\"color: #005cc5\">.aof_child_pid<\/span> <span style=\"color: #d73a49\">!=<\/span> <span style=\"color: #d73a49\">&#8211;<\/span><span style=\"color: #005cc5\">1<\/span><span style=\"color: #997\">)<\/span> <span style=\"color: #997\">{<\/span><br \/><span style=\"color: #d73a49\">\/\/<\/span>\u5982\u679c\u6b63\u5728aof rewrite\uff0c\u8fd4\u56de\u9519\u8bef\u4fe1\u606f<br \/> addReplyError<span style=\"color: #997\">(<\/span>c<span>,<\/span><span style=\"color: #690\">&#8220;Background append only file rewriting already in progress&#8221;<\/span><span style=\"color: #997\">)<\/span><span>;<\/span><br \/><span style=\"color: #997\">}<\/span> else if <span style=\"color: #997\">(<\/span>server<span style=\"color: #005cc5\">.rdb_child_pid<\/span> <span style=\"color: #d73a49\">!=<\/span> <span style=\"color: #d73a49\">&#8211;<\/span><span style=\"color: #005cc5\">1<\/span><span style=\"color: #997\">)<\/span> <span style=\"color: #997\">{<\/span><br \/><span style=\"color: #d73a49\">\/\/<\/span>\u5982\u679c\u6b63\u5728rdb dump\uff0c\u4e3a\u4e86\u907f\u514d\u78c1\u76d8\u538b\u529b\uff0c\u5c06aof\u91cd\u5199\u8ba1\u5212\u72b6\u6001\u7f6e\u4e3a1\uff0c\u540e\u671f\u518d\u8fdb\u884crewrite\uff1b<br \/> server<span style=\"color: #005cc5\">.aof_rewrite_scheduled<\/span> <span style=\"color: #d73a49\">=<\/span> <span style=\"color: #005cc5\">1<\/span><span>;<\/span><br \/> addReplyStatus<span style=\"color: #997\">(<\/span>c<span>,<\/span><span style=\"color: #690\">&#8220;Background append only file rewriting scheduled&#8221;<\/span><span style=\"color: #997\">)<\/span><span>;<\/span><br \/><span style=\"color: #997\">}<\/span><br \/><span style=\"color: #d73a49\">\/\/<\/span>\u5982\u679c\u5f53\u524d\u6ca1\u6709aof rewrite\u548crdb dump\u5728\u8fdb\u884c\uff0c\u5219\u8c03\u7528rewriteAppendOnlyFileBackground\u5f00\u59cbaof rewrite\u3002<br \/> else if <span style=\"color: #997\">(<\/span>rewriteAppendOnlyFileBackground<span style=\"color: #997\">(<\/span><span style=\"color: #997\">)<\/span> <span style=\"color: #d73a49\">==<\/span> REDIS_OK<span style=\"color: #997\">)<\/span> <span style=\"color: #997\">{<\/span><br \/> addReplyStatus<span style=\"color: #997\">(<\/span>c<span>,<\/span><span style=\"color: #690\">&#8220;Background append only file rewriting started&#8221;<\/span><span style=\"color: #997\">)<\/span><span>;<\/span><br \/><span style=\"color: #997\">}<\/span> else <span style=\"color: #997\">{<\/span><br \/><span style=\"color: #d73a49\">\/\/<\/span>\u51fa\u73b0\u5f02\u5e38\u8fd4\u56de\u9519\u8bef\u3002<br \/> addReply<span style=\"color: #997\">(<\/span>c<span>,<\/span>shared<span style=\"color: #005cc5\">.err<\/span><span style=\"color: #997\">)<\/span><span>;<\/span><br \/><span style=\"color: #997\">}<\/span><br \/><span style=\"color: #997\">}<\/span><\/p>\n<h4><em>\u8d85\u51fa\u914d\u7f6e\u9608\u503c<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>\u5982\u679cRedis\u5b9e\u4f8b\u5f00\u542f\u4e86AOF\u914d\u7f6e\uff0c\u540c\u65f6\u914d\u7f6e\u4e86auto-aof-rewrite-percentage\u4ee5\u53caauto-aof-rewrite-min-size\uff0c\u5982\u679c\u8d85\u51fa\u4e86\u9608\u503c\u4f1a\u89e6\u53d1AOF\u91cd\u5199\u3002<\/em><\/span><\/p>\n<p><span style=\"color: #d73a49\">\/\/<\/span>\u6ca1\u6709rdb\u5b50\u8fdb\u7a0b\u3001\u6ca1\u6709aof\u91cd\u5199\u5b50\u8fdb\u7a0b\u3001aof\u6587\u4ef6\u8bbe\u5b9a\u4e86\u9608\u503c\u4ee5\u53caaof\u6587\u4ef6\u5927\u5c0f\u7edd\u5bf9\u503c\u8d85\u8fc7\u9608\u503c<br \/> if <span style=\"color: #997\">(<\/span>server<span style=\"color: #005cc5\">.rdb_child_pid<\/span> <span style=\"color: #d73a49\">==<\/span> <span style=\"color: #d73a49\">&#8211;<\/span><span style=\"color: #005cc5\">1<\/span> <span style=\"color: #d73a49\">&amp;&amp;<\/span><br \/> server<span style=\"color: #005cc5\">.aof_child_pid<\/span> <span style=\"color: #d73a49\">==<\/span> <span style=\"color: #d73a49\">&#8211;<\/span><span style=\"color: #005cc5\">1<\/span> <span style=\"color: #d73a49\">&amp;&amp;<\/span><br \/> server<span style=\"color: #005cc5\">.aof_rewrite_perc<\/span> <span style=\"color: #d73a49\">&amp;&amp;<\/span><br \/> server<span style=\"color: #005cc5\">.aof_current_size<\/span> <span style=\"color: #d73a49\">&gt;<\/span> server<span style=\"color: #005cc5\">.aof_rewrite_min_size<\/span><span style=\"color: #997\">)<\/span><br \/><span style=\"color: #997\">{<\/span><br \/><span style=\"color: #22863a\">long<\/span> <span style=\"color: #22863a\">long<\/span> base <span style=\"color: #d73a49\">=<\/span> server<span style=\"color: #005cc5\">.aof_rewrite_base_size<\/span> <span style=\"color: #22863a\">?<\/span><br \/> server<span style=\"color: #005cc5\">.aof_rewrite_base_size<\/span> <span>:<\/span> <span style=\"color: #005cc5\">1<\/span><span>;<\/span><br \/><span style=\"color: #22863a\">long<\/span> <span style=\"color: #22863a\">long<\/span> growth <span style=\"color: #d73a49\">=<\/span> <span style=\"color: #997\">(<\/span>server<span style=\"color: #005cc5\">.aof_current_size<\/span><span style=\"color: #d73a49\">*<\/span><span style=\"color: #005cc5\">100<\/span><span style=\"color: #d73a49\">\/<\/span>base<span style=\"color: #997\">)<\/span> <span style=\"color: #d73a49\">&#8211;<\/span> <span style=\"color: #005cc5\">100<\/span><span>;<\/span><br \/><span style=\"color: #d73a49\">\/\/<\/span>\u8d85\u8fc7\u9608\u503c\u5219\u8fdb\u884c\u91cd\u5199<br \/> if <span style=\"color: #997\">(<\/span>growth <span style=\"color: #d73a49\">&gt;=<\/span> server<span style=\"color: #005cc5\">.aof_rewrite_perc<\/span><span style=\"color: #997\">)<\/span> <span style=\"color: #997\">{<\/span><br \/> serverLog<span style=\"color: #997\">(<\/span>LL_NOTICE<span>,<\/span><span style=\"color: #690\">&#8220;Starting automatic rewriting of AOF on %lld%% growth&#8221;<\/span><span>,<\/span>growth<span style=\"color: #997\">)<\/span><span>;<\/span><br \/> rewriteAppendOnlyFileBackground<span style=\"color: #997\">(<\/span><span style=\"color: #997\">)<\/span><span>;<\/span><br \/><span style=\"color: #997\">}<\/span><br \/><span style=\"color: #997\">}<\/span><\/p>\n<h4><em>aof_rewrite_scheduled\u88ab\u8bbe\u7f6e\u4e3a\u5f85\u8c03\u5ea6\u72b6\u6001<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>\u5728bgrewriteaofCommand\u51fd\u6570\u4e2d\uff0c\u5982\u679c\u5f53\u524d\u6b63\u5728\u6267\u884cRDB dump\u64cd\u4f5c\uff0c\u90a3\u4e48\u5bf9\u5e94\u7684aof\u5f85\u8c03\u5ea6aof_rewrite_scheduled\u72b6\u6001\u5c31\u4f1a\u88ab\u7f6e\u4e3a1\uff0c\u5f53\u524dRDB dump\u5b8c\u6210\u4e4b\u540e\uff0c\u4f1a\u7ee7\u7eed\u6267\u884cAOF\u91cd\u5199\u64cd\u4f5c\u3002<\/em><\/span><em>\u200b<\/em><\/p>\n<h4><em>AOF\u91cd\u5199\u8fc7\u7a0b\u662f\u600e\u6837\u7684\uff1f<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>\u901a\u8fc7\u4e0a\u6587\u7684\u63cf\u8ff0\uff0c\u6211\u4eec\u77e5\u9053\u4e86Redis\u89e6\u53d1AOF\u91cd\u5199\u7684\u65f6\u673a\uff0c\u90a3\u4e48\u5f53\u89e6\u53d1\u91cd\u5199\u4e4b\u540e\u7684\u5177\u4f53\u4e1a\u52a1\u662f\u600e\u6837\u7684\u5462\uff1f\u6211\u4eec\u4e00\u8d77\u770b\u4e0bAOF\u91cd\u5199\u7684\u5927\u81f4\u6d41\u7a0b\uff1a<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\uff081\uff09Redis\u4e3b\u8fdb\u7a0b\u9996\u5148\u68c0\u67e5\u662f\u4e0d\u662f\u5b58\u5728rdb dump\u8fdb\u7a0b\u6216\u8005aof\u91cd\u5199\u8fdb\u7a0b\u6b63\u5728\u8fd0\u884c\uff0c\u5982\u679c\u4e0d\u5b58\u5728Redis\u4e3b\u8fdb\u7a0bfork\u5b50\u8fdb\u7a0b\u8fdb\u884caof\u6587\u4ef6\u91cd\u5199\uff1b<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\uff082\uff09fork\u51fa\u6765\u7684\u5b50\u8fdb\u7a0b\u548c\u539f\u6765\u7684Redis\u4e3b\u8fdb\u7a0b\u62e5\u6709\u540c\u6837\u7684\u5185\u5b58\u6570\u636e\uff0c\u5b50\u8fdb\u7a0b\u904d\u5386\u6b64\u65f6\u7684\u5185\u5b58\u6570\u636e\u540c\u65f6\u5c06\u5185\u5b58\u6570\u636e\u5199\u5165\u5230\u4e34\u65f6\u7684AOF\u6587\u4ef6\u4e2d\uff1b<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\uff083\uff09\u4e3b\u8fdb\u7a0b\u6b64\u65f6\u4ecd\u7136\u53ef\u4ee5\u63a5\u6536\u5ba2\u6237\u7aef\u8bf7\u6c42\uff0c\u540c\u65f6\u5c06\u65b0\u7684\u7f13\u5b58\u64cd\u4f5c\u5199\u5165aof_buf\u4ee5\u53caaof_rewrite_buf\u4e2d\uff0c\u6839\u636e\u5bf9\u5e94\u7684\u540c\u6b65\u7b56\u7565\uff0c\u5c06buf\u4e2d\u7684\u6570\u636e\u5206\u522b\u5199\u5165\u65e7AOF\u6587\u4ef6\u4ee5\u53ca\u4e34\u65f6AOF\u6587\u4ef6\u4e2d\uff1b<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\uff084\uff09\u91cd\u5199\u5b8c\u6210\u4e4b\u540e\uff0c\u4e34\u65f6AOF\u6587\u4ef6\u5c06\u66ff\u6362\u539f\u6709\u7684\u8001\u7684AOF\u6587\u4ef6\uff0c\u4ece\u800c\u5b8c\u6210\u6574\u4e2aAOF\u91cd\u5199\u3002<\/em><\/span><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230129\/167495490563d5c899c3c65.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<h4><em>AOF\u6a21\u5f0f\u4f18\u70b9<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>1\u3001AOF\u7684\u6301\u4e45\u5316\u7b56\u7565\u66f4\u52a0\u4e30\u5bcc\u4e9b\uff0c\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u4e1a\u52a1\u9700\u8981\u8fdb\u884c\u914d\u7f6e\uff0c\u56e0\u6b64\u76f8\u5bf9\u6765\u8bf4\u5728\u6570\u636e\u53ef\u9760\u6027\u65b9\u9762\u8981\u66f4\u52a0\u6709\u4f18\u52bf\u4e00\u70b9\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>2\u3001AOF\u6587\u4ef6\u5185\u5bb9\u6bd4\u8f83\u597d\u7406\u89e3\uff0c\u66f4\u52a0\u65b9\u4fbf\u7406\u89e3\u4e1a\u52a1\u7f13\u5b58\u6570\u636e\u3002<\/em><\/span><\/p>\n<h4><em>AOF\u6a21\u5f0f\u7f3a\u70b9<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>1\u3001\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u540c\u6837\u7684\u7f13\u5b58\u6570\u636e\uff0cAOF\u6587\u4ef6\u6bd4RDB\u6587\u4ef6\u5927\u5c0f\u8981\u5927\u4e00\u4e9b\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>2\u3001\u5728\u6587\u4ef6\u6062\u590d\u573a\u666f\u4e0b\uff0cAOF\u8981\u6bd4DRB\u6062\u590d\u6570\u636e\u6162\u4e00\u4e9b\u3002<\/em><\/span><\/p>\n<h2><span style=\"color: #515151\">RDB\u6301\u4e45\u5316<\/span><\/h2>\n<p><span style=\"font-size: 14px\"><em>RDB\uff08Redis Data Base\uff09\uff0c\u6240\u8c13\u7684Redis\u5185\u5b58\u6570\u636e\u5feb\u7167\u5c31\u662f\u67d0\u4e00\u65f6\u523bRedis\u5b58\u4e8e\u5185\u5b58\u4e2d\u7684\u6240\u6709\u7f13\u5b58\u6570\u636e\uff0c\u8fd9\u5c31\u597d\u6bd4\u7528\u624b\u673a\u76f8\u673a\u62cd\u7167\uff0c\u8bb0\u5f55\u5f53\u65f6\u7684\u7f8e\u597d\u753b\u9762\u3002Redis\u53ef\u4ee5\u5b9e\u73b0\u5728\u56fa\u5b9a\u65f6\u95f4\u95f4\u9694\u540e\u5c06\u5185\u5b58\u4e2d\u7684\u7f13\u5b58\u6570\u636e\u6301\u4e45\u5316\u4fdd\u5b58\u8d77\u6765\u3002\u8fd9\u6837\u5373\u4fbf\u662f\u670d\u52a1\u5668\u5b95\u673a\u6216\u8005\u91cd\u542f\u4e86\uff0c\u53ea\u8981RDB\u5feb\u7167\u6587\u4ef6\u8fd8\u5b58\u5728\uff0c\u5feb\u7167\u6587\u4ef6\u4e2d\u5bf9\u5e94\u7684\u7f13\u5b58\u6570\u636e\u5c31\u4e0d\u4f1a\u4e22\u5931\uff0cRedis\u91cd\u65b0\u542f\u52a8\u540e\u4f1a\u91cd\u65b0\u52a0\u8f7dRDB\u6587\u4ef6\u5230\u5185\u5b58\u4e2d\uff0c\u5feb\u901f\u6062\u590d\u7f13\u5b58\u6570\u636e\uff0c\u901a\u8fc7\u8fd9\u6837\u7684\u65b9\u5f0f\u4fdd\u969c\u4e86\u7f13\u5b58\u6570\u636e\u7684\u53ef\u9760\u6027\u3002<\/em><\/span><\/p>\n<h3><span style=\"color: #515151\">RDB\u6587\u4ef6\u751f\u6210\u8fc7\u7a0b<\/span><\/h3>\n<p><span style=\"font-size: 14px\"><em>\u6211\u4eec\u4ee5bgsave\u4e3a\u4f8b\u5b50\u6765\u770b\u4e0bRedis\u751f\u6210RDB\u6587\u4ef6\u7684\u5927\u81f4\u8fc7\u7a0b\u662f\u600e\u6837\u7684\u3002<\/em><\/span><\/p>\n<p><span style=\"color: #22863a\">int<\/span> <span style=\"color: #005cc5\">rdbSaveBackground<\/span>(<span style=\"color: #22863a\">char<\/span> <span style=\"color: #d73a49\">*<\/span><span>filename<\/span>, <span>rdbSaveInfo<\/span> <span style=\"color: #d73a49\">*<\/span><span>rsi<\/span>){<br \/><span>pid_t<\/span> <span>childpid<\/span>;<br \/><span style=\"color: #22863a\">long<\/span> <span style=\"color: #22863a\">long<\/span> <span>start<\/span>;<\/p>\n<p><span style=\"color: #6a737d\">\/\/ \u5982\u679c\u5df2\u7ecf\u5b58\u5728aof\u91cd\u5199\u5b50\u8fdb\u7a0b\u4ee5\u53cardb\u751f\u6210\u5b50\u8fdb\u7a0b\u5219\u76f4\u63a5\u8fd4\u56de\u9519\u8bef<\/span><br \/><span style=\"color: #d73a49\">if<\/span> (<span>server<\/span>.<span>aof_child_pid<\/span> <span style=\"color: #d73a49\">!=<\/span> <span style=\"color: #d73a49\">&#8211;<\/span><span style=\"color: #005cc5\">1<\/span> <span style=\"color: #d73a49\">||<\/span> <span>server<\/span>.<span>rdb_child_pid<\/span> <span style=\"color: #d73a49\">!=<\/span> <span style=\"color: #d73a49\">&#8211;<\/span><span style=\"color: #005cc5\">1<\/span>) <span style=\"color: #d73a49\">return<\/span> <span>C_ERR<\/span>;<br \/> &#8230;<br \/><span style=\"color: #6a737d\">\/\/ fork\u5b50\u8fdb\u7a0b\u8fdb\u884cRDB\u6587\u4ef6\u751f\u6210<\/span><br \/><span style=\"color: #d73a49\">if<\/span> ((<span>childpid<\/span> <span style=\"color: #d73a49\">=<\/span> <span>fork<\/span>()) <span style=\"color: #d73a49\">==<\/span> <span style=\"color: #005cc5\">0<\/span>) {<br \/> &#8230;<br \/><span style=\"color: #6a737d\">\/\/ \u751f\u6210RDB\u6587\u4ef6<\/span><br \/><span>retval<\/span> <span style=\"color: #d73a49\">=<\/span> <span>rdbSave<\/span>(<span>filename<\/span>,<span>rsi<\/span>);<br \/><span style=\"color: #d73a49\">if<\/span> (<span>retval<\/span> <span style=\"color: #d73a49\">==<\/span> <span>C_OK<\/span>) {<br \/><span>size_t<\/span> <span>private_dirty<\/span> <span style=\"color: #d73a49\">=<\/span> <span>zmalloc_get_private_dirty<\/span>(<span style=\"color: #d73a49\">&#8211;<\/span><span style=\"color: #005cc5\">1<\/span>);<\/p>\n<p><span style=\"color: #d73a49\">if<\/span> (<span>private_dirty<\/span>) {<br \/><span>serverLog<\/span>(<span>LL_NOTICE<\/span>,<br \/><span style=\"color: #690\">&#8220;RDB: %zu MB of memory used by copy-on-write&#8221;<\/span>,<br \/><span>private_dirty<\/span><span style=\"color: #d73a49\">\/<\/span>(<span style=\"color: #005cc5\">1024<\/span><span style=\"color: #d73a49\">*<\/span><span style=\"color: #005cc5\">1024<\/span>));<br \/> }<\/p>\n<p><span>server<\/span>.<span>child_info_data<\/span>.<span>cow_size<\/span> <span style=\"color: #d73a49\">=<\/span> <span>private_dirty<\/span>;<br \/><span style=\"color: #6a737d\">\/\/ \u901a\u77e5\u7236\u8fdb\u7a0bRDB\u6587\u4ef6\u751f\u6210\u5b8c\u6bd5<\/span><br \/><span>sendChildInfo<\/span>(<span>CHILD_INFO_TYPE_RDB<\/span>);<br \/> }<br \/><span style=\"color: #6a737d\">\/\/\u5b50\u8fdb\u7a0b\u9000\u51fa<\/span><br \/><span>exitFromChild<\/span>((<span>retval<\/span> <span style=\"color: #d73a49\">==<\/span> <span>C_OK<\/span>) <span style=\"color: #d73a49\">?<\/span> <span style=\"color: #005cc5\">0<\/span> : <span style=\"color: #005cc5\">1<\/span>);<br \/> } <span style=\"color: #d73a49\">else<\/span> {<br \/><span style=\"color: #6a737d\">\/\/\u7236\u8fdb\u7a0b\u4e1a\u52a1\u903b\u8f91<\/span><br \/> &#8230;<br \/> }<br \/><span style=\"color: #d73a49\">return<\/span> <span>C_OK<\/span>; <br \/>}<\/p>\n<p><span style=\"font-size: 14px\"><em>\uff081\uff09Redis\u4e3b\u8fdb\u7a0b\u9996\u5148\u5224\u65ad\u5f53\u524d\u662f\u5426\u5b58\u5728\u5df2\u7ecf\u5728\u6267\u884c\u7684aof\u91cd\u5199\u5b50\u8fdb\u7a0b\u4ee5\u53cardb\u6587\u4ef6\u751f\u6210\u5b50\u8fdb\u7a0b\uff0c\u5982\u679c\u5b58\u5728\u7684\u8bdd\u5219\u76f4\u63a5\u8fdb\u884c\u8fd4\u56de\u3002\u4e3a\u4ec0\u4e48\u8981\u8fdb\u884c\u8fd9\u6837\u7684\u5224\u65ad\u5462\uff1f\u4e3b\u8981\u8fd8\u662f\u4ece\u670d\u52a1\u5668\u6027\u80fd\u65b9\u9762\u8fdb\u884c\u8003\u91cf\uff0c\u5982\u679c\u670d\u52a1\u5668\u6709\u591a\u4e2a\u5b50\u7ebf\u7a0b\u5728\u8fdb\u884cRDB\u6301\u4e45\u5316\u64cd\u4f5c\uff0c\u90a3\u4e48\u5fc5\u5b9a\u4f1a\u5bf9\u78c1\u76d8\u9020\u6210\u6bd4\u8f83\u5927\u7684IO\u538b\u529b\uff0c\u5982\u679c\u670d\u52a1\u5668\u4e2d\u8fd8\u90e8\u7f72\u4e86\u5176\u4ed6\u670d\u52a1\u751a\u81f3\u4f1a\u5f71\u54cd\u5176\u4ed6\u670d\u52a1\u7684\u6b63\u5e38\u8fd0\u884c\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\uff082\uff09Redis\u4e3b\u8fdb\u7a0bfork\u5b50\u8fdb\u7a0b\u8fdb\u884cRDB\u6587\u4ef6\u751f\u6210\u64cd\u4f5c\uff0c\u5728fork\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6b64\u65f6\u7684Redis\u4e3b\u8fdb\u7a0b\u662f\u963b\u585e\u7684\uff0c\u4e0d\u80fd\u54cd\u5e94\u5ba2\u6237\u7aef\u8bf7\u6c42\uff0c\u5b50\u8fdb\u7a0bfork\u5b8c\u6210\u4e4b\u540e\u53ef\u4ee5\u7ee7\u7eed\u54cd\u5e94\u5ba2\u6237\u7aef\u8bf7\u6c42\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\uff083\uff09fork\u51fa\u6765\u7684\u5b50\u8fdb\u7a0b\u904d\u5386\u5185\u5b58\u6570\u636e\u8fdb\u884cRDB\u6587\u4ef6\u751f\u6210\u64cd\u4f5c\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\uff084\uff09\u5982\u679c\u6b64\u65f6\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u9700\u8981\u4fee\u6539\u7f13\u5b58\u6570\u636e\uff0c\u90a3\u4e48\u5982\u4e0a\u9762fork\u5b50\u8fdb\u7a0b\u7684\u539f\u7406\uff0c\u901a\u8fc7COW\u673a\u5236\uff0c\u64cd\u4f5c\u7cfb\u7edf\u4f1a\u5f00\u8f9f\u65b0\u7684\u5185\u5b58\u7a7a\u95f4\u7ed9Redis\u4e3b\u8fdb\u7a0b\u8fdb\u884c\u65b0\u7684\u7f13\u5b58\u6570\u636e\u5199\u5165\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\uff085\uff09\u5b50\u8fdb\u7a0b\u5feb\u7167\u6570\u636e\u751f\u6210\u5b8c\u6210\u4e4b\u540e\uff0c\u66ff\u6362\u539f\u6765\u8001\u7684RDB\u6587\u4ef6\u3002<\/em><\/span><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230129\/167495490663d5c89a330f8.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<h3><span style=\"color: #515151\">RDB\u89e6\u53d1\u65f6\u673a<\/span><\/h3>\n<p><span style=\"font-size: 14px\"><em>Redis\u4e3b\u8981\u652f\u6301\u4e24\u79cd\u6301\u4e45\u5316\u64cd\u4f5c\u6765\u751f\u6210RDB\u6587\u4ef6\uff0c\u5206\u522b\u662fsave\u3001bsave\u547d\u4ee4\u65b9\u5f0f\u624b\u52a8\u751f\u6210\u4ee5\u53ca\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u914d\u7f6e\u65f6\u95f4\u95f4\u9694\u81ea\u52a8\u8fdb\u884cRDB\u6587\u4ef6\u751f\u6210\u3002<\/em><\/span><\/p>\n<h4><em>\u624b\u52a8\u547d\u4ee4\u89e6\u53d1<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>\u5ba2\u6237\u7aef\u8fde\u63a5\u5230redis\u4e4b\u540e\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7save\u4ee5\u53cabsave\u547d\u4ee4\u8fdb\u884cRDB\u6587\u4ef6\u7684\u7acb\u5373\u521b\u5efa\uff0c\u4e24\u8005\u7684\u533a\u522b\u5982\u4e0b\uff1a<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><strong><em>save\uff1a<\/em><\/strong><\/span><span style=\"font-size: 14px\"><em>\u901a\u8fc7\u4e3b\u7ebf\u7a0b\u89e6\u53d1\uff0c\u4f1a\u963b\u585eRedis\u4e1a\u52a1\uff0c\u5982\u679c\u5185\u5b58\u6570\u636e\u6bd4\u8f83\u591a\u7684\u8bdd\uff0c\u4f1a\u5bfc\u81f4\u957f\u65f6\u95f4\u4e0d\u80fd\u54cd\u5e94\u5916\u90e8\u8bf7\u6c42\uff1b<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><strong><em>bsave\uff1a<\/em><\/strong><\/span><span style=\"font-size: 14px\"><em>\u5ba2\u6237\u7aef\u6267\u884cbsave\u547d\u4ee4\u8fdb\u884cRDB\u6301\u4e45\u5316\uff0cRedis\u4e3b\u7ebf\u7a0b\u4f1afork\u5b50\u7ebf\u7a0b\u51fa\u6765\u8fdb\u884cRDB\u6587\u4ef6\u6301\u4e45\u5316\u64cd\u4f5c\uff0c\u8fd9\u6837\u907f\u514d\u4e86\u4e3b\u7ebf\u7a0b\u7684\u963b\u585e\u5373\u4fbf\u6b63\u5728\u6301\u4e45\u5316\u64cd\u4f5c\u4f9d\u7136\u53ef\u4ee5\u54cd\u5e94\u5916\u90e8\u6570\u636e\u7f13\u5b58\u8bf7\u6c42\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\u4e0d\u8fc7\u8fd9\u91cc\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u867d\u7136fork\u5b50\u8fdb\u7a0b\u4e4b\u540e\u4e0d\u4f1a\u963b\u585e\u4e3b\u8fdb\u7a0b\uff0c\u4f46\u662f\u5728fork\u7684\u8fc7\u7a0b\u4e2d\u4f1a\u963b\u585e\u4e3b\u8fdb\u7a0b\uff0c\u5c24\u5176\u662f\u5728\u5185\u5b58\u6570\u636e\u6bd4\u8f83\u5927\u7684\u65f6\u5019\uff0c\u963b\u585e\u4e3b\u8fdb\u7a0b\u7684\u65f6\u95f4\u4f1a\u66f4\u957f\u3002<\/em><\/span><\/p>\n<h4><em>\u914d\u7f6e\u81ea\u52a8\u89e6\u53d1<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>\u53e6\u5916\u5728Redis\u7684\u914d\u7f6e\u6587\u4ef6redis.conf\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u914d\u7f6e\u6309\u7167\u4e00\u5b9a\u7684\u65f6\u95f4\u95f4\u9694\u6765\u8fdb\u884cRDB\u6301\u4e45\u5316\u64cd\u4f5c\u3002\u5982\u4e0b\u914d\u7f6e\uff1a<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>save 900 1<br \/>save 300 10<br \/>save 60 10000<\/em><\/span><em>\u200b<\/em><\/p>\n<p><span style=\"font-size: 14px\"><em>\u5176\u4ed6\u7684\u89e6\u53d1RDB\u6587\u4ef6\u751f\u6210\u7684\u64cd\u4f5c\u8fd9\u91cc\u4e0d\u518d\u8d58\u8ff0\u4e86\uff0c\u50cf\u4ece\u8282\u70b9\u6267\u884c\u5168\u91cf\u6570\u636e\u540c\u6b65\u7684\u65f6\u5019\uff0c\u4e5f\u4f1a\u89e6\u53d1\u4e3b\u8282\u70b9\u751f\u6210RDB\u6587\u4ef6\u53d1\u9001\u7ed9\u4ece\u8282\u70b9\u3002<\/em><\/span><\/p>\n<h3><span style=\"color: #515151\">RDB\u6709\u6ca1\u6709\u4e22\u6570\u636e\u7684\u98ce\u9669\uff1f<\/span><\/h3>\n<p><span style=\"font-size: 14px\"><em>\u5927\u5bb6\u4e0d\u59a8\u601d\u8003\u4e0b\u901a\u8fc7RDB\u6587\u4ef6\u8fdb\u884c\u7f13\u5b58\u6570\u636e\u6301\u4e45\u5316\u4f1a\u6709\u4ec0\u4e48\u95ee\u9898\uff1f\u5b58\u4e0d\u5b58\u5728\u4e22\u5931\u7f13\u5b58\u6570\u636e\u7684\u98ce\u9669\uff1f\u8fd9\u79cd\u65b9\u5f0f\u770b\u4e0a\u53bb\u662f\u4e2a\u8fd8\u4e0d\u9519\u7684\u6301\u4e45\u5316\u89e3\u51b3\u65b9\u6848\uff0c\u4f46\u662f\u5b9e\u9645\u4e0a\u9690\u85cf\u7740\u4e00\u4e9b\u4e22\u5931\u7f13\u5b58\u6570\u636e\u7684\u98ce\u9669\u3002\u4e3a\u4ec0\u4e48\u8fd9\u4e48\u8bf4\u5462\uff1f\u901a\u8fc7\u5206\u6790RDB\u6587\u4ef6\u751f\u6210\u7684\u673a\u5236\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\u6709\u4e24\u4e2a\u5730\u65b9\u5b58\u5728\u7f13\u5b58\u6570\u636e\u4e22\u5931\u7684\u53ef\u80fd\u6027\u3002<\/em><\/span><\/p>\n<h4><em>\u573a\u666f1\uff1a<\/em><\/h4>\n<p><span style=\"font-size: 14px\"><em>\u7531\u4e8eRedis\u4fdd\u5b58RDB\u5feb\u7167\u6587\u4ef6\u7684\u7b56\u7565\u662f\u6309\u7167\u914d\u7f6e\u7684\u65f6\u95f4\u95f4\u9694\u8fdb\u884c\u6301\u4e45\u5316\u4fdd\u5b58\uff0c\u4e5f\u5c31\u662f\u6bcf\u9694\u4e00\u4e2a\u65f6\u95f4\u95f4\u9694Redis\u5c31\u4f1a\u4fdd\u5b58\u4e00\u4e2aRDB\u6587\u4ef6\u3002\u56e0\u6b64\u5728\u5185\u5b58\u6570\u636e\u6709\u66f4\u65b0\u4f46\u662fRDB\u4fdd\u5b58\u65f6\u95f4\u5c1a\u672a\u5230\u6765\u7684\u8fd9\u6bb5\u65f6\u95f4\u5982\u679c\u5b58\u5728\u670d\u52a1\u5668\u5b95\u673a\u6216\u8005\u670d\u52a1\u5668\u91cd\u542f\u7684\u60c5\u51b5\uff0c\u6b64\u65f6\u5185\u5b58\u7684\u6570\u636e\u5c31\u4f1a\u5b58\u5728\u4e22\u5931\u7684\u98ce\u9669\uff0c\u56e0\u4e3aRedis\u8fd8\u6ca1\u6765\u5f97\u53ca\u5c06\u6570\u636e\u6301\u4e45\u5316\u5230RDB\u6587\u4ef6\u4e2d\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\u573a\u666f1\u4e2d\u6700\u5927\u7684\u95ee\u9898\u5c31RDB\u6587\u4ef6\u6301\u4e45\u5316\u5b58\u5728\u65f6\u95f4\u95f4\u9694\uff0c\u800c\u8fd9\u4e2a\u65f6\u95f4\u95f4\u9694\u5bfc\u81f4\u4e86\u65b0\u589e\u7684\u7f13\u5b58\u6570\u636e\u5b58\u5728\u4e22\u5931\u7684\u98ce\u9669\u3002\u90a3\u4e48\u662f\u4e0d\u662f\u5c06\u65f6\u95f4\u95f4\u9694\u964d\u4f4e\u5230\u6700\u5c0f\u5c31\u53ef\u4ee5\u4e86\uff0c\u6bd4\u5982\u4e00\u79d2\u949f\uff0c\u5373\u4f7f\u5728\u8fd9\u4e00\u79d2\u949f\u671f\u95f4\u51fa\u73b0\u5f02\u5e38\u60c5\u51b5\uff0c\u90a3\u7f13\u5b58\u6570\u636e\u4e5f\u53ea\u662f\u4e22\u6389\u8fd9\u4e00\u79d2\u949f\u7684\u7f13\u5b58\u6570\u636e\uff0c\u76f8\u5bf9\u6765\u8bf4\u6570\u636e\u4e22\u5931\u7684\u60c5\u51b5\u53ef\u63a7\u4e00\u70b9\u3002\u4f46\u662f\u95ee\u9898\u662f\u5982\u679c\u771f\u7684\u6bcf\u96941s\u5c31\u4fdd\u5b58\u4e00\u4e2aRDB\u6587\u4ef6\u5230\u670d\u52a1\u5668\u78c1\u76d8\u4e2d\uff0c\u90a3\u4e0d\u8bba\u662f\u5bf9Redis\u672c\u8eab\u8fd8\u662fRedis\u6240\u5728\u7684\u670d\u52a1\u5668\u78c1\u76d8IO\u90fd\u662f\u4e00\u79cd\u8d1f\u62c5\u3002<\/em><\/span><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230129\/167495490663d5c89aa40e4.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<h4><em>\u573a\u666f2\uff1a<\/em><\/h4>\n<p><em>\u200b<\/em><span style=\"font-size: 14px\"><em>\u968f\u7740\u4e1a\u52a1\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u5185\u5b58\u4e2d\u7684\u6570\u636e\u5fc5\u5b9a\u4f1a\u8d8a\u6765\u8d8a\u5927\uff0c\u56e0\u6b64\u5728fork\u5b50\u8fdb\u7a0b\u6765\u751f\u6210RDB\u6587\u4ef6\u7684\u8fc7\u7a0b\u4e2d\uff0c\u9700\u8981\u590d\u5236\u7684\u6570\u636e\u4f1a\u540c\u6837\u8d8a\u6765\u8d8a\u591a\uff0c\u8017\u8d39\u7684\u65f6\u95f4\u4e5f\u4f1a\u8d8a\u6765\u8d8a\u591a\uff0c\u8fdb\u800c\u963b\u585e\u4e3b\u8fdb\u7a0b\u7684\u65f6\u95f4\u4e5f\u4f1a\u8d8a\u6765\u8d8a\u591a\u3002\u5982\u679c\u51fa\u73b0\u957f\u65f6\u95f4\u963b\u585e\u4e3b\u8fdb\u7a0b\u7684\u60c5\u51b5\uff0c\u90a3\u4e48Redis\u5b9e\u4f8b\u5fc5\u5b9a\u65e0\u6cd5\u54cd\u5e94\u5ba2\u6237\u7aef\u7684\u6570\u636e\u64cd\u4f5c\u8bf7\u6c42\uff0c\u6700\u7ec8\u5bfc\u81f4\u5185\u5b58\u6570\u636e\u6ca1\u6709\u8fdb\u884c\u53ca\u65f6\u66f4\u65b0\uff0c\u4ece\u800c\u51fa\u73b0\u4e22\u5931\u7f13\u5b58\u6570\u636e\u7684\u98ce\u9669\u3002<\/em><\/span><\/p>\n<h3><em>RDB\u6a21\u5f0f\u4f18\u70b9<\/em><\/h3>\n<p><span style=\"font-size: 14px\"><em>1\u3001\u76f8\u6bd4AOF\u5728\u6062\u590d\u6570\u636e\u7684\u65f6\u5019\u9700\u8981\u4e00\u6761\u6761\u56de\u653e\u64cd\u4f5c\u547d\u4ee4\uff0c\u901a\u8fc7RDB\u6587\u4ef6\u6062\u590d\u6570\u636e\u6548\u7387\u66f4\u9ad8\uff1b<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>2\u3001\u9002\u5408\u5168\u91cf\u5907\u4efd\u5185\u5b58\u6570\u636e\u573a\u666f\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>3\u3001\u540c\u6837\u89c4\u6a21\u7684\u5185\u5b58\u6570\u636e\uff0cRDB\u6587\u4ef6\u6570\u636e\u66f4\u52a0\u7d27\u51d1\uff0c\u78c1\u76d8\u7a7a\u95f4\u5360\u7528\u66f4\u5c0f\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>4\u3001\u53ef\u4ee5\u6839\u636e\u4e0d\u540c\u7684\u65f6\u95f4\u95f4\u9694\u4fdd\u5b58RDB\u6587\u4ef6\uff0c\u5728\u6062\u590d\u6570\u636e\u7684\u65f6\u5019\u53ef\u4ee5\u66f4\u52a0\u7075\u6d3b\u5730\u9009\u62e9\u5bf9\u5e94\u7248\u672c\u6570\u636e\u8fdb\u884c\u6062\u590d\u3002<\/em><\/span><\/p>\n<h3><em>RDB\u6a21\u5f0f\u7f3a\u70b9<\/em><\/h3>\n<p><span style=\"font-size: 14px\"><em>1\u3001\u7531\u4e8eRDB\u6570\u636e\u4fdd\u5b58\u5b58\u5728\u4e00\u5b9a\u7684\u65f6\u95f4\u95f4\u9694\uff0c\u56e0\u6b64\u5b58\u5728\u4e22\u5931\u7f13\u5b58\u6570\u636e\u7684\u98ce\u9669\uff1b<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>2\u3001fork\u5b50\u8fdb\u7a0b\u8fdb\u884cRDB\u6587\u4ef6\u751f\u6210\uff0c\u7531\u4e8e\u662f\u4e00\u6b21\u6027\u751f\u6210\u4e00\u4e2a\u5185\u5b58\u5feb\u7167\u6587\u4ef6\uff0c\u5bf9\u4e8e\u670d\u52a1\u5668\u78c1\u76d8IO\u4ee5\u53caRedis\u672c\u8eab\u6765\u8bf4\u90fd\u5c5e\u4e8e\u91cd\u64cd\u4f5c\uff0c\u53ef\u80fd\u4f1a\u5bf9\u670d\u52a1\u5668\u7684\u78c1\u76d8IO\u9020\u6210\u538b\u529b\u3002<\/em><\/span><\/p>\n<h2><span style=\"color: #515151\">\u6df7\u5408\u6301\u4e45\u5316<\/span><\/h2>\n<p><span style=\"font-size: 14px\"><em>\u65e2\u7136AOF\u4ee5\u53caRDB\u6301\u4e45\u5316\u90fd\u6709\u8fd9\u6837\u6216\u8005\u90a3\u6837\u7684\u4e0d\u8db3\uff0c\u90a3\u4e48\u6709\u6ca1\u6709\u4e00\u79cd\u6301\u4e45\u5316\u65b9\u6848\u53ef\u4ee5\u517c\u987e\u4e8c\u8005\u7684\u4f18\u70b9\u6765\u626c\u957f\u907f\u77ed\u5462\uff1f\u4ece4.0\u7248\u672c\u5f00\u59cb\uff0cRedis\u652f\u6301\u6df7\u5408\u6301\u4e45\u5316\u7684\u65b9\u5f0f\u6765\u517c\u987e\u6548\u7387\u4ee5\u53ca\u6570\u636e\u53ef\u9760\u6027\u3002\u5728Redis\u914d\u7f6e\u6587\u4ef6redis.conf\u4e2d\u914d\u7f6e\u6df7\u5408\u6301\u4e45\u5316\uff1a<\/em><\/span><\/p>\n<\/p>\n<p>aof\u2010use\u2010rdb\u2010preamble yes<\/p>\n<p><span style=\"font-size: 14px\"><em>\u5982\u679c\u914d\u7f6e\u4e86\u6df7\u5408\u6301\u4e45\u5316\uff0c\u90a3\u4e48Redis\u4e3b\u8fdb\u7a0b\u5728fork\u5b50\u8fdb\u7a0b\u8fdb\u884c\u6301\u4e45\u5316\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u539f\u5148\u7684\u5c06\u5185\u5b58\u6570\u636e\u8f6c\u6362\u4e3a\u64cd\u4f5c\u547d\u4ee4\u7684\u8fc7\u7a0b\u5c06\u66ff\u6362\u4e3a\u4f7f\u7528\u8fdb\u884cAOF\u91cd\u5199\u65f6\u5bf9\u5e94\u7684RDB\u6587\u4ef6\u5185\u5bb9\u76f4\u63a5\u653e\u5165\u5230\u91cd\u5199\u540e\u7684\u4e34\u65f6\u6587\u4ef6\u4e2d\uff0c\u540e\u9762\u518d\u6709\u65b0\u7684\u64cd\u4f5c\u547d\u4ee4\uff0c\u90fd\u8ffd\u52a0\u5230\u4e34\u65f6aof\u6587\u4ef6\u4e2d\uff0c\u91cd\u5199\u5b8c\u6210\u540e\u4f7f\u7528\u4e34\u65f6aof\u6587\u4ef6\u66ff\u6362\u65e7\u7684\u6587\u4ef6\u3002<\/em><\/span><\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230129\/167495490763d5c89b1ae96.png\" style=\"max-width:100%\" class=\"aligncenter\"> <\/p>\n<h3><em>\u6df7\u5408\u6301\u4e45\u5316\u6a21\u5f0f\u4f18\u70b9<\/em><\/h3>\n<p><span style=\"font-size: 14px\"><em>1\u3001\u540c\u65f6\u62e5\u6709RDB\u4ee5\u53caAOF\u673a\u5236\u7684\u4f18\u70b9\uff0c\u5728\u6570\u636e\u53ef\u9760\u6027\u4ee5\u53ca\u6570\u636e\u6062\u590d\u6548\u7387\u4e0a\u9762\u8fbe\u5230\u4e86\u5f88\u597d\u7684\u5e73\u8861\u3002<\/em><\/span><em>\u200b<\/em><\/p>\n<h3><em>\u6df7\u5408\u6301\u4e45\u5316\u6a21\u5f0f\u7f3a\u70b9<\/em><\/h3>\n<p><span style=\"font-size: 14px\"><em>1\u3001\u7531\u4e8eRedis\u4ece4.0\u7248\u672c\u624d\u5f00\u59cb\u652f\u6301\u6df7\u5408\u6301\u4e45\u5316\uff0c\u5982\u679c\u5f53\u524d\u5e73\u53f0\u4e2d\u7684Redis\u7248\u672c\u4f4e\u4e8e4.0\uff0c\u90a3\u4e48\u5c31\u65e0\u6cd5\u4f7f\u7528\u8fd9\u4e2a\u6301\u4e45\u5316\u673a\u5236\uff0c\u56e0\u6b64\u517c\u5bb9\u6027\u4e0d\u591f\u53cb\u597d\uff1b<\/em><\/span><\/p>\n<h2><span style=\"color: #515151\">\u603b\u7ed3<\/span><\/h2>\n<p><span style=\"font-size: 14px\"><em>\u672c\u6587\u4e3b\u8981\u5206\u6790\u4e86Redis AOF\u3001RDB\u4ee5\u53ca\u6df7\u5408\u6301\u4e45\u5316\u7684\u5185\u5b58\u6570\u636e\u6301\u4e45\u5316\u7684\u673a\u5236\u539f\u7406\uff0c\u540c\u65f6\u5206\u6790\u4e86\u4e24\u79cd\u6301\u4e45\u5316\u65b9\u5f0f\u7684\u4f18\u70b9\u4ee5\u53ca\u7f3a\u70b9\u3002\u6211\u60f3\u53ea\u6709\u7406\u89e3\u4e86\u4e2d\u95f4\u4ef6\u7684\u7279\u6027\u673a\u5236\u539f\u7406\uff0c\u77e5\u9053\u4e86\u7279\u6027\u7684\u957f\u5904\u4ee5\u53ca\u4e0d\u8db3\u6211\u4eec\u624d\u80fd\u8bbe\u8ba1\u9002\u5408\u6211\u4eec\u5e73\u53f0\u7684\u7f13\u5b58\u6570\u636e\u6301\u4e45\u5316\u7b56\u7565\uff0c\u4ece\u800c\u63d0\u5347\u5e73\u53f0\u7684\u7a33\u5b9a\u6027\u3002<\/em><\/span><\/p>\n<p><span style=\"font-size: 14px\"><em>\u53e6\u5916\u5728\u4e00\u4e9b\u4f18\u79c0\u4e2d\u95f4\u4ef6\u7684\u5b66\u4e60\u548c\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u4e0d\u80fd\u4ec5\u4ec5\u505c\u7559\u5728\u4f1a\u7528\u7684\u5c42\u9762\uff0c\u66f4\u5e94\u8be5\u6df1\u5165\u5e95\u5c42\u9886\u4f1a\u5176\u67b6\u6784\u548c\u5b9e\u73b0\u673a\u5236\u7684\u8bbe\u8ba1\u601d\u8def\uff0c\u53ea\u6709\u641e\u660e\u767d\u8bbe\u8ba1\u601d\u8def\uff0c\u65f6\u523b\u7ad9\u5728\u8bbe\u8ba1\u8005\u7684\u89d2\u5ea6\u6765\u770b\u5f85\u9047\u5230\u7684\u95ee\u9898\uff0c\u90a3\u4e48\u5728\u6211\u4eec\u7684\u5b9e\u9645\u5de5\u4f5c\u4e2d\uff0c\u5982\u679c\u9047\u5230\u7c7b\u4f3c\u7684\u95ee\u9898\u6211\u4eec\u53ef\u4ee5\u501f\u9274\u8fd9\u4e9b\u4f18\u79c0\u4e2d\u95f4\u4ef6\u7684\u89e3\u51b3\u601d\u8def\u6765\u8fdb\u884c\u95ee\u9898\u5206\u6790\u3002<\/em><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7f13\u5b58\u6570\u636e\u4e22\u4e86\uff0c\u539f\u6765\u662fRedis\u6301&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-201480","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/201480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=201480"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/201480\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=201480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=201480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=201480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}