redis aof持久化

[C:\~]$ 

Connecting to 192.168.159.12:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Wed Mar 25 10:54:35 2020 from 192.168.159.1
[root@centos7002 ~]# cd /usr/local/bin/
[root@centos7002 bin]# ls -l
总用量 32744
-rw-r--r-- 1 root root     153 3月  23 11:50 dump_bk.rd
-rw-r--r-- 1 root root     153 3月  23 14:36 dump.rdb
-rwxr-xr-x 1 root root 4366608 3月  10 14:20 redis-benc
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-chec
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-chec
-rwxr-xr-x 1 root root 4806832 3月  10 14:20 redis-cli
lrwxrwxrwx 1 root root      12 3月  10 14:20 redis-sentver
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-serv
[root@centos7002 bin]# redis-server /myredis/redis.conf
20665:C 25 Mar 2020 19:00:23.352 # oO0OoO0OoO0Oo Redis O0OoO0Oo
20665:C 25 Mar 2020 19:00:23.352 # Redis version=5.0.5,00000000, modified=0, pid=20665, just started
20665:C 25 Mar 2020 19:00:23.352 # Configuration loaded
[root@centos7002 bin]# redis-cli -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> shutdown
not connected> exit
[root@centos7002 bin]# ls -l
总用量 32744
-rw-r--r-- 1 root root     153 3月  23 11:50 dump_bk.rd
-rw-r--r-- 1 root root     153 3月  25 19:08 dump.rdb
-rwxr-xr-x 1 root root 4366608 3月  10 14:20 redis-benc
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-chec
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-chec
-rwxr-xr-x 1 root root 4806832 3月  10 14:20 redis-cli
lrwxrwxrwx 1 root root      12 3月  10 14:20 redis-sent
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-serv
[root@centos7002 bin]# rm -f dump.red
[root@centos7002 bin]# rm -f dump.rdb
[root@centos7002 bin]# rm -f dump_bk.rdb 
[root@centos7002 bin]# ls -l
总用量 32736
-rwxr-xr-x 1 root root 4366608 3月  10 14:20 redis-benc
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-chec
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-chec
-rwxr-xr-x 1 root root 4806832 3月  10 14:20 redis-cli
lrwxrwxrwx 1 root root      12 3月  10 14:20 redis-sent
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-serv
[root@centos7002 bin]# redis-server /myredis/redis_aof.
21358:C 25 Mar 2020 19:10:16.407 # oO0OoO0OoO0Oo Redis 
21358:C 25 Mar 2020 19:10:16.407 # Redis version=5.0.5,d=21358, just started
21358:C 25 Mar 2020 19:10:16.407 # Configuration loaded
[root@centos7002 bin]# redis-cli -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> set k1 v1
OK
127.0.0.1:6379> set k2 v2
OK
127.0.0.1:6379> set k3 v3
OK
127.0.0.1:6379> set k4 v4
OK
127.0.0.1:6379> set k5 v5
OK
127.0.0.1:6379> flushall
OK
127.0.0.1:6379> shutdown
not connected> exit
[root@centos7002 bin]# redis-server /myredis/redis_aof.
22475:C 25 Mar 2020 19:29:21.049 # oO0OoO0OoO0Oo Redis 
22475:C 25 Mar 2020 19:29:21.049 # Redis version=5.0.5,d=22475, just started
22475:C 25 Mar 2020 19:29:21.049 # Configuration loaded
[root@centos7002 bin]# redis-cli 
appendonly.aof   redis-benchmark  redis-check-rdb  redi
dump.rdb         redis-check-aof  redis-cli        redi
[root@centos7002 bin]# redis-cli -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> shutdown
not connected> exit
[root@centos7002 bin]# redis-server /myredis/redis_aof.
23877:C 25 Mar 2020 19:53:31.094 # oO0OoO0OoO0Oo Redis 
23877:C 25 Mar 2020 19:53:31.094 # Redis version=5.0.5,d=23877, just started
23877:C 25 Mar 2020 19:53:31.094 # Configuration loaded
[root@centos7002 bin]# redis-cli -p 6379
127.0.0.1:6379> keys *
1) "k1"
2) "k2"
3) "k4"
4) "k5"
5) "k3"
127.0.0.1:6379> SHUTDOWN
not connected> exit
[root@centos7002 bin]# redis-server /myredis/redis_aof.
24025:C 25 Mar 2020 19:55:55.213 # oO0OoO0OoO0Oo Redis 
24025:C 25 Mar 2020 19:55:55.213 # Redis version=5.0.5,d=24025, just started
24025:C 25 Mar 2020 19:55:55.213 # Configuration loaded
[root@centos7002 bin]# redis-cli -p 6379
Could not connect to Redis at 127.0.0.1:6379: Connectio
not connected> exit
[root@centos7002 bin]# redis-server /myredis/redis_aof.
24173:C 25 Mar 2020 19:58:15.766 # oO0OoO0OoO0Oo Redis 
24173:C 25 Mar 2020 19:58:15.766 # Redis version=5.0.5,d=24173, just started
24173:C 25 Mar 2020 19:58:15.766 # Configuration loaded
[root@centos7002 bin]# redis-check-aof --flix appendonl
Invalid argument: --flix
[root@centos7002 bin]# redis-check-aof -flix appendonly
Invalid argument: -flix
[root@centos7002 bin]# redis-check-aof flix appendonly.
Invalid argument: flix
[root@centos7002 bin]# redis-check-aof --fix appendonly
0x              a8: Expected prefix '*', got: 'A'
AOF analyzed: size=267, ok_up_to=168, diff=99
This will shrink the AOF from 267 bytes, with 99 bytes,
Continue? [y/N]: y
Successfully truncated AOF
[root@centos7002 bin]# redis-server /myredis/redis_aof.
24395:C 25 Mar 2020 20:01:34.870 # oO0OoO0OoO0Oo Redis 
24395:C 25 Mar 2020 20:01:34.870 # Redis version=5.0.5,d=24395, just started
24395:C 25 Mar 2020 20:01:34.870 # Configuration loaded
[root@centos7002 bin]# redis-cli -p 6379
127.0.0.1:6379> keys *
1) "k1"
2) "k4"
3) "k3"
4) "k2"
5) "k5"
127.0.0.1:6379> shutdown
not connected> exit
 


