slave 在退出后,也会在本地产生一个 rdb 文件,这个文件就是库的一个快照,下次启动后用来恢复内存状态
代码语言:javascript复制shutdown
Connection closed by foreign host.
[root@m2 tmp]# ps -ef | grep redis
root 5052 2119 0 14:50 pts/0 00:00:00 grep redis
[root@m2 tmp]# ls
dump.rdb my.cnf percona-release-0.1-3.noarch.rpm
epel-release-6-8.noarch2.rpm my.cnf.leopard redis-3.0.0
mha4mysql-manager-0.53-0.el6.noarch.rpm my.cnf.leopard.bak redis-3.0.0.tar.gz
mha4mysql-manager-0.53.tar.gz my.cnfrrrccc redis.conf
mha4mysql-node-0.53-0.el6.noarch.rpm my.cnf.tt redisnew.conf
[root@m2 tmp]#
如果删掉这个 rdb 文件,数据就会丢失
代码语言:javascript复制同步实际上是从 client 端发送了一个 SYNC 命令
[root@m2 tmp]# rm dump.rdb
rm: remove regular file `dump.rdb'? y
[root@m2 tmp]# ls
epel-release-6-8.noarch2.rpm my.cnf my.cnf.tt redis.conf
mha4mysql-manager-0.53-0.el6.noarch.rpm my.cnf.leopard percona-release-0.1-3.noarch.rpm redisnew.conf
mha4mysql-manager-0.53.tar.gz my.cnf.leopard.bak redis-3.0.0
mha4mysql-node-0.53-0.el6.noarch.rpm my.cnfrrrccc redis-3.0.0.tar.gz
[root@m2 tmp]# redis-server redisnew.conf
[root@m2 tmp]# telnet localhost 6379
Trying ::1...
Connected to localhost.
Escape character is '^]'.
keys *
*0
keys *
*0
sync
$18
REDIS0006³C띲V
keys *
*0
*1
$4
PING
keys *
*0
*1
$4
PING
*1
$4
PING
*1
$4
PING
keys *
*0
*1
$4
PING
quit
OK
Connection closed by foreign host.
[root@m2 tmp]# ls
dump.rdb my.cnf percona-release-0.1-3.noarch.rpm
epel-release-6-8.noarch2.rpm my.cnf.leopard redis-3.0.0
mha4mysql-manager-0.53-0.el6.noarch.rpm my.cnf.leopard.bak redis-3.0.0.tar.gz
mha4mysql-manager-0.53.tar.gz my.cnfrrrccc redis.conf
mha4mysql-node-0.53-0.el6.noarch.rpm my.cnf.tt redisnew.conf
[root@m2 tmp]#