Redis-dump 文档和地址: https://github.com/delano/redis-dump/ https://rubygems.org/gems/redis-dump 安装r uby 依赖: yum install -y gcc-c + + patch readline readline-devel zlib zlib-devel \ libyaml-devel li
Redis-dump 文档和地址:
https://github.com/delano/redis-dump/
https://rubygems.org/gems/redis-dump
安装ruby依赖:
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel \libyaml-devel libffi-devel openssl-devel make \
bzip2 autoconf automake libtool bison iconv-devel sqlite-devel
安装系统ruby:
yum install ruby -y
替换ruby源:
gem sources --remove https://rubygems.org/gem sources -a https://mirrors.aliyun.com/rubygems/
gem source -l
安装rvm:
yum install curl -ycurl -L get.rvm.io | bash -s stable
报错:
[root@harbor ~]# curl -sSL https://get.rvm.io | bash -s stable
curl: (7) Failed connect to raw.githubusercontent.com:443; Connection refused
解决办法:
打开网站https://www.ipaddress.com/,查询一下raw.githubusercontent.com对应的IP 地址。
/etc/hosts文件新增:
185.199.108.133 raw.githubusercontent.com/etc/resolv.conf文件新增:
nameserver 8.8.8.8
输出内容复制下面内容运行:
command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -command curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -
再次运行:
curl -L get.rvm.io | bash -s stable更新配置文件:
source /etc/profile.d/rvm.sh安装ruby2.3.3版本:
安装中替换老的ruby.
rvm install 2.3.3 (2.3.3以上版本都可以)
查看可以安装的Ruby版本:
rvm list known安装备份工具redis-dump:
gem install redis-dump -V
测试redis-dump备份:
第一种写法:
[root@harbor ~]# redis-dump -u:redhat@127.0.0.1:6379 > /backup/db_full.json[root@harbor ~]# cat /backup/db_full.json
{"db":0,"key":"name","ttl":-1,"type":"string","value":"mew","size":3}
第二种写法:
[root@harbor ~]# redis-dump -p 6379 -a redhat > /backup/db2.json[root@harbor ~]# cat /backup/db2.json
{"db":0,"key":"name","ttl":-1,"type":"string","value":"mew","size":3}
测试name值改为meng,再新建一个值,恢复看是否会覆盖或者影响其他值:
新建的2个key:
恢复备份:
# cat /backup/db_full.json | redis-load -u:redhat@127.0.0.1:6379
【文章原创作者:华为云代理 http://www.558idc.com/hw.html处的文章,转载请说明出处】