Redis持久化之AOF重写机制测试-----Redis

文章详细描述了在Linux终端中对Redis服务器进行配置、删除RDB备份文件、使用AOF持久化机制以及清理键值对的过程,还展示了如何通过命令行接口执行关键操作如flushall和keys。
摘要由CSDN通过智能技术生成
[root@localhost ~]# cd /myredis
[root@localhost myredis]# vim redis.conf
[root@localhost myredis]# vim redis.conf
[root@localhost myredis]# ll
总用量 112
drwxr-xr-x. 2 root root    103 1月  18 15:26 appendonlydir
-rw-r--r--. 1 root root    121 1月  18 15:25 dump6379.rdb
-rw-r--r--. 1 root root 107528 1月  18 15:28 redis.conf
[root@localhost myredis]# rm rf dump6379.rdb
rm: 无法删除"rf": 没有那个文件或目录
rm:是否删除普通文件 "dump6379.rdb"?y         
[root@localhost myredis]# rm -rf dump6379.rdb
[root@localhost myredis]# ll
总用量 108
drwxr-xr-x. 2 root root    103 1月  18 15:26 appendonlydir
-rw-r--r--. 1 root root 107528 1月  18 15:28 redis.conf
[root@localhost myredis]# cd appendonlydir/
[root@localhost appendonlydir]# pwd
/myredis/appendonlydir
[root@localhost appendonlydir]# rm -rf *
[root@localhost appendonlydir]# ll
总用量 0
[root@localhost appendonlydir]# cd ..
[root@localhost myredis]# ll
总用量 108
drwxr-xr-x. 2 root root    103 1月  18 15:30 appendonlydir
-rw-r--r--. 1 root root 107528 1月  18 15:28 redis.conf
[root@localhost myredis]# cd appendonlydir/
[root@localhost appendonlydir]# ll
总用量 4
-rw-r--r--. 1 root root  0 1月  18 15:30 appendonly.aof.1.base.aof
-rw-r--r--. 1 root root  0 1月  18 15:30 appendonly.aof.1.incr.aof
-rw-r--r--. 1 root root 88 1月  18 15:30 appendonly.aof.manifest
[root@localhost appendonlydir]# ll
总用量 8
-rw-r--r--. 1 root root  0 1月  18 15:30 appendonly.aof.1.base.aof
-rw-r--r--. 1 root root 51 1月  18 15:30 appendonly.aof.1.incr.aof
-rw-r--r--. 1 root root 88 1月  18 15:30 appendonly.aof.manifest
[root@localhost appendonlydir]# vim appendonly.aof.1.incr.aof 
[root@localhost appendonlydir]# ll
总用量 8
-rw-r--r--. 1 root root  0 1月  18 15:30 appendonly.aof.1.base.aof
-rw-r--r--. 1 root root 51 1月  18 15:31 appendonly.aof.1.incr.aof
-rw-r--r--. 1 root root 88 1月  18 15:30 appendonly.aof.manifest
[root@localhost appendonlydir]# ll
总用量 8
-rw-r--r--. 1 root root  0 1月  18 15:30 appendonly.aof.1.base.aof
-rw-r--r--. 1 root root 51 1月  18 15:31 appendonly.aof.1.incr.aof
-rw-r--r--. 1 root root 88 1月  18 15:30 appendonly.aof.manifest
[root@localhost appendonlydir]# ll
总用量 8
-rw-r--r--. 1 root root  0 1月  18 15:30 appendonly.aof.1.base.aof
-rw-r--r--. 1 root root 51 1月  18 15:31 appendonly.aof.1.incr.aof
-rw-r--r--. 1 root root 88 1月  18 15:30 appendonly.aof.manifest
[root@localhost appendonlydir]# ll
总用量 8
-rw-r--r--. 1 root root  0 1月  18 15:30 appendonly.aof.1.base.aof
-rw-r--r--. 1 root root 51 1月  18 15:31 appendonly.aof.1.incr.aof
-rw-r--r--. 1 root root 88 1月  18 15:30 appendonly.aof.manifest
[root@localhost appendonlydir]# ll
总用量 8
-rw-r--r--. 1 root root 130 1月  18 15:32 appendonly.aof.2.base.aof
-rw-r--r--. 1 root root   0 1月  18 15:32 appendonly.aof.2.incr.aof
-rw-r--r--. 1 root root  88 1月  18 15:32 appendonly.aof.manifest
[root@localhost appendonlydir]# vim appendonly.aof.2.incr.aof 
[root@localhost appendonlydir]# vim appendonly.aof.2.base
[root@localhost appendonlydir]# vim appendonly.aof.2.base
appendonly.aof.2.base      appendonly.aof.2.base.aof
[root@localhost appendonlydir]# vim appendonly.aof.2.base.aof
[root@localhost appendonlydir]# vim /myredis/redis.conf
[root@localhost appendonlydir]# ll
总用量 8
-rw-r--r--. 1 root root   0 1月  18 15:33 appendonly.aof.2.base
-rw-r--r--. 1 root root 128 1月  18 15:35 appendonly.aof.2.base.aof
-rw-r--r--. 1 root root   0 1月  18 15:33 appendonly.aof.2.incr.aof
-rw-r--r--. 1 root root  88 1月  18 15:32 appendonly.aof.manifest

