In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Shutdown service or kill the process to test whether data is lost
Turn off RDB persistence, start AOF persistence, and restart the redis service.
Set valu
127.0.0.1 6379 > mset K1 v1 K2 v2
OK
127.0.0.1 6379 > keys *
1) "K2"
2) "K1"
127.0.0.1 6379 > get K1
V1
127.0.0.1 6379 > get K2
"v2"
Shutdown service
127.0.0.1 purl 6379 > shutdown
Start the redis service
Check that the data is still there.
Redis-cli-a Redis2019!
Warning: Using a password with'- a 'option on the command line interface may not be safe.
127.0.0.1 6379 > keys *
1) "K2"
2) "K1"
Kill the redis process and start the redis service
Check that the value is still there.
Redis-cli-a Redis2019!
Warning: Using a password with'- a 'option on the command line interface may not be safe.
127.0.0.1 6379 > keys *
1) "K2"
2) "K1"
2. Abnormal test service leads to garbled appendonly.aof files.
AOF persistence is to write all operations into the file appendonly.aof.
View Fil
Cat appendonly.aof
2
$6
SELECT
, 1
0
* 5
$4
Mset
$2
K1
$2
V1
$2
K2
$2
V2
Edit the document and fill in the contents instead of messy documents.
Vi appendonly.aof
Sfsbdd
1213fns
2
$6
SELECT
, 1
0
* 5
$4
Mset
$2
K1
$2
V1
$2
K2
$2
V2
Dshfs
Sdfksh5&
Khdfjsj%$$
Oguduog7&*
Restart the redis service, access to redis discovery failed
Redis-cli-a Redis2019!
Warning: Using a password with'- a 'option on the command line interface may not be safe.
Could not connect to Redis at 127.0.0.1:6379: Connection refused
Could not connect to Redis at 127.0.0.1:6379: Connection refused
Use the fix command to repair files
[root@master1 data] # redis-check-aof-- fix appendonly.aof
0x 45: Expected prefix'*', got:'d'
AOF analyzed: size=114, ok_up_to=69, diff=45
This will shrink the AOF from 114 bytes, with 45 bytes, to 69 bytes
Continue? [y/N]: y
Successfully truncated AOF
Check the file and find that it has been repaired.
Cat appendonly.aof
2
$6
SELECT
, 1
0
* 5
$4
Mset
$2
K1
$2
V1
$2
K2
$2
V2
It is no problem to start redis service and access redis to view data
Redis-cli-a Redis2019!
Warning: Using a password with'- a 'option on the command line interface may not be safe.
127.0.0.1 6379 > keys *
1) "K1"
2) "K2"
127.0.0.1 6379 > del K1
(integer) 1
127.0.0.1 6379 > del K2
(integer) 1
127.0.0.1 6379 > mset K5 v5 K6 v6
OK
127.0.0.1 6379 > keys *
1) "K5"
2) "K6"
Edit redis.conf and turn on RDB persistence
Restart the redis service, access redis, and find that the data is only persisted by AOF, and there is no previous data persisted by RDB, which proves that AOF persistent data will be used first when two persistence configurations are enabled at the same time.
Redis-cli-a Redis2019!
Warning: Using a password with'- a 'option on the command line interface may not be safe.
127.0.0.1 6379 > keys *
1) "K6"
2) "K5"
3. Delete all data and make use of the characteristics of AOF to repair.
Delete data, stop service
127.0.0.1 purl 6379 > flushall
OK
127.0.0.1 purl 6379 > shutdown
Edit a file
Vi data/appendonly.aof
2
$6
SELECT
, 1
0
* 5
$4
Mset
$2
K1
$2
V1
$2
K2
$2
V2
2
$6
SELECT
.
SELECT
, 1
0
, 1
$8
Flushall
Delete the last line of flushall
Start the redis service
Discovery data recovery
Redis-cli-a Redis2019!
Warning: Using a password with'- a 'option on the command line interface may not be safe.
127.0.0.1 6379 > keys *
1) "K6"
2) "K5"
Reference:
Https://blog.csdn.net/qq_33101675/article/details/80631992
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.