将redis数据从slave恢复到master [英] Restore redis data from slave to master

查看:135
本文介绍了将redis数据从slave恢复到master的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在redis上不要丢失任何数据,而且它有很高的写请求,所以我不能使用AOF持久化.RDB可以提供帮助,但也许有可能丢失上次备份的一些数据.

I need to don't loss any data on redis and It has high write request,so I can't use AOF persistence.RDB can help be,but maybe It's possible to loss some of data from last backup.

现在我将复制视为备份,所以当主服务器崩溃、重启或其他任何事情时,我已经同步了从服务器中的数据并可以再次恢复.

Now I think about replication as backup,so when master crashed,restarted or anything else,I have synced data in slaves and can restore it again.

现在有什么办法可以设置master为slave,崩溃时slave自动为master,然后同步?

Now is there any way set master as slave,and slave as master at crashed time automatically,then sync them?

推荐答案

当您的应用程序知道 MASTER 已关闭时,应用程序应在 SLAVE 上发出以下命令:

When your application comes to know that MASTER is down, application should issue below command on SLAVE:

无人为奴

上述命令将使 SLAVE 成为 MASTER,您的应用程序现在可以继续使用它作为 MASTER.

The above command would make the SLAVE as MASTER and your application could continue using this as MASTER now.

当您的实际 MASTER 启动时,发出以下命令:

When your actual MASTER is up, issue following command:

SLAVEOF 主机名端口

SLAVEOF hostname port

这里的主机名和端口将用于旧的 SLAVE.这样就交换了主从配置.

Here hostname and port would be for the old SLAVE. With this the MASTER-SLAVE configuration is swapped.

这篇关于将redis数据从slave恢复到master的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