Azure Redis 系列之 Azure Redis 生成随机数据

    接下来准备给各位介绍下如何来实现Azure Redis数据的迁移,咱们常常会收到一些需求,就是客户须要将线下或者其余云上的Redis迁移到微软的Azure Redis,或者是从微软的某个region的Azure redis迁移到其余regionnode


    对于这些需求,咱们其实能够经过分析,来判断咱们应该用什么样的方法进行迁移,对于Azure Redis premium版原本说,咱们是能够支持将数据导出到blob里,而后再导入到Premium版本的redis中的,这种迁移方法相对来讲比较简单粗暴,可是Premium版本并非每一个用户都会用的,并且Azure Redis也没办法从Premium版本降到Standard版本,因此这种迁移方法自己就有必定的局限性,以后准备介绍一个微软提供的跨region迁移Redis的方法,可是在这以前,咱们须要先准备一些测试的数据,测试数据要尽可能能模拟生产环境的模式,并且数据量不能过小,因此给各位介绍一个生成redis随机数据的工具linux


    首先感谢这位大佬提供的工具https://github.com/SaminOz/redis-random-data-generatorgit

    这个程序自己是用node.js写的,因此咱们首先须要准备好node.js的环境
github


    1.先在linux服务器装好node.jsredis

    sudo yum install node.jsjson

    1.png


    2.安装依赖包,文档中有很明确介绍都须要哪些包,直接安装就好
服务器

    

├─┬ lorem-ipsum@1.0.3
└─┬ optimist@0.3.7
└── wordwrap@0.0.3
├─┬ redis-stream@0.1.0
└─┬ event-stream@2.1.9
├── from@0.1.3
├── optimist@0.2.8
└── through@0.0.4
└── uuid@3.0.1session



    2.png


    使用NPM安装各类包dom

    3.png   


    3.下载https://github.com/SaminOz/redis-random-data-generator里的文件,拷贝到服务器上,能够看到程序自己包含这些文件ide

    4.png


    4.编辑config.json,添加Azure redis地址还有key

5.png


    5.运行node generator.js string 999999,随机插入999999条数据到Azure Redis

6.png


    6.链接到Azure Redis,经过info能够看到数据量已经有200多M

7.png


    8.查询数据,能够看到生成的都是一些随机数据

9.png


    固然,不仅是string,这个程序还能够支持redis其余格式的数据,用起来仍是很方便的

    

    如下是这个程序的一些基本用法

    Basic Usage:

    node generator.js <type> <qty> [<key_prefix>]

    This will enter <qty> of <type> entries into the redis instance

    running at the server and port address set in the config.json

    file.

    If <key_prefix> is set then this will be prepended to the key (uuid) separated by a ":" - thanks to Alfonso Montero for this contribution

    node generator.js hash 100 session

    1)...

    100) "session:ffab3b35-09c3-4fd7-9af1-4d323534065e"

    

    Types (others may be added in future versions i.e. geohash):

    'string' uses SET to add a redis string value

    'list' uses LPUSH to add a random number of values to a list

    'set' uses SADD to add a random number of values to a set

    'sorted' uses ZADD to add a random number of values and scores

    to a sorted set.

    'hash' uses HMSET to add a random number of values to a hash


    node generator.js –help能够查看帮助

    10.png


    准备好数据以后,就能够看如何迁移了!

相关文章
相关标签/搜索