[root@localhost ~]# cd /myredis
[root@localhost myredis]# vim redis.conf
[root@localhost myredis]# vim redis.conf
[root@localhost myredis]# ll
总用量 112
drwxr-xr-x. 2 root root    103 1月  18 15:26 appendonlydir
-rw-r--r--. 1 root root    121 1月  18 15:25 dump6379.rdb
-rw-r--r--. 1 root root 107528 1月  18 15:28 redis.conf
[root@localhost myredis]# rm rf dump6379.rdb
rm: 无法删除"rf": 没有那个文件或目录
rm:是否删除普通文件 "dump6379.rdb"?y         
[root@localhost myredis]# rm -rf dump6379.rdb
[root@localhost myredis]# ll
总用量 108
drwxr-xr-x. 2 root root    103 1月  18 15:26 appendonlydir
-rw-r--r--. 1 root root 107528 1月  18 15:28 redis.conf
[root@localhost myredis]# cd appendonlydir/
[root@localhost appendonlydir]# pwd
/myredis/appendonlydir
[root@localhost appendonlydir]# rm -rf *
[root@localhost appendonlydir]# ll
总用量 0
[root@localhost appendonlydir]# cd ..
[root@localhost myredis]# ll
总用量 108
drwxr-xr-x. 2 root root    103 1月  18 15:30 appendonlydir
-rw-r--r--. 1 root root 107528 1月  18 15:28 redis.conf
[root@localhost myredis]# cd appendonlydir/
[root@localhost appendonlydir]# ll
总用量 4
-rw-r--r--. 1 root root  0 1月  18 15:30 appendonly.aof.1.base.aof
-rw-r--r--. 1 root root  0 1月  18 15:30 appendonly.aof.1.incr.aof
-rw-r--r--. 1 root root 88 1月  18 15:30 appendonly.aof.manifest
[root@localhost appendonlydir]# ll
总用量 8
-rw-r--r--. 1 root root  0 1月  18 15:30 appendonly.aof.1.base.aof
-rw-r--r--. 1 root root 51 1月  18 15:30 appendonly.aof.1.incr.aof
-rw-r--r--. 1 root root 88 1月  18 15:30 appendonly.aof.manifest
[root@localhost appendonlydir]# vim appendonly.aof.1.incr.aof 
[root@localhost appendonlydir]# ll
总用量 8
-rw-r--r--. 1 root root  0 1月  18 15:30 appendonly.aof.1.base.aof
-rw-r--r--. 1 root root 51 1月  18 15:31 appendonly.aof.1.incr.aof
-rw-r--r--. 1 root root 88 1月  18 15:30 appendonly.aof.manifest
[root@localhost appendonlydir]# ll
总用量 8
-rw-r--r--. 1 root root  0 1月  18 15:30 appendonly.aof.1.base.aof
-rw-r--r--. 1 root root 51 1月  18 15:31 appendonly.aof.1.incr.aof
-rw-r--r--. 1 root root 88 1月  18 15:30 appendonly.aof.manifest
[root@localhost appendonlydir]# ll
总用量 8
-rw-r--r--. 1 root root  0 1月  18 15:30 appendonly.aof.1.base.aof
-rw-r--r--. 1 root root 51 1月  18 15:31 appendonly.aof.1.incr.aof
-rw-r--r--. 1 root root 88 1月  18 15:30 appendonly.aof.manifest
[root@localhost appendonlydir]# ll
总用量 8
-rw-r--r--. 1 root root  0 1月  18 15:30 appendonly.aof.1.base.aof
-rw-r--r--. 1 root root 51 1月  18 15:31 appendonly.aof.1.incr.aof
-rw-r--r--. 1 root root 88 1月  18 15:30 appendonly.aof.manifest
[root@localhost appendonlydir]# ll
总用量 8
-rw-r--r--. 1 root root 130 1月  18 15:32 appendonly.aof.2.base.aof
-rw-r--r--. 1 root root   0 1月  18 15:32 appendonly.aof.2.incr.aof
-rw-r--r--. 1 root root  88 1月  18 15:32 appendonly.aof.manifest
[root@localhost appendonlydir]# vim appendonly.aof.2.incr.aof 
[root@localhost appendonlydir]# vim appendonly.aof.2.base
[root@localhost appendonlydir]# vim appendonly.aof.2.base
appendonly.aof.2.base      appendonly.aof.2.base.aof
[root@localhost appendonlydir]# vim appendonly.aof.2.base.aof
[root@localhost appendonlydir]# vim /myredis/redis.conf
[root@localhost appendonlydir]# ll
总用量 8
-rw-r--r--. 1 root root   0 1月  18 15:33 appendonly.aof.2.base
-rw-r--r--. 1 root root 128 1月  18 15:35 appendonly.aof.2.base.aof
-rw-r--r--. 1 root root   0 1月  18 15:33 appendonly.aof.2.incr.aof
-rw-r--r--. 1 root root  88 1月  18 15:32 appendonly.aof.manifest
 

