• 自动秒收录
  • 软件:1973
  • 资讯:56933|
  • 收录网站:211312|

IT精英团

知道雷迪斯关系数据库这些细节,可以少踩很多坑

知道雷迪斯关系数据库这些细节,可以少踩很多坑

浏览次数:
评论次数:
编辑: 泽洋
信息来源: ITPUB
更新日期: 2022-06-23 20:55:54
摘要

在使用Redis的过程中,你是否遇到过下面这些问题:开启RDB落盘,业务频繁出现请求超时。除了save和bgsave命令,还有哪些操作会触发RDB落盘?执行了flushall,发

  • 正文开始
  • 相关阅读
  • 推荐作品

在使用使用心得的过程中,你是否遇到过下面这些问题:

开启关系数据库落盘,业务频繁出现请求超时。

除了救援和bgsave命令,还有哪些操作会触发关系数据库落盘?

执行了冲水阀,发现清空所有数据库之前写的数据又冒出来了。

重启使用心得实例之后,发现数据有丢失的情况。

设置aaa 111 ','标记' :[]}],'状态' :{},{ '类型' :{ } '块',' id':'Gezy-1655890668775 ','名称' : '段落','数据' : { '版本' :1},'节点' 3360[{ '类型' : '文本',' id':

"name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"BoeQ-1655893053938","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"yIxd-1655890893749","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"Wjqt-1655890893747","leaves":[{"text":"127.0.0.1:6301>flushall","marks":[]}]}],"state":{}},{"type":"block","id":"AgMP-1655890902634","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"jxFh-1655890902633","leaves":[{"text":"OK","marks":[]}]}],"state":{}},{"type":"block","id":"o4KA-1655890668785","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"KiRd-1655890668784","leaves":[{"text":"127.0.0.1:6301>config get save","marks":[]}]}],"state":{}},{"type":"block","id":"kRtQ-1655890668787","name":"list-item","data":{"version":1,"listId":"P71n-1655890668755","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"EghP-1655890668786","leaves":[{"text":"\"save\"","marks":[]}]}],"state":{"index":1}},{"type":"block","id":"FAV8-1655890668789","name":"list-item","data":{"version":1,"listId":"P71n-1655890668755","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"c6DR-1655890668788","leaves":[{"text":"\"\"","marks":[]}]}],"state":{"index":2}},{"type":"block","id":"C3NC-1655890668791","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"IW47-1655890668790","leaves":[{"text":"127.0.0.1:6301>config get appendonly","marks":[]}]}],"state":{}},{"type":"block","id":"7mfN-1655890668793","name":"list-item","data":{"version":1,"listId":"aqXG-1655890668757","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"Vtlq-1655890668792","leaves":[{"text":"\"appendonly\"","marks":[]}]}],"state":{"index":1}},{"type":"block","id":"UHvl-1655890668795","name":"list-item","data":{"version":1,"listId":"aqXG-1655890668757","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"iTi1-1655890668794","leaves":[{"text":"\"no\"","marks":[]}]}],"state":{"index":2}},{"type":"block","id":"ezIn-1655890670875","name":"paragraph","data":{},"nodes":[{"type":"text","id":"oy5i-1655890670873","leaves":[{"text":"127.0.0.1:6301>shutdown","marks":[]}]}],"state":{}},{"type":"block","id":"vkDu-1655890680217","name":"paragraph","data":{},"nodes":[{"type":"text","id":"7K8F-1655890680216","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"fIYv-1655890681078","name":"paragraph","data":{},"nodes":[{"type":"text","id":"3AAT-1655890681076","leaves":[{"text":"再启动 Redis","marks":[]}]}],"state":{}},{"type":"block","id":"m6WJ-1655890686803","name":"paragraph","data":{},"nodes":[{"type":"text","id":"IxZo-1655890686802","leaves":[{"text":"127.0.0.1:6301>keys *","marks":[]}]}],"state":{}},{"type":"block","id":"9bKf-1655890695851","name":"list-item","data":{"version":1,"listId":"x4xr-1655890695842","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"Gc1y-1655890695850","leaves":[{"text":"\"aaa\"","marks":[]}]}],"state":{"index":1}},{"type":"block","id":"qZbx-1655890695853","name":"list-item","data":{"version":1,"listId":"x4xr-1655890695842","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"9jEI-1655890695852","leaves":[{"text":"\"bbb\"","marks":[]}]}],"state":{"index":2}},{"type":"block","id":"SCdk-1655890702890","name":"paragraph","data":{},"nodes":[{"type":"text","id":"y5lN-1655890702888","leaves":[{"text":"会看到我们清空Redis 之前写入的数据。显然是不符合逻辑的。","marks":[]}]}],"state":{}},{"type":"block","id":"FSnC-1655893635985","name":"paragraph","data":{},"nodes":[{"type":"text","id":"t3AM-1655893635983","leaves":[{"text":"这是因为在启动 Redis 时,会加载数据目录下的 RDB 文件,而这个 RDB 文件是 flushall 之前执行 bgsave 生成的,也就是会看到清空 Redis 之前写入的数据。这里也是“","marks":[]},{"text":"执行了 flushall,发现 flushall 之前写的数据又冒出来了。","marks":[{"type":"bold"}]},{"text":"”的原因。","marks":[]}]}],"state":{}},{"type":"block","id":"pahc-1655893636770","name":"paragraph","data":{},"nodes":[{"type":"text","id":"j3ul-1655893636769","leaves":[{"text":"所以在实例未开启 RDB 和 AOF 的情况下,如果执行 了 flushall 命令,建议再执行一次 bgsave,让 RDB 文件也清空。","marks":[]}]}],"state":{}},{"type":"block","id":"WxpZ-1655891215757","name":"paragraph","data":{},"nodes":[{"type":"text","id":"Ddwk-1655891215756","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"YOVw-1655891216553","name":"paragraph","data":{},"nodes":[{"type":"text","id":"SvtV-1655891216551","leaves":[{"text":"另外还测试了开启 AOF,关闭 RDB 的情况:","marks":[]}]}],"state":{}},{"type":"block","id":"04b2-1655891250870","name":"paragraph","data":{},"nodes":[{"type":"text","id":"iD7W-1655891250869","leaves":[{"text":"127.0.0.1:6301>set aaa 111","marks":[]}]}],"state":{}},{"type":"block","id":"jTpH-1655891264727","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"TiML-1655891264726","leaves":[{"text":"OK","marks":[]}]}],"state":{}},{"type":"block","id":"TJdM-1655891264729","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"ZR7d-1655891264728","leaves":[{"text":"127.0.0.1:6301>set bbb 111","marks":[]}]}],"state":{}},{"type":"block","id":"gHWu-1655891264731","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"D8FU-1655891264730","leaves":[{"text":"OK","marks":[]}]}],"state":{}},{"type":"block","id":"9yXg-1655891264733","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"AFmV-1655891264732","leaves":[{"text":"127.0.0.1:6301>bgsave","marks":[]}]}],"state":{}},{"type":"block","id":"OQRp-1655891264735","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"NQs2-1655891264734","leaves":[{"text":"Background saving started","marks":[]}]}],"state":{}},{"type":"block","id":"d3hT-1655891264737","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"DA2i-1655891264736","leaves":[{"text":"127.0.0.1:6301>flushall","marks":[]}]}],"state":{}},{"type":"block","id":"AfPR-1655891264740","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"Ca1g-1655891264739","leaves":[{"text":"OK","marks":[]}]}],"state":{}},{"type":"block","id":"iywM-1655891264742","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"FkTW-1655891264741","leaves":[{"text":"127.0.0.1:6301>config get save","marks":[]}]}],"state":{}},{"type":"block","id":"SO9H-1655891264744","name":"list-item","data":{"version":1,"listId":"MTFC-1655891264705","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"qIk9-1655891264743","leaves":[{"text":"\"save\"","marks":[]}]}],"state":{"index":1}},{"type":"block","id":"c3FN-1655891264746","name":"list-item","data":{"version":1,"listId":"MTFC-1655891264705","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"jzH2-1655891264745","leaves":[{"text":"\"\"","marks":[]}]}],"state":{"index":2}},{"type":"block","id":"LcFn-1655891264748","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"NeMi-1655891264747","leaves":[{"text":"127.0.0.1:6301>config get appendonly","marks":[]}]}],"state":{}},{"type":"block","id":"pLjp-1655891264750","name":"list-item","data":{"version":1,"listId":"7du8-1655891264707","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"aH9q-1655891264749","leaves":[{"text":"\"appendonly\"","marks":[]}]}],"state":{"index":1}},{"type":"block","id":"FU6c-1655891264752","name":"list-item","data":{"version":1,"listId":"7du8-1655891264707","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"3bKn-1655891264751","leaves":[{"text":"\"yes\"","marks":[]}]}],"state":{"index":2}},{"type":"block","id":"C6za-1655891264754","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"sUDJ-1655891264753","leaves":[{"text":"127.0.0.1:6301>shutdown","marks":[]}]}],"state":{}},{"type":"block","id":"qcQx-1655891267833","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"hOjw-1655891267832","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"iPXf-1655891267972","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"mcCF-1655891267970","leaves":[{"text":"启动 Redis","marks":[]}]}],"state":{}},{"type":"block","id":"blTl-1655891274733","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"9qrW-1655891274732","leaves":[{"text":"redis-cli -p 6301","marks":[]}]}],"state":{}},{"type":"block","id":"sFe2-1655891281854","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"VmIa-1655891281853","leaves":[{"text":"127.0.0.1:6301>keys *","marks":[]}]}],"state":{}},{"type":"block","id":"MHOj-1655891288833","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"BsGT-1655891288832","leaves":[{"text":"(empty list or set)","marks":[]}]}],"state":{}},{"type":"block","id":"dH9r-1655891292029","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"ZvCN-1655891292027","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"kKsI-1655891292163","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"ndjF-1655891292162","leaves":[{"text":"重启之后不会再看到 flushall 之前写入的数据,因为 Redis 在 启动时加载 rdb 文件后,也会加载在执行 RDB 之后 AOF 里新增的操作。而 flushall 操作就记录在 AOF 文件中。","marks":[]}]}],"state":{}},{"type":"block","id":"bxuj-1655792323906","name":"paragraph","data":{},"nodes":[{"type":"text","id":"vRWK-1655792323904","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"6m5v-1655792330716","name":"paragraph","data":{},"nodes":[{"type":"text","id":"9BQA-1655792330714","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"XUnD-1655792368251","name":"paragraph","data":{},"nodes":[{"type":"text","id":"6XtY-1655792368250","leaves":[{"text":"4 正常关闭时","marks":[{"type":"bold"}]}]}],"state":{}},{"type":"block","id":"Livf-1655893437262","name":"paragraph","data":{},"nodes":[{"type":"text","id":"wvqI-1655893437260","leaves":[{"text":"我们通过在命令行执行 shutdown 正常关闭 Redis 时,并不是所有情况都会执行一次 RDB 落盘的,这里就来分析一下不同配置,重启后的情况。","marks":[]}]}],"state":{}},{"type":"block","id":"YRAg-1655792330869","name":"paragraph","data":{},"nodes":[{"type":"text","id":"Pvv3-1655792330868","leaves":[{"text":"4/1 AOF 和 RDB 都开启的情况","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"},{"type":"bold"}]}]}],"state":{}},{"type":"block","id":"ZH44-1655824761076","name":"paragraph","data":{},"nodes":[{"type":"text","id":"wKGS-1655824761074","leaves":[{"text":"127.0.0.1:6301>set bbb 111","marks":[]}]}],"state":{}},{"type":"block","id":"XOua-1655887765104","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"vcg7-1655887765103","leaves":[{"text":"OK","marks":[]}]}],"state":{}},{"type":"block","id":"3YI1-1655887765106","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"mEa0-1655887765105","leaves":[{"text":"127.0.0.1:6301>config get save","marks":[]}]}],"state":{}},{"type":"block","id":"iY18-1655887765108","name":"list-item","data":{"version":1,"listId":"Xb0Y-1655887765070","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"vjre-1655887765107","leaves":[{"text":"\"save\"","marks":[]}]}],"state":{"index":1}},{"type":"block","id":"r1Qt-1655887765110","name":"list-item","data":{"version":1,"listId":"Xb0Y-1655887765070","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"Baen-1655887765109","leaves":[{"text":"\"1800 1\"","marks":[]}]}],"state":{"index":2}},{"type":"block","id":"cNnj-1655887765112","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"MNSd-1655887765111","leaves":[{"text":"127.0.0.1:6301>config get appendonly","marks":[]}]}],"state":{}},{"type":"block","id":"28pw-1655887765115","name":"list-item","data":{"version":1,"listId":"eEMJ-1655887765090","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"oiHo-1655887765113","leaves":[{"text":"\"appendonly\"","marks":[]}]}],"state":{"index":1}},{"type":"block","id":"SxzK-1655887765117","name":"list-item","data":{"version":1,"listId":"eEMJ-1655887765090","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"zZWg-1655887765116","leaves":[{"text":"\"yes\"","marks":[]}]}],"state":{"index":2}},{"type":"block","id":"0YYL-1655887765119","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"mh5z-1655887765118","leaves":[{"text":"127.0.0.1:6301>shutdown","marks":[]}]}],"state":{}},{"type":"block","id":"Hv7E-1655887776706","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"p1pF-1655887776705","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"YEIc-1655887777012","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"YOgq-1655887777010","leaves":[{"text":"启动 Redis","marks":[]}]}],"state":{}},{"type":"block","id":"Wwkc-1655887782423","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"EaBP-1655887782421","leaves":[{"text":"127.0.0.1:6301>get bbb","marks":[]}]}],"state":{}},{"type":"block","id":"ORnG-1655887800384","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"pNvL-1655887800383","leaves":[{"text":"\"111\"","marks":[]}]}],"state":{}},{"type":"block","id":"NbAe-1655887741466","name":"paragraph","data":{},"nodes":[{"type":"text","id":"u6Pv-1655887741464","leaves":[{"text":"这种情况会在关闭时执行一次 RDB 落盘,启动加载 RDB 文件,保证重启前后数据一致。","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"}]}]}],"state":{}},{"type":"block","id":"ONOZ-1655893911457","name":"paragraph","data":{},"nodes":[{"type":"text","id":"Tie8-1655893911456","leaves":[{"text":"","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"}]}]}],"state":{}},{"type":"block","id":"b33Y-1655893899084","name":"paragraph","data":{},"nodes":[{"type":"text","id":"Pq1p-1655893899082","leaves":[{"text":"","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"}]}]}],"state":{}},{"type":"block","id":"8U6t-1655824761517","name":"paragraph","data":{},"nodes":[{"type":"text","id":"ezhz-1655824761515","leaves":[{"text":"4.2 AOF 和 RDB 都未开的情况","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"},{"type":"bold"}]}]}],"state":{}},{"type":"block","id":"gXgb-1655824772108","name":"paragraph","data":{},"nodes":[{"type":"text","id":"a0oG-1655824772107","leaves":[{"text":"127.0.0.1:6301>set ccc 111","marks":[]}]}],"state":{}},{"type":"block","id":"b0Si-1655824989380","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"u3FB-1655824989379","leaves":[{"text":"OK","marks":[]}]}],"state":{}},{"type":"block","id":"bpoJ-1655824989382","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"tmtQ-1655824989381","leaves":[{"text":"127.0.0.1:6301>config get save","marks":[]}]}],"state":{}},{"type":"block","id":"qEI3-1655824989384","name":"list-item","data":{"version":1,"listId":"99UD-1655824989362","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"bbGP-1655824989383","leaves":[{"text":"\"save\"","marks":[]}]}],"state":{"index":1}},{"type":"block","id":"O5ib-1655824989386","name":"list-item","data":{"version":1,"listId":"99UD-1655824989362","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"umOg-1655824989385","leaves":[{"text":"\"\"","marks":[]}]}],"state":{"index":2}},{"type":"block","id":"ncdx-1655824989388","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"nyl7-1655824989387","leaves":[{"text":"127.0.0.1:6301>config get appendonly","marks":[]}]}],"state":{}},{"type":"block","id":"WBnt-1655824989390","name":"list-item","data":{"version":1,"listId":"XYMJ-1655824989364","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"q2dv-1655824989389","leaves":[{"text":"\"appendonly\"","marks":[]}]}],"state":{"index":1}},{"type":"block","id":"9AGk-1655824989392","name":"list-item","data":{"version":1,"listId":"XYMJ-1655824989364","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"F6aQ-1655824989391","leaves":[{"text":"\"no\"","marks":[]}]}],"state":{"index":2}},{"type":"block","id":"cRju-1655824989394","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"p35E-1655824989393","leaves":[{"text":"127.0.0.1:6301>shutdown","marks":[]}]}],"state":{}},{"type":"block","id":"eXyh-1655824992631","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"IaaZ-1655824992630","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"8R9L-1655824992786","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"p7y8-1655824992785","leaves":[{"text":"然后启动 Redis","marks":[]}]}],"state":{}},{"type":"block","id":"zxMD-1655825006642","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"W1Wy-1655825006641","leaves":[{"text":"127.0.0.1:6301>get ccc","marks":[]}]}],"state":{}},{"type":"block","id":"AKWV-1655825017202","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"27eA-1655825017201","leaves":[{"text":"(nil)","marks":[]}]}],"state":{}},{"type":"block","id":"1Acc-1655825020277","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"p8dl-1655825020275","leaves":[{"text":"发现重启之前 ccc 的 key 已经丢失,","marks":[]},{"text":"因此在 master 未开启 RDB 的情况,关闭之前需要主动执行 bgsave,否则会导致数据丢失。这也是“","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"}]},{"text":"重启 Redis 实例之后,发现数据有丢失的情况","marks":[{"type":"fontSize","value":16},{"type":"bold"}]},{"text":"”的原因。","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"}]}]}],"state":{}},{"type":"block","id":"zs3X-1655866267151","name":"paragraph","data":{},"nodes":[{"type":"text","id":"xicm-1655866267150","leaves":[{"text":"","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"}]}]}],"state":{}},{"type":"block","id":"nazm-1655866218485","name":"paragraph","data":{},"nodes":[{"type":"text","id":"YHzX-1655866218484","leaves":[{"text":"","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"}]}]}],"state":{}},{"type":"block","id":"ZSr7-1655824812385","name":"paragraph","data":{},"nodes":[{"type":"text","id":"fmDH-1655824812383","leaves":[{"text":"4.3 AOF 关闭,RDB 开启的情况","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"},{"type":"bold"}]}]}],"state":{}},{"type":"block","id":"vEt1-1655824823939","name":"paragraph","data":{},"nodes":[{"type":"text","id":"yfmX-1655824823938","leaves":[{"text":"127.0.0.1:6301>set ddd 111","marks":[]}]}],"state":{}},{"type":"block","id":"Kgtx-1655888558340","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"rnAU-1655888558339","leaves":[{"text":"OK","marks":[]}]}],"state":{}},{"type":"block","id":"F8S9-1655888558343","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"XPLp-1655888558342","leaves":[{"text":"127.0.0.1:6301>config get save","marks":[]}]}],"state":{}},{"type":"block","id":"4nkT-1655888558345","name":"list-item","data":{"version":1,"listId":"9Mr3-1655888558326","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"SwYc-1655888558344","leaves":[{"text":"\"save\"","marks":[]}]}],"state":{"index":1}},{"type":"block","id":"Q5Jr-1655888558347","name":"list-item","data":{"version":1,"listId":"9Mr3-1655888558326","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"MLRb-1655888558346","leaves":[{"text":"\"1800 1\"","marks":[]}]}],"state":{"index":2}},{"type":"block","id":"JTCf-1655888558349","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"pUfg-1655888558348","leaves":[{"text":"127.0.0.1:6301>config get appendonly","marks":[]}]}],"state":{}},{"type":"block","id":"L445-1655888558351","name":"list-item","data":{"version":1,"listId":"bbcW-1655888558328","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"fwt3-1655888558350","leaves":[{"text":"\"appendonly\"","marks":[]}]}],"state":{"index":1}},{"type":"block","id":"EX80-1655888558353","name":"list-item","data":{"version":1,"listId":"bbcW-1655888558328","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"ty84-1655888558352","leaves":[{"text":"\"no\"","marks":[]}]}],"state":{"index":2}},{"type":"block","id":"ZXq5-1655888557385","name":"paragraph","data":{},"nodes":[{"type":"text","id":"0noT-1655888557383","leaves":[{"text":"127.0.0.1:6301>shutdown","marks":[]}]}],"state":{}},{"type":"block","id":"fAej-1655888568959","name":"paragraph","data":{},"nodes":[{"type":"text","id":"Hzmi-1655888568957","leaves":[{"text":"启动 Redis","marks":[]}]}],"state":{}},{"type":"block","id":"8esc-1655888579617","name":"paragraph","data":{},"nodes":[{"type":"text","id":"qvf3-1655888579616","leaves":[{"text":"127.0.0.1:6301>get ddd","marks":[]}]}],"state":{}},{"type":"block","id":"ak95-1655888636161","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"C3NS-1655888636160","leaves":[{"text":"\"111\"","marks":[]}]}],"state":{}},{"type":"block","id":"KvFR-1655888569423","name":"paragraph","data":{},"nodes":[{"type":"text","id":"b9uE-1655888569422","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"LpVB-1655888557524","name":"paragraph","data":{},"nodes":[{"type":"text","id":"Cdb3-1655888557522","leaves":[{"text":"这种情况会写 RDB,重启后数据未丢失。","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"}]}]}],"state":{}},{"type":"block","id":"O39z-1655808429874","name":"paragraph","data":{},"nodes":[{"type":"text","id":"FuU6-1655808429873","leaves":[{"text":"","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"}]}]}],"state":{}},{"type":"block","id":"9dLG-1655866291685","name":"paragraph","data":{},"nodes":[{"type":"text","id":"mFAL-1655866291683","leaves":[{"text":"","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"}]}]}],"state":{}},{"type":"block","id":"2f56-1655866291839","name":"paragraph","data":{},"nodes":[{"type":"text","id":"a8do-1655866291837","leaves":[{"text":"4.4 AOF 开启,RDB 关闭的情况","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"},{"type":"bold"}]}]}],"state":{}},{"type":"block","id":"rufi-1655866349417","name":"paragraph","data":{},"nodes":[{"type":"text","id":"FhXv-1655866349416","leaves":[{"text":"127.0.0.1:6301>set eee 111","marks":[]}]}],"state":{}},{"type":"block","id":"jRgB-1655889003755","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"jPpv-1655889003754","leaves":[{"text":"OK","marks":[]}]}],"state":{}},{"type":"block","id":"fMKm-1655889003757","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"SrtN-1655889003756","leaves":[{"text":"127.0.0.1:6301>config get save","marks":[]}]}],"state":{}},{"type":"block","id":"RxG8-1655889003759","name":"list-item","data":{"version":1,"listId":"eSo1-1655889003739","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"M1yY-1655889003758","leaves":[{"text":"\"save\"","marks":[]}]}],"state":{"index":1}},{"type":"block","id":"QyCu-1655889003761","name":"list-item","data":{"version":1,"listId":"eSo1-1655889003739","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"5soX-1655889003760","leaves":[{"text":"\"\"","marks":[]}]}],"state":{"index":2}},{"type":"block","id":"Y5nl-1655889003763","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"a72b-1655889003762","leaves":[{"text":"127.0.0.1:6301>config get appendonly","marks":[]}]}],"state":{}},{"type":"block","id":"nOew-1655889003766","name":"list-item","data":{"version":1,"listId":"sETu-1655889003741","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"hCOU-1655889003765","leaves":[{"text":"\"appendonly\"","marks":[]}]}],"state":{"index":1}},{"type":"block","id":"1jb5-1655889003768","name":"list-item","data":{"version":1,"listId":"sETu-1655889003741","listLevel":1,"listType":"ordered"},"nodes":[{"type":"text","id":"vv9B-1655889003767","leaves":[{"text":"\"yes\"","marks":[]}]}],"state":{"index":2}},{"type":"block","id":"bD3W-1655889003770","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"y0mC-1655889003769","leaves":[{"text":"127.0.0.1:6301>shutdown","marks":[]}]}],"state":{}},{"type":"block","id":"3jde-1655889006481","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"h368-1655889006480","leaves":[{"text":"启动 Redis","marks":[]}]}],"state":{}},{"type":"block","id":"tCQC-1655889021894","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"PUXR-1655889021892","leaves":[{"text":"127.0.0.1:6301>get eee","marks":[]}]}],"state":{}},{"type":"block","id":"xoQU-1655889026836","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"cXWE-1655889026835","leaves":[{"text":"\"111\"","marks":[]}]}],"state":{}},{"type":"block","id":"HEeM-1655894063820","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"ffH5-1655894063818","leaves":[{"text":"这种情况尽管不会进行 RDB 落盘,但是因为之前的操作都写入了 AOF,在 Redis 启动时,会加载 AOF 里的数据,因此也会跟关闭之前的数据保持一致。","marks":[]}]}],"state":{}},{"type":"block","id":"7vzB-1655894152756","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"mwZb-1655894152755","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"YAwN-1655894152917","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"9p6z-1655894152915","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"7Ttv-1655894153057","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"PTOy-1655894153055","leaves":[{"text":"到这里,文章开始列出的四个问题都应该找到了答案,可能列出的 RDB 细节不一定全,朋友们可以在手机端打开文章跳到最下面,点击“发消息”进行交流。","marks":[]}]}],"state":{}},{"type":"block","id":"jxWH-1655894064030","name":"paragraph","data":{"version":1},"nodes":[{"type":"text","id":"iMEJ-1655894064029","leaves":[{"text":"或者加入数据库交流群讨论,入群请添加下方群秘微信,备注“进群”,等待群秘邀你入群。","marks":[]}]}],"state":{}},{"type":"block","id":"uC0W-1655894356010","name":"paragraph","data":{},"nodes":[{"type":"text","id":"Ki9E-1655894356011","leaves":[{"text":"","marks":[]}]}],"state":{}},{"type":"block","id":"T7WM-1655808430036","name":"paragraph","data":{},"nodes":[{"type":"text","id":"HCQf-1655808430034","leaves":[{"text":"","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"}]}]}],"state":{}},{"type":"block","id":"Er30-1655809352544","name":"paragraph","data":{},"nodes":[{"type":"text","id":"taT4-1655809352542","leaves":[{"text":"","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"}]}]}],"state":{}},{"type":"block","id":"GDHK-1655809366432","name":"paragraph","data":{},"nodes":[{"type":"text","id":"kmTC-1655809366430","leaves":[{"text":"","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"}]}]}],"state":{}},{"type":"block","id":"wG4v-1655808436810","name":"paragraph","data":{},"nodes":[{"type":"text","id":"n1ZI-1655808436809","leaves":[{"text":"","marks":[{"type":"color","value":"#333333"},{"type":"backgroundColor","value":"rgb(255, 255, 255)"},{"type":"fontSize","value":16},{"type":"fontFamily","value":"Arial"}]}]}],"state":{}},{"type":"block","id":"NShA-1655792324924","name":"paragraph","data":{},"nodes":[{"type":"text","id":"VAG8-1655792324923","leaves":[{"text":"标题:知道 Redis RDB 这些细节,可以少踩很多坑","marks":[]}]}],"state":{}}]">

