How do I set an elasticache redis cluster as a slave?

≯℡__Kan透↙ 提交于 2019-12-11 01:37:01

问题


According to Elasticache manual, the SLAVEOF command is restricted for AWS cache nodes.

Is there anyway to set an existing Elasticache node as a slave so that I can migrate my existing redis cluster over to AWS?


回答1:


As you've spotted, Elasticache doesn't support the SLAVEOF command so you can't simply add an Elasticache node to your existing cluster and then promote it to the primary node/switch off your existing cluster.

Instead, to migrate your Redis cluster you should create a snapshot by using either BGSAVE or SAVE to produce a .rdb snapshot file.

You should then upload this snapshot file to S3 and allow Elasticache access to the file:

To grant ElastiCache read access to the snapshot copied to Amazon S3

  1. Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/.

  2. Click All Buckets, and then click the name of the Amazon S3 bucket that contains your .rdb file.

  3. Click the name of the folder that contains your .rdb file.

  4. Click the name of your .rdb file, click the Actions drop-down menu, and then select Properties.

  5. Click Permissions, and then click Add more permissions.

  6. In the Grantee box, type this email address: aws-scs-s3-readonly@amazon.com.

Important For the following regions, connect to the region specific canonical ID rather than aws-scs-s3-readonly@amazon.com: China (Beijing) region: b14d6a125bdf69854ed8ef2e71d8a20b7c490f252229b806e514966e490b8d83 EU (Frankfurt) region: 540804c33a284a299d2547575ce1010f2312ef3da9b3a053c8bc45bf233e4353 AWS GovCloud (US) region: 40fa568277ad703bd160f66ae4f83fc9dfdfd06c2f1b5060ca22442ac3ef8be6 Note The snapshot must be located in a GovCloud S3 bucket for you to download it to a GovCloud Redis cluster. Note The aws-scs-s3-readonly@amazon.com account is used exclusively for customers uploading Redis snapshot data from Amazon S3.

  1. Click Open/Download, and then click Save.

After this, simply create a new Redis backed Elasticache cluster and in the configuration section you should specify the S3 location of your snapshot file.

This will seed your new Elasticache cluster with your existing cluster's data taken from the snapshot but obviously you will still have to deal with either downtime, data loss or you would have to work out a way to replay the AOF log into the Elasticache cluster using something like this aof-replay tool.

Amazon's docs go into more detail here.



来源:https://stackoverflow.com/questions/30255626/how-do-i-set-an-elasticache-redis-cluster-as-a-slave

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!