127.0.0.1:6379> flushall
OK
127.0.0.1:6379> keys *
(empty array)
127.0.0.1:6379> quit
[root@localhost bin]# redis-server /myredis/redis.conf
[root@localhost bin]# redis-cli -a abc123
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> keys *
(empty array)
127.0.0.1:6379> shutdown
not connected> quit
[root@localhost bin]# redis-server /myredis/redis.conf
[root@localhost bin]# redis-cli -a abc123
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> keys *
1) "k3"
2) "k4"
3) "k2"
4) "k1"
127.0.0.1:6379> shutdown
not connected> quit
[root@localhost bin]# redis-server /myredis/redis.conf
[root@localhost bin]# redis-cli -a abc123
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> keys *
(empty array)
127.0.0.1:6379> set k1 1
OK
127.0.0.1:6379> get k1
"1"
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 2asdasdasdasdalsdkxzckajsdaskdxmzncaskdjaskdjasdmzx,mckajsdkasdmasndnxcnasdkasd
OK

 127.0.0.1:6379> flushall
OK
127.0.0.1:6379> keys *
(empty array)
127.0.0.1:6379> quit
[root@localhost bin]# redis-server /myredis/redis.conf
[root@localhost bin]# redis-cli -a abc123
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> keys *
(empty array)
127.0.0.1:6379> shutdown
not connected> quit
[root@localhost bin]# redis-server /myredis/redis.conf
[root@localhost bin]# redis-cli -a abc123
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> keys *
1) "k3"
2) "k4"
3) "k2"
4) "k1"
127.0.0.1:6379> shutdown
not connected> quit
[root@localhost bin]# redis-server /myredis/redis.conf
[root@localhost bin]# redis-cli -a abc123
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> keys *
(empty array)
127.0.0.1:6379> set k1 1
OK
127.0.0.1:6379> get k1
"1"
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 1111111111111111111111111111
OK
127.0.0.1:6379> set k1 2asdasdasdasdalsdkxzckajsdaskdxmzncaskdjaskdjasdmzx,mckajsdkasdmasndnxcnasdkasd
OK

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值