带着上面这些问题,我们一起来聊聊 RDB 的一些细节。


触发 RDB 文件创建的命令有两条,save 和 bgsave。

save 我们知道会阻塞整个实例,通常也不太可能会用。

bgsave 命令是在后台生成 RDB 文件,Redis 仍然可以处理客户端请求。


但是并不能保证 bgsave 不会影响 Redis 所有的客户端请求,在生成 RDB的过程中,Redis 会 fork 出一个子进程,子进程和父进程会共享内存地址空间,可以保证子进程拥有父进程相同的内存数据。但是在 fork 子进程时,操作系统需要将父进程的内存页表复制给子进程。如果整个 Redis 实例占用的内存很大,那么它的内存页表也会很大,复制的时间也会比较长。

同时,这个过程会消耗大量的 CPU 资源,在复制完成之前,父进程也会被阻塞,无法处理客户端请求。

执行 fork 后,子进程可以扫描 Redis 中所有数据,然后将所有数据写入 RDB 文件。

之后,父进程仍然处理客户端的请求。父进程在处理写命令时,会重新分配新的内存地址空间,向操作系统申请新的内存使用,不再与子进程共享。这样,父子进程的内存会逐渐分离,父进程会申请新的内存空间并改变内存数据,子进程的内存数据不会受到影响。

可以看出,在生成RDB文件时,不仅消耗CPU资源,还需要消耗更多的内存空间。

上面也就是“开启 RDB 落盘,业务频繁出现请求超时”的原因。通常在生产环境,我们也应该避免在 master 实例上做 RDB。


那么除了 save 和 bgsave 命令,还有哪些常见会触发 RDB 呢?这里就来总结几种情况,这也是问题“除了 save 和 bgsave 命令,还有哪些操作会触发 RDB 落盘呢?”的答案:

1 配置了 RDB 落盘的情况

比如配置文件配置了 save xxx xxx,或者命令行执行了 config set save "xxx xxx",都表示配置了 RDB 落盘。

比如配置了 save 900 1

则表示 900 秒内如果至少有 1 个 key 的值变化,则做一次 bgsave。

我们在前面有提到 bgsave 也会对客户端请求有所影响,所以不建议在 master 上增加该参数,如果为了数据备份,建议只在 slave 增加 save 参数。


2 主从复制

第一次创建主从复制关系时,会在主库执行 bgsave 命令生成 RDB 文件,然后传给从库,从库加载 RDB 文件,以完成一次全量数据的传输。

因此在业务访问高峰,并且数据量比较大的情况,不建议在 master 上创建 slave。


3 Redis 在执行 flushall 命令

