redis默认读取appendonly.aof文件

dump.rdb 与 appendonly.aof 同时存在的情况下,默认优先读取appendonly.aof文件。如果appendonly.aof有错误,则启动会失败。

vim appendonly.aof

*2
$6
SELECT
$1
...
v3
dfsdfsdfsdfsdfsd;;;;;;;;sdfsdf;;;;;;;sd;f;;;  // 乱加的

启动失败:

[mhbtest@root redis-5.0.4]$ src/redis-server redis_aof.conf 
19838:C 15 Dec 2020 16:37:13.330 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
19838:C 15 Dec 2020 16:37:13.330 # Redis version=5.0.4, bits=64, commit=00000000, modified=0, pid=19838, just started
19838:C 15 Dec 2020 16:37:13.330 # Configuration loaded
[mhbtest@root redis-5.0.4]$ src/redis-cli -p 6379
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> 

通过命令 redis-check-aof
启动成功:

[mhbtest@root redis-5.0.4]$ src/redis-check-aof --fix appendonly.aof 
0x              6e: Expected prefix '*', got: 'd'
AOF analyzed: size=156, ok_up_to=110, diff=46
This will shrink the AOF from 156 bytes, with 46 bytes, to 110 bytes
Continue? [y/N]: y
Successfully truncated AOF

[mhbtest@root redis-5.0.4]$ src/redis-server redis_aof.conf 
22117:C 15 Dec 2020 16:41:25.754 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
22117:C 15 Dec 2020 16:41:25.754 # Redis version=5.0.4, bits=64, commit=00000000, modified=0, pid=22117, just started
22117:C 15 Dec 2020 16:41:25.754 # Configuration loaded
[mhbtest@root redis-5.0.4]$ src/redis-cli -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值