国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > Redis > 正文

Redis migrate數據遷移工具的使用教程

2020-10-28 21:27:08
字體:
來源:轉載
供稿:網友

前言

在工作中可能會遇到單點Redis向Redis集群遷移數據的問題,但又不能老麻煩運維來做。為了方便研發自己遷移數據,我這里寫了一個簡單的Redis遷移工具,希望對有需要的人有用。

本工具支持:

  • 單點Redis到單點Redis遷移
  • 單點Redis到Redis集群遷移
  • Redis集群到Redis集群遷移
  • Redis集群到單點Redis遷移

該工具已經編譯成了多平臺命令,直接從Github下載二進制文件執行就好了。

項目地址: https://github.com/icowan/redis-tool

把代碼拉下來之后直接執行命令 make 就可以編譯多個平臺可執行文件,需要依賴golang編譯器。

  • Windows amd64: redis-tool-windows-amd64.exe
  • MacOS amd64: redis-tool-darwin-amd64
  • Linux amd64: redis-tool-linux-amd64
  • Linux arm64: redis-tool-linux-arm64

查看使用方法:

$ chmod a+x redis-tool-linux-amd64$ ./redis-tool-linux-amd64 -h

支持的數據類型

  • string 字符串
  • hash 散列列表
  • list 列表
  • sorted-set 有序集合

如何使用

下載好命令并授權之后執行 ./redis-tool-linux-amd64 -h 可以查看該工具所支持的所有功能:

$ ./redis-tool-darwin-amd64 migrate -h數據遷移命令Usage:redis-tool migrate [command]Examples:支持命令:[hash, set, sorted-set, list]Available Commands:all  遷移所有hash 哈希列表遷移list 列表遷移 set  redis set 遷移sorted-set 有序集合遷移Flags: -h, --help   help for migrate --source-auth string 源密碼 --source-database int 源database --source-hosts string 源redis地址, 多個ip用','隔開 (default "127.0.0.1:6379") --source-prefix string 源redis前綴 --source-redis-cluster 源redis是否是集群 --target-auth string 目標密碼 --target-database int 目標database --target-hosts string 目標redis地址, 多個ip用','隔開 (default "127.0.0.1:6379") --target-prefix string 目標redis前綴 --target-redis-cluster 目標redis是否是集群Use "redis-tool migrate [command] --help" for more information about a command.

參數說明:

  • --source-auth: 源redis密碼,如果有的話就填
  • --source-database: 源database,默認是 0
  • --source-hosts: 源redis地址, 集群的多個ip用','隔開 (default "127.0.0.1:6379")
  • --source-prefix: 源redis前綴, 可不填
  • --source-redis-cluster: 源redis是否是集群, 默認 false
  • --target-auth: 遷移目標redis密碼,如果有的話就填
  • --target-database: 遷移目標database,默認是 0
  • --target-hosts: 遷移目標redis地址, 集群的多個ip用','隔開 (default "127.0.0.1:6379")
  • --target-prefix: 遷移目標redis前綴, 可不填
  • --target-redis-cluster: 遷移目標redis是否是集群, 默認 false

遷移單個key的數據

下面就舉兩個例子吧,其他的都差不太多。

Hash類型

可以通過命令 redis-tool migrate hash -h 查看使用說明

$ redis-tool migrate hash helloworld / --source-hosts 127.0.0.1:6379 / --target-redis-cluster true / --target-hosts 127.0.0.1:6379,127.0.0.1:7379 / --target-auth 123456

有序集合

可以通過命令 redis-tool migrate sorted-set -h 查看使用說明

有序集合的數據量可能會比較大,所以這里按 50000 為單位進行了切割。我這里測試過遷移近17000000萬條的數據,用時40多分鐘。

$ redis-tool migrate hash helloworld / --source-hosts 127.0.0.1:6379 / --target-redis-cluster true / --target-hosts 127.0.0.1:6379,127.0.0.1:7379 / --target-auth 123456

遷移所有key的數據支持通配符過濾

可以通過命令 redis-tool migrate all -h 查看使用說明

$ redis-tool migrate all "ipdetect:*" /  --source-hosts 127.0.0.1:6379 / --target-redis-cluster true / --target-hosts 127.0.0.1:6379,127.0.0.1:7379 / --target-auth 123456

這個命令會編譯匹配到的所有類型的key,再根據key的類型進行逐步遷移。

尾巴

使用golang寫的一個比較簡單的工具, 主要用于在Redis沒有持久化或多套Redis向一套Redis遷移的情況下使用。

總結

到此這篇關于Redis migrate數據遷移工具的文章就介紹到這了,更多相關Redis migrate數據遷移工具內容請搜索武林網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持武林網!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 白玉县| 西充县| 曲靖市| 兴城市| 浦城县| 洛川县| 枣阳市| 阳信县| 石狮市| 凤城市| 石屏县| 余江县| 济宁市| 兖州市| 郯城县| 青岛市| 麦盖提县| 庄浪县| 清远市| 娄底市| 康平县| 石泉县| 五河县| 桃园市| 新邵县| 子洲县| 普兰店市| 三门县| 当阳市| 永平县| 许昌县| 华容县| 巢湖市| 丁青县| 喀什市| 仲巴县| 乡城县| 巴东县| 东方市| 乃东县| 曲阜市|