资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

AzureRedis系列之AzureRedis生成随机数据

    接下来准备给各位介绍下如何来实现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 []

    This will enter of entries into the redis instance

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

    file.

    If 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 生成随机数据

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


网站题目:AzureRedis系列之AzureRedis生成随机数据
网站地址:http://cdkjz.cn/article/gejppg.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220