配置了 RDB 落盘的情况,在执行 flushall 命令时,会进行一次 RDB 落盘,但是内容是空的。目的是将 RDB 文件也清空。


但是,如果 RDB 和 AOF 都关闭的情况下,会有下面这种情况:

127.0.0.1:6301> set aaa 111OK127.0.0.1:6301> set bbb 111OK127.0.0.1:6301> bgsaveBackground saving started127.0.0.1:6301> flushallOK127.0.0.1:6301> config get save"save"""127.0.0.1:6301> config get appendonly"appendonly""no"127.0.0.1:6301> shutdown

再启动 Redis

127.0.0.1:6301> keys *"aaa""bbb"

会看到我们清空 Redis 之前写入的数据。显然是不符合逻辑的。

这是因为在启动 Redis 时,会加载数据目录下的 RDB 文件,而这个 RDB 文件是 flushall 之前执行 bgsave 生成的,也就是会看到清空 Redis 之前写入的数据。这里也是“执行了 flushall,发现 flushall 之前写的数据又冒出来了”的原因。

所以在实例未开启 RDB 和 AOF 的情况下,如果执行 了 flushall 命令,建议再执行一次 bgsave,让 RDB 文件也清空。


另外还测试了开启 AOF,关闭 RDB 的情况:

127.0.0.1:6301> set aaa 111OK127.0.0.1:6301> set bbb 111OK127.0.0.1:6301>  bgsaveBackground saving started127.0.0.1:6301> flushallOK127.0.0.1:6301> config get save"save"""127.0.0.1:6301> config get appendonly"appendonly""yes"127.0.0.1:6301> shutdown

