Redis recovery of -aof

Jane say aof recovery process:

[@ ZFRC the root-YW-370 123-YJF the TEST-Redis] -9 Redis the pkill #
[@ ZFRC the root-YW-370 123-YJF-the TEST ~] # CD / var / the dir
[@ ZFRC the root-YW-YJF-TEST- 370123 ~] # rm -rf *
Clear out the existing environment backup files; then start the server process, adding new data

[root@ZFRC-YW-YJF-TEST-370123 redis]# ./bin/redis-server ./redis.conf
[root@ZFRC-YW-YJF-TEST-370123 redis]# ./bin/redis-server ./redis6380.conf
[root@ZFRC-YW-YJF-TEST-370123 redis]# ./bin/redis-server ./redis6381.conf
[root@ZFRC-YW-YJF-TEST-370123 redis]# ./bin/redis-cli
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> set site www.baidu.com
OK
127.0.0.1:6379> set name yjf
OK
127.0.0.1:6379> set addr bj
OK
127.0.0.1:6379> flushall
OK
127.0.0.1:6379> get name
(nil)

At this point you must first stop the service, avoid other people write, rewrite aof. Moreover aof records have flushall operation.
[the root @ ZFRC-YW-YJF-the TEST-370 123 the dir] # More laoyang-appendonly.aof
2
$. 6
the SELECT
$. 1
0
. 3
$. 3
SET
$. 4
Site
$ 13 is
www.baidu.com
. 3
$. 3
SET
$. 4
name
$. 3
YJF
. 3
$. 3
SET
$. 4
addr
$ 2
BJ
* 1
$ 8
flushall

127.0.0.1:6379> shutdown nosave --- shutdown operation is not logging
not connected>

Then edit it aof generated files. The last dangerous operation flushall to dd out. - Note recording format, usually * Start the command at the end;

[root @ ZFRC-YW-YJF -TEST-370123 dir] # vim laoyang-appendonly.aof
remove the following three lines, save and exit
* 1
$ 8
flushall

Then restart the service, landing inquiries, if it has, after exit, again landing the query
[root @ ZFRC-YW-YJF-the TEST-370 123 Redis] # ./bin/redis-server ./redis.conf
[root @ ZFRC- YJF the TEST---YW Redis 370 123] # ./bin/redis-cli
127.0.0.1:6379> GET name
(nil)
127.0.0.1:6379> Exit
[@ ZFRC the root-YW-370 123-YJF the TEST-Redis] # ./bin/redis-cli
127.0.0.1:6379> GET name
YJF

检查rdb文件
[root@ZFRC-YW-YJF-TEST-370123 redis]# ./bin/redis-check-rdb /var/dir/dump6380.rdb
[offset 0] Checking RDB file /var/dir/dump6380.rdb
[offset 27] AUX FIELD redis-ver = '3.2.13'
[offset 41] AUX FIELD redis-bits = '64'
[offset 53] AUX FIELD ctime = '1561537890'
[offset 68] AUX FIELD used-mem = '880976'
[offset 77] Checksum OK
[offset 77] \o/ RDB looks OK! \o/
[info] 0 keys read
[info] 0 expires
[info] 0 already expired

Guess you like

Origin blog.51cto.com/yangjunfeng/2414275