国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 數(shù)據(jù)庫(kù) > Redis > 正文

Redis數(shù)據(jù)備份與恢復(fù)方法

2020-02-17 14:53:40
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

武林技術(shù)頻道的編輯在這里給你們來(lái)講解一個(gè)簡(jiǎn)單粗暴的Redis數(shù)據(jù)備份與恢復(fù)方法,有一個(gè)在不同主機(jī)上遷移Redis數(shù)據(jù)的示例,還有一個(gè)備份腳本實(shí)現(xiàn)的關(guān)鍵點(diǎn)提示,下面一起來(lái)看一下。

示例

目標(biāo):把服務(wù)器CentOS上的redis數(shù)據(jù)復(fù)制到Mac機(jī)上

步驟:

在CentOS上找dump文件位置

vi /etc/redis.confdbfilename dump.rdb dir /var/lib/redis

說(shuō)明文件在

/var/lib/redis/dump.rdb

在mac上查找dump文件位置

vi /usr/local/etc/redis.confdbfilename dump.rdb dir /usr/local/var/db/redis

拷貝服務(wù)器上的dump.rdb到mac機(jī)器

scp root@dv:/var/lib/redis/dump.rdb ./

在mac上重啟Redis

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist


PS:備份腳本
看如下腳本,

#! /bin/bashPATH=/usr/local/bin:$PATHredis-cli SAVEdate=$(date +"%Y%m%d")cp /var/lib/redis/6379/dump.rdb /data01/cache_backup/$date.rdbecho "done!"

有如上腳本,便可以cron等方式備份redis數(shù)據(jù)文件了。細(xì)節(jié)如下:
首先必須進(jìn)行SAVE, 因?yàn)閞edis的rdb文件并非總是內(nèi)存數(shù)據(jù)的完整鏡像,備份之前必須進(jìn)行SAVE,即向其發(fā)送SAVE命令,其次拷貝走其rdb文件即可。
rdb的具體路徑不一定是如上路徑,可以在redis配置文件中查找, /etc/redis/6379.conf

# The filename where to dump the DBdbfilename dump.rdb# The working directory.## The DB will be written inside this directory, with the filename specified# above using the 'dbfilename' configuration directive.## Also the Append Only File will be created inside this directory.## Note that you must specify a directory here, not a file name.dir /var/lib/redis/6379

以上就是關(guān)于Redis數(shù)據(jù)備份與恢復(fù)方法,希望能對(duì)大家的學(xué)習(xí)或者工作帶來(lái)一些便捷,如果有大家有疑問(wèn)也可以留言交流,謝謝大家對(duì)武林技術(shù)頻道的支持。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 噶尔县| 增城市| 西乌珠穆沁旗| 北流市| 扎兰屯市| 通辽市| 循化| 禄劝| 武功县| 忻州市| 固安县| 太谷县| 汾阳市| 阿克| 明溪县| 成武县| 二连浩特市| 卢氏县| 襄垣县| 漯河市| 屯门区| 佳木斯市| 贵溪市| 永定县| 安顺市| 保亭| 藁城市| 肇州县| 闸北区| 白山市| 重庆市| 宁波市| 崇礼县| 东丽区| 华阴市| 宁城县| 原平市| 原平市| 长子县| 汉中市| 哈巴河县|