Home  >  Q&A  >  body text

Redis 如何迁移数据?

正在运行的 Redis 服务,想迁移到另一台服务器,该如何迁移?
有类似 MySQL 的导入导出功能吗?

ringa_leeringa_lee2760 days ago874

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-21 11:20:29

    The redis service has a replication function. You can execute the SLAVEOF command or set the slaveof option to let one server replicate another server, commonly known as "master-slave synchronization" (the replication logic of redis version 2.8 and versions lower than 2.8 is different, so you need to Note), therefore, data migration is divided into the following steps:

    1. The target server for migration is set as the slave server of the migrated server
    2. After the slave catches up with the progress of the master, stop writing redis business (if shutdown is not possible, you need to consider redoing the pipeline during the migration, or perform the migration during the off-peak period of the business and accept the short-term data loss)
    3. After the master-slave server is fully synchronized, modify and write the redis business configuration, point it to the slave server, and disconnect the master-slave relationship
    4. Resume writing redis business

    redis replication function customer reference: link description

    In addition, the redis instance running on the external network must set up master-slave and turn on the persistence option (redis has two persistence strategies: RDB and AOF) to prevent single points of failure

    reply
    0
  • PHP中文网

    PHP中文网2017-04-21 11:20:29

    1. Back up the current redis, there will be a dump.rdb file
    2. Copy the file to the redis directory of another server
    3. Restart redis and it will be OK

    reply
    0
  • Cancelreply