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

首頁 > 數據庫 > Redis > 正文

簡單粗暴的Redis數據備份和恢復方法

2020-10-28 21:39:07
字體:
來源:轉載
供稿:網友

示例

目標:把服務器CentOS上的redis數據復制到Mac機上

步驟:

在CentOS上找dump文件位置

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

說明文件在

/var/lib/redis/dump.rdb

在mac上查找dump文件位置

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

拷貝服務器上的dump.rdb到mac機器

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數據文件了。細節如下:
首先必須進行SAVE, 因為redis的rdb文件并非總是內存數據的完整鏡像,備份之前必須進行SAVE,即向其發送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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 托克托县| 桂平市| 循化| 南乐县| 桦甸市| 博客| 大名县| 桦南县| 绥滨县| 峨眉山市| 阿拉善右旗| 芜湖县| 昂仁县| 杂多县| 长春市| 庆城县| 康定县| 新乡市| 抚顺市| 大丰市| 永川市| 汉川市| 嘉黎县| 神池县| 获嘉县| 衡东县| 宜城市| 光山县| 西充县| 陆河县| 兴宁市| 宁国市| 南澳县| 井冈山市| 天全县| 金华市| 石城县| 玉树县| 金坛市| 奉新县| 石台县|