• redis迁移工具-redis-migrate-tool使用测试


    https://github.com/vipshop/redis-migrate-tool
    一.安装redis-migrate-tool
    a.下载redis-migrate-tool软件包 https://codeload.github.com/vipshop/redis-migrate-tool/zip/master
    b.安装autoconf yum install autoconf automake libtool
      注意:autoconf需要2.64以上版本
      rpm -e --nodeps autoconf-2.63
      cd /usr/local/src
      wget ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.68.tar.gz
      tar -zxvf autoconf-2.68.tar.gz
      cd autoconf-2.68
      ./configure --prefix=/usr
      make && make install
    c.解压安装
      cd /usr/local/src
      unzip redis-migrate-tool-master.zip
      cd redis-migrate-tool-master
      autoreconf -fvi
      ./configure --prefix=/usr/local/redis-migrate/
      make
      make install
      echo "export PATH=$PATH:/usr/local/redis-migrate/sbin">>/etc/profile
      source /etc/profile

    二.测试
    测试环境简介(redis版本3.0.5,redis3.2版本不能使用此迁移工具)
    主机:192.168.196.128
    实例:192.168.196.128:6001....192.168.196.128:6008(共8个实例)
    安装目录及结构如下:(其中.sh结尾的文件为自定义的快捷脚本)
    [root@vhost02 redis-cluster3.0]# pwd
    /usr/local/redis-cluster3.0
    [root@vhost02 redis-cluster3.0]# ll
    total 112
    drwxr-xr-x. 2 root root 4096 May 18 01:45 bin
    drwxr-xr-x. 2 root root 4096 May 18 02:29 etc
    -rwxr-xr-x. 1 root root 80 May 18 02:24 load_data.sh
    drwxr-xr-x. 2 root root 4096 May 18 02:07 redis6001
    drwxr-xr-x. 2 root root 4096 May 18 02:40 redis6002
    drwxr-xr-x. 2 root root 4096 May 18 02:40 redis6003
    drwxr-xr-x. 2 root root 4096 May 18 01:45 redis6004
    drwxr-xr-x. 2 root root 4096 May 18 01:45 redis6005
    drwxr-xr-x. 2 root root 4096 May 18 02:23 redis6006
    drwxr-xr-x. 2 root root 4096 May 18 02:23 redis6007
    drwxr-xr-x. 2 root root 4096 May 18 02:23 redis6008
    -rwxr-xr-x. 1 root root 49186 May 18 02:26 redis-trib.rb
    -rwxr-xr-x. 1 root root 12 May 18 01:56 shutdown-all.sh
    -rwxr-xr-x. 1 root root 100 May 18 01:56 shutdown-cluster.sh
    -rwxr-xr-x. 1 root root 660 May 18 02:03 startup-all.sh
    -rwxr-xr-x. 1 root root 99 May 18 02:00 startup-cluster.sh

    1.有数据集群到无数据单点
    a.搭建集群(192.168.196.128:6001 192.168.196.128:6002 192.168.196.128:6003此处略去集群搭建过程)
    b.使用脚本往集群中添加数据
      more load_data.sh
      #!/bin/bash
      for((i=1;i<=20000;i++))
      do
      redis-cli -c -p 6001 set k$i v$i
      done
    c.检查下集群中的数据
      redis-cli -c -p 6003
      127.0.0.1:6001> info
      ...
      # Keyspace
      db0:keys=6656,expires=0,avg_ttl=0
    d.启动单实例192.168.196.128:6004,并查看数据
      [root@vhost02 redis-cluster]# ./startup-all.sh
      please enter the number that you want to startup[1|2|3|4..|all]4

      startup redis04 ...
      redis04 is ok

      redis-cli -p 6004
      127.0.0.1:6004> info
      ...
      # Keyspace
    e.修改迁移配置文件
      mkdir /usr/local/redis-migrate/etc
      vi c-s-rmt.conf
      [source]
      type: redis cluster
      servers:
      - 192.168.196.128:6001

      [target]
      type: single
      servers:
      - 192.168.196.128:6004

      [common]
      threads: 1
      step: 5
      mbuf_size: 512
      source_safe: false
    f.迁移
      redis-migrate-tool -c /usr/local/redis-migrate/etc/c-s-rmt.conf -o c-s.log -d
    g.检查数据
      redis-cli -p 6004
      # Keyspace
      db0:keys=20000,expires=0,avg_ttl=0
    h.集群写,单实例是否同步
      往集群实例6001中写添加key kx001
      添加成功后,查看6004中key总理,并查看kx001
      # Keyspace
      db0:keys=20001,expires=0,avg_ttl=0
      127.0.0.1:6004> get kx001
      "x001"
      同理删除key值
    结论:同步 redis-migrate-tool进程一直在后台运行,断掉进程后就不再同步。如果后面修改source上的数据target上没有也不会报错,动作仍旧会同步。

    2.单点到集群
      vi s-c-rmt.conf
      [source]
      type: single
      servers:
      - 192.168.196.128:6004

      [target]
      type: redis cluster
      servers:
      - 192.168.196.128:6001

      [common]
      threads: 1
      step: 5
      mbuf_size: 512
      source_safe: false
    结论:同上

    3.单点到单点
      more s-s-rmt.conf
      [source]
      type: single
      servers:
      - 192.168.196.128:6004

      [target]
      type: single
      servers:
      - 192.168.196.128:6005

      [common]
      threads: 1
      step: 5
      mbuf_size: 512
      source_safe: false
    结论:同上
    4.三节点集群到三节点集群
      more c-c-rmt.conf
      [source]
      type: redis cluster
      servers:
      - 192.168.196.128:6001

      [target]
      type: redis cluster
      servers:
      - 192.168.196.128:6006

      [common]
      threads: 1
      step: 5
      mbuf_size: 512
      source_safe: false
    结论:同上

    作者:jane.hoo 
    出处:jane.hoo的博客 http://www.cnblogs.com/janehoo/ 
    [人生不设限,生命不息,折腾不止] 
    您的支持是对博主最大的鼓励,感谢您的认真阅读。本文版权归作者所有,欢迎转载,但请保留该声明。
  • 相关阅读:
    ESB相关技术入门
    推荐两个界面原型设计工具GUIDesignStudio 和 Mockups For Desktop
    开源框架完美组合之Spring.NET + NHibernate + ASP.NET MVC + jQuery + easyUI 中英文双语言小型企业网站Demo
    各大网站架构总结笔记
    NUnit是一款优秀的开源回归测试框架
    2011 年最佳代码
    [转]WinForms UI Thread Invokes: An InDepth Review of Invoke/BeginInvoke/InvokeRequred
    ISAPI_Rewrite引起的IIS应用程序池崩溃(fatal communication error)
    微软一站式示例代码库(中文版)20110808版本, 新添加ASP.NET, Azure, Silverlight, WinForm等15个Sample
    Office系列在线预览
  • 原文地址:https://www.cnblogs.com/janehoo/p/6124455.html
Copyright © 2020-2023  润新知