AzureRedis系列之AzureRedis生成隨機(jī)數(shù)據(jù)

????接下來準(zhǔn)備給各位介紹下如何來實(shí)現(xiàn)Azure redis數(shù)據(jù)的遷移,我們經(jīng)常會收到一些需求,就是客戶需要將線下或者其他云上的Redis遷移到微軟的Azure Redis,或者是從微軟的某個region的Azure redis遷移到其他region

創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供集美網(wǎng)站建設(shè)、集美做網(wǎng)站、集美網(wǎng)站設(shè)計(jì)、集美網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、集美企業(yè)網(wǎng)站模板建站服務(wù),十余年集美做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。

????對于這些需求,我們其實(shí)可以通過分析,來判斷我們應(yīng)該用什么樣的方法進(jìn)行遷移,對于Azure Redis premium版本來說,我們是可以支持將數(shù)據(jù)導(dǎo)出到blob里,然后再導(dǎo)入到Premium版本的redis中的,這種遷移方法相對來說比較簡單粗暴,但是Premium版本并不是每個用戶都會用的,而且Azure Redis也沒辦法從Premium版本降到Standard版本,所以這種遷移方法本身就有一定的局限性,之后準(zhǔn)備介紹一個微軟提供的跨region遷移Redis的方法,但是在這之前,我們需要先準(zhǔn)備一些測試的數(shù)據(jù),測試數(shù)據(jù)要盡量能模擬生產(chǎn)環(huán)境的模式,而且數(shù)據(jù)量不能太小,所以給各位介紹一個生成redis隨機(jī)數(shù)據(jù)的工具

????首先感謝這位大佬提供的工具h(yuǎn)ttps://github.com/SaminOz/redis-random-data-generator

????這個程序本身是用node.js寫的,所以我們首先需要準(zhǔn)備好node.js的環(huán)境

? ? 1.先在linux服務(wù)器裝好node.js

????sudo yum install node.js

????Azure Redis 系列之 Azure Redis 生成隨機(jī)數(shù)據(jù)

????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 生成隨機(jī)數(shù)據(jù)

????使用NPM安裝各種包

????Azure Redis 系列之 Azure Redis 生成隨機(jī)數(shù)據(jù)? ?

????3.下載https://github.com/SaminOz/redis-random-data-generator里的文件,拷貝到服務(wù)器上,可以看到程序本身包含這些文件

????Azure Redis 系列之 Azure Redis 生成隨機(jī)數(shù)據(jù)

????4.編輯config.json,添加Azure redis地址還有key

Azure Redis 系列之 Azure Redis 生成隨機(jī)數(shù)據(jù)

????5.運(yùn)行node generator.js string 999999,隨機(jī)插入999999條數(shù)據(jù)到Azure Redis

Azure Redis 系列之 Azure Redis 生成隨機(jī)數(shù)據(jù)

????6.連接到Azure Redis,通過info可以看到數(shù)據(jù)量已經(jīng)有200多M

Azure Redis 系列之 Azure Redis 生成隨機(jī)數(shù)據(jù)

????8.查詢數(shù)據(jù),可以看到生成的都是一些隨機(jī)數(shù)據(jù)

Azure Redis 系列之 Azure Redis 生成隨機(jī)數(shù)據(jù)

????當(dāng)然,不只是string,這個程序還可以支持redis其他格式的數(shù)據(jù),用起來還是很方便的

????

????以下是這個程序的一些基本用法

????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 生成隨機(jī)數(shù)據(jù)

????準(zhǔn)備好數(shù)據(jù)之后,就可以看如何遷移了!

文章名稱:AzureRedis系列之AzureRedis生成隨機(jī)數(shù)據(jù)
轉(zhuǎn)載來源:http://bm7419.com/article36/gejppg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、搜索引擎優(yōu)化移動網(wǎng)站建設(shè)、微信小程序、網(wǎng)站設(shè)計(jì)公司企業(yè)網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站