markdown 移动Redis

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 移动Redis相关的知识,希望对你有一定的参考价值。

### Create a dump on server A ###

```
A$ redis-cli
127.0.0.1:6379> CONFIG GET dir
1) "dir"
2) "/var/lib/redis/"
127.0.0.1:6379> SAVE
OK
```

This ensures dump.rdb is completely up-to-date, and shows us where it is stored (/var/lib/redis/dump.rdb in this case). dump.rdb is also periodically written to disk automatically.

### Copy it to server B ###

```
A$ scp /var/lib/redis/dump.rdb myuser@B:/tmp/dump.rdb
```

### Stop the Redis server on B, copy dump.rdb (ensuring permissions are the same as before), then start. ###

```
B$ sudo service redis-server stop
B$ sudo cp /tmp/dump.rdb /var/lib/redis/dump.rdb
B$ sudo chown redis: /var/lib/redis/dump.rdb
B$ sudo service redis-server start
```

The version of Redis on B must be greater or equal than that of A, or you may hit compatibility issues.
### This is worked ###

* Stop redis (because redis overwrites the current rdb file when it exits).
* Copy your backup rdb file to the redis working directory (this is the dir option in your redis config). Also make sure your backup filename matches the dbfilename config option.
* Change the redis config appendonly flag to no (otherwise redis will ignore your rdb file when it starts).
* Start redis.
* Run redis-cli BGREWRITEAOF to create a new appendonly file.
* Restore redis config appendonly flag to yes.

以上是关于markdown 移动Redis的主要内容,如果未能解决你的问题,请参考以下文章

markdown [redis常用命令] #bash #redis

markdown [Redis]同一台服务器上的多个Redis实例#linux

markdown Azure Redrest for Redis

markdown Redis的

markdown Redis Template配置和使用

markdown [例外] #exception #redis