温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-05-21 08:53:22 来源:网络 阅读:454 作者:mxy00000 栏目:云计算

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


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


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

    这个程序本身是用node.js写的,所以我们首先需要准备好node.js的环境


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

    sudo yum install node.js

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


    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.1



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


    使用NPM安装各种包

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


    3.下载https://github.com/SaminOz/redis-random-data-generator里的文件,拷贝到服务器上,可以看到程序本身包含这些文件

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


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

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


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

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


    6.连接到Azure Redis,通过info可以看到数据量已经有200多M

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


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

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


    当然,不只是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可以查看帮助

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


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

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI