AzureRedis系列之AzureRedis生成随机数据-创新互联

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

创新互联主营黄龙网站建设的网络公司,主营网站建设方案,app软件开发公司,黄龙h5成都小程序开发搭建,黄龙网站营销推广欢迎黄龙等地区企业咨询

对于这些需求,我们其实可以通过分析,来判断我们应该用什么样的方法进行迁移,对于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 生成随机数据

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

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

本文标题:AzureRedis系列之AzureRedis生成随机数据-创新互联
新闻来源:https://www.cdcxhl.com/article46/ppheg.html

成都网站建设公司_创新互联,为您提供动态网站面包屑导航电子商务Google商城网站移动网站建设

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

微信小程序开发