启动 Redis

127.0.0.1:6301> keys *(empty list or set)

重启之后不会再看到 flushall 之前写入的数据,因为 Redis 在 启动时加载 RDB 文件后,也会加载在执行 RDB 之后 AOF 里新增的操作。而 flushall 操作就记录在 AOF 文件中。


4 正常关闭时

我们通过在命令行执行 shutdown 正常关闭 Redis 时,并不是所有情况都会执行一次 RDB 落盘的,这里就来分析一下不同配置,重启后的情况。

4.1 AOF 和  RDB 都开启的情况

127.0.0.1:6301> set bbb 111OK127.0.0.1:6301> config get save"save""1800 1"127.0.0.1:6301> config get appendonly"appendonly""yes"127.0.0.1:6301> shutdown

启动 Redis

127.0.0.1:6301> get bbb"111"

这种情况会在关闭时执行一次 RDB 落盘,启动时加载 RDB 文件,保证重启前后数据一致。


4.2 AOF 和 RDB 都未开的情况

127.0.0.1:6301> set ccc 111OK127.0.0.1:6301> config get save"save"""127.0.0.1:6301> config get appendonly"appendonly""no"127.0.0.1:6301> shutdown

然后启动 Redis

127.0.0.1:6301> get ccc(nil)

发现重启之前 ccc 的 key 已经丢失,因此在 master 未开启 RDB 的情况,关闭之前需要主动执行 bgsave,否则会导致数据丢失。这也是“重启 Redis 实例之后,发现数据有丢失的情况”的原因。