[C:\~]$ 

Connecting to 192.168.159.12:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Wed Mar 25 18:59:10 2020 from 192.168.159.1
[root@centos7002 ~]# vi /myredis/redis.conf 
[root@centos7002 ~]# vi /myredis/redis.conf 
[root@centos7002 ~]# cd /myredis/
[root@centos7002 myredis]# ls -l
总用量 128
-rw-r--r-- 1 root root 61798 3月  23 11:35 redis.conf
-rw-r--r-- 1 root root 61797 3月  10 15:04 redis-init.conf
[root@centos7002 myredis]# cp redis.conf redis_aof.conf
[root@centos7002 myredis]# vi redis_aof.conf 
[root@centos7002 myredis]# ls -l
总用量 192
-rw-r--r-- 1 root root 61799 3月  25 19:06 redis_aof.conf
-rw-r--r-- 1 root root 61798 3月  23 11:35 redis.conf
-rw-r--r-- 1 root root 61797 3月  10 15:04 redis-init.conf
[root@centos7002 myredis]# cd 
[root@centos7002 ~]# cd /usr/local/bin/
[root@centos7002 bin]# ls -l
总用量 32736
-rw-r--r-- 1 root root       0 3月  25 19:10 appendonly.aof
-rwxr-xr-x 1 root root 4366608 3月  10 14:20 redis-benchmark
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-check-aof
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-check-rdb
-rwxr-xr-x 1 root root 4806832 3月  10 14:20 redis-cli
lrwxrwxrwx 1 root root      12 3月  10 14:20 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-server
[root@centos7002 bin]# ls -l
总用量 32744
-rw-r--r-- 1 root root     186 3月  25 19:12 appendonly.aof
-rw-r--r-- 1 root root      92 3月  25 19:12 dump.rdb
-rwxr-xr-x 1 root root 4366608 3月  10 14:20 redis-benchmark
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-check-aof
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-check-rdb
-rwxr-xr-x 1 root root 4806832 3月  10 14:20 redis-cli
lrwxrwxrwx 1 root root      12 3月  10 14:20 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-server
[root@centos7002 bin]# rm -f dump.rdb 
[root@centos7002 bin]# cat appendonly.aof 
*2
$6
SELECT
$1
0
*3
$3
set
$2
k1
$2
v1
*3
$3
set
$2
k2
$2
v2
*3
$3
set
$2
k3
$2
v3
*3
$3
set
$2
k4
$2
v4
*3
$3
set
$2
k5
$2
v5
*1
$8
flushall
[root@centos7002 bin]# ls -l
总用量 32740
-rw-r--r-- 1 root root     186 3月  25 19:12 appendonly.aof
-rwxr-xr-x 1 root root 4366608 3月  10 14:20 redis-benchmark
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-check-aof
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-check-rdb
-rwxr-xr-x 1 root root 4806832 3月  10 14:20 redis-cli
lrwxrwxrwx 1 root root      12 3月  10 14:20 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-server
[root@centos7002 bin]# vi appendonly.aof 
[root@centos7002 bin]# vi appendonly.aof 
[root@centos7002 bin]# ls -l
总用量 32744
-rw-r--r-- 1 root root     267 3月  25 19:55 appendonly.aof
-rw-r--r-- 1 root root     132 3月  25 19:54 dump.rdb
-rwxr-xr-x 1 root root 4366608 3月  10 14:20 redis-benchmark
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-check-aof
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-check-rdb
-rwxr-xr-x 1 root root 4806832 3月  10 14:20 redis-cli
lrwxrwxrwx 1 root root      12 3月  10 14:20 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-server
[root@centos7002 bin]# rm -f dump.rdb 
[root@centos7002 bin]# ls -l
总用量 32740
-rw-r--r-- 1 root root     267 3月  25 19:55 appendonly.aof
-rwxr-xr-x 1 root root 4366608 3月  10 14:20 redis-benchmark
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-check-aof
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-check-rdb
-rwxr-xr-x 1 root root 4806832 3月  10 14:20 redis-cli
lrwxrwxrwx 1 root root      12 3月  10 14:20 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 8111816 3月  10 14:20 redis-server
[root@centos7002 bin]# ps -ef|grep redis
root     24203 20748  0 19:58 pts/2    00:00:00 grep --color=auto redis
[root@centos7002 bin]# cat appendonly.aof 
*2
$6
SELECT
$1
0
*3
$3
set
$2
k1
$2
v1
*3
$3
set
$2
k2
$2
v2
*3
$3
set
$2
k3
$2
v3
*3
$3
set
$2
k4
$2
v4
*3
$3
set
$2
k5
$2
v5
[root@centos7002 bin]# vi /myredis/redis_aof.conf 
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值