4.3 AOF 关闭,RDB 开启的情况

127.0.0.1:6301> set ddd 111OK127.0.0.1:6301> config get save"save""1800 1"127.0.0.1:6301> config get appendonly"appendonly""no"127.0.0.1:6301> shutdown


启动 Redis

127.0.0.1:6301> get ddd"111"

这种情况会写 RDB,重启后数据未丢失。


4.4 AOF 开启,RDB 关闭的情况

127.0.0.1:6301> set eee 111OK127.0.0.1:6301> config get save"save"""127.0.0.1:6301> config get appendonly"appendonly""yes"127.0.0.1:6301> shutdown

启动 Redis

127.0.0.1:6301> get eee"111"


这种情况尽管不会进行 RDB 落盘,但是因为之前的操作都写入了 AOF,在 Redis 启动时,会加载 AOF 里的数据,因此也会跟关闭之前的数据保持一致。


到这里,文章开始列出的四个问题都应该找到了答案,可能列出的 RDB 细节不一定全,朋友们可以在手机端打开文章跳到最下面,点击“发消息”进行交流。



原文

标签:数据 情况 文件
大厂中的技术专家:建筑设计中的常见思维模式
« 上一篇 2022-06-23
  • 大厂中的技术专家:建筑设计中的常见思维模式
    0阅读 0条评论 个赞
    上周我写的一篇文章《关于技术能力的思考和总结》引起了大家的关注,好多读者的评论“以写代想、以想促真、以讲验真”,大家的感受很深刻,基于上次的文章,这篇文章我其实更想跟大家聊聊一些常用的思考方法,思考问……
  • 在线K8s群集性能评估 基本服务部署调整
    0阅读 0条评论 个赞
    对于非结构化的数据存储系统来说,LIST操作通常都是非常重量级的,不仅占用大量的磁盘IO、网络带宽和CPU,而且会影响同时间段的其他请求(尤其是响应延迟要求极高的选主请求),是集群稳定性的一……
  • 当字节跳动向美国出口中国996.
    0阅读 0条评论 个赞
    作者|GeorgiaWells/YoreeKoh/SalvadorRodriguez来源|WSJ在荣克离职时发布的一份内部备忘录中,他说,“TikTok对待员工的方式与TikTok平台代表的……
  • 在Kotlin开发者眼中 Java缺少哪些特性?
    2阅读 0条评论 个赞
    出品|OSC开源社区(ID:oschina2013)NicolasFränkel是一名资深程序员,拥有近二十年的Java开发经历。他在几年前开始学习Kotlin,在此之后,每当他再使用……
  • 老工程师总结的10条经验 太有益了~
    1阅读 0条评论 个赞
    正文到现在,我已经做了超过21年开发,可以说,我生命中超过一半的时间都在编程,那既是我的职业,也成了我的习惯。下面是我在开发过程中学到的10条最有价值的经验。1你永远不可能什么都知道尤其是在开……
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
  • Kubernetes日志收集例程 能正确使用吗?
    0阅读 0条评论 个赞
    一、准备1、关于容器日志Docker的日志分为两类,一类是Docker引擎日志;另一类是容器日志。引擎日志一般都交给了系统日志,不同的操作系统会放在不同的位置。本文主要介绍容器日志,容器日志可以……
  • 用Docke r构建自己的dns服务器
    0阅读 0条评论 个赞
    在开发运维过程中经常需要自定义一个域名来管理服务,通常的方法是修改hosts文件,但还有一种更便捷的方法,从源头上解决问题,也就是使用DNS来实现。1.搭建搭建依然使用docker,安装前请安装好do……
  • Kafka负载平衡在体内的实现
    1阅读 0条评论 个赞
    vivo互联网服务器团队-YouShuo副本迁移是Kafka最高频的操作,对于一个拥有几十万个副本的集群,通过人工去完成副本迁移是一件很困难的事情。CruiseControl作为Kafka的运维……
  • 【网关对比】Java亿流量架构的网关设计思路
    0阅读 0条评论 个赞
    本文准备围绕七个点来讲网关,分别是网关的基本概念、网关设计思路、网关设计重点、流量网关、业务网关、常见网关对比,对基础概念熟悉的朋友可以根据目录查看自己感兴趣的部分。Part1什么是网关网关,很多地方……
  • Redis的底层数据结构 逐个磁盘
    2阅读 0条评论 个赞
    大家好,我是陌溪前言Redis是一个高性能的分布式内存数据库,在国内的公司也有着非常广泛的使用场景。因此,在面试过程中,关于Redis相关的知识点,也是经常被问到的。下面这题,就是之前面试的时候……
  • 好的架构不是设计出来的 是进化出来的~
    0阅读 0条评论 个赞
    大家好,我是飘渺。各位肯定都听过这样一句话:"好的架构不是设计出来的,而是演进出来的,没有完美的架构,只有不断演变、不断完善的架构。"今天我们来看一下1号店App服务端架构改造的例子,来具……
  • 干货:10个聚类算法的完整Python操作实例
    1阅读 0条评论 个赞
    来源:海豚数据科学实验室本文约7000字,建议阅读14分钟本文将介绍一篇关于聚类的文章,10种聚类介绍和Python代码。聚类或聚类分析是无监督学习问题。它通常被用作数据分析技术,用于发现数据中的有趣……
  • 可以解决80%故障的故障排除方法
    1阅读 0条评论 个赞
    在讲解事件、故障处理思路前,先讲一个故障场景(以呼叫中心系统作为一例子):业务人员反映呼叫中心系统运行缓慢,部份电话在自助语言环节系统处理超时,话务转人工座席,人工座席出现爆线情况。运维人员开始忙活了……
  • 还记得发现redis使用不当导致的应用卡顿bug的过程吗?
    1阅读 0条评论 个赞
    首先说下问题现象:内网sandbox环境API持续1周出现应用卡死,所有api无响应现象。刚开始当测试抱怨环境响应慢的时候,我们重启一下应用,应用恢复正常,于是没做处理。但是后来问题出现频率越来越频……
  • 深入了解前端路由哈希和历史的区别
    1阅读 0条评论 个赞
    前言没了解这两种路由前,不管是vue还是react在项目创建时难免会进行路由之间选择,在hash和history难免会纠结一番,或者是直接稀里糊涂用了默认带#的hash路由,看完这篇分享,保准让你之后……
  • MySQL主从式 6分钟带你掌握!
    0阅读 0条评论 个赞
    以下文章来源于公众号-楼仔,作者楼仔MySQL主从一直是面试常客,里面的知识点虽然基础,但是能回答全的同学不多。比如我之前面试小米,就被问到过主从复制的原理,以及主从延迟的解决方案,你之前面试,有遇……
  • 为什么C的singleton模式不直接使用static 而必须实例化一个对象?
    1阅读 0条评论 个赞
    以下文章来源于公众号-编程往事,作者果冻虾仁开场前段时间在知乎回答了这样一个问题:为什么C++单例模式不能直接全部使用static变量和static函数呢?如果全部使用static的话,是不是也……
  • 如何用Python操作MySQL?
    0阅读 0条评论 个赞
    来源丨网络一.python操作数据库介绍Python标准数据库接口为PythonDB-API,PythonDB-API为开发人员提供了数据库应用编程接口。Python数据库接口支持非常多的……
  • Linux实用运维脚本分享
    0阅读 0条评论 个赞
    #查看僵尸进程ps-al|gawk'{print$2,$4}'|grepZ#匹配电子邮件的地址catindex.html|egrep-o"[A-Za-z0-9._]+@[A-Za-z0-9.]+\.[……
  • 彻底根除MySQL查询慢 这12个问题不能落下
    0阅读 0条评论 个赞
    前言日常开发中,我们经常会遇到数据库慢查询。那么导致数据慢查询都有哪些常见的原因呢?今天田螺哥就跟大家聊聊导致MySQL慢查询的12个常见原因,以及对应的解决方法。一、SQL没加索引1、反例sel……
  • Arch Linux超越Ubuntu成功登顶
    10阅读 0条评论 个赞
    Steam5月调查结果发布啦,本月Linux平台的用户百分比基础略有下降,而且最受欢迎的Linux发行版从UbuntuLTS转向了ArchLinux。Steam5月份的调查结……
  • 高并发架构的设计方法:面对高并发如何对症下药?
    1阅读 0条评论 个赞
    前言我们知道,“高并发”是现在系统架构设计的核心关键词。一个架构师如果设计、开发的系统不支持高并发,那简直不好意思跟同行讨论。但事实上,在架构设计领域,高并发的历史非常短暂,这一架构特性是随着互联网,……
  • 运维入坑必看:Kubernetes平台架构解读
    1阅读 0条评论 个赞
    Kubernetes是一个开源容器编排平台,管理大规模分布式容器化软件应用,是云计算发展演进的一次彻底革命性的突破。Kubernetes是谷歌的第三代容器管理系统,是Borg独特的控制器和Omega灵……
  • 数据库主键一定要自己增加吗?有哪些不推荐自我增加的场景?
    0阅读 0条评论 个赞
    我们平时建表的时候,一般会像下面这样。CREATETABLE`user`(`id`intNOTNULLAUTO_INCREMENTCOMMENT'主键',`name`char(10)NOTNULLDE……
  • 如何通过缓存提高系统性能
    1阅读 0条评论 个赞
    缓存在系统中最消耗性能的地方就是对数据库的访问了,一般来说,增、删、改操作不会出现什么性能问题,除非索引太多,并且数据量有十分庞大的情况下,这三个操作才会导致性能问题。一般可以限制单表索引的数量来提升……
最近发布资讯
更多