【Redis】redis-dump 安装指南

如果你是语雀使用者,推荐到语雀阅读文章:《redis-dump 安装指南》

redis-dump 工具用于集群中的数据迁移:

  1. yum 安装依赖
  2. 安装 rvm
  3. 安装 ruby
  4. 安装 redis-dump

1、yum 安装依赖


由于 安装redis-dump 工具需要使用rvm 和gem工具所以要提前安装:

[root@localhost ~]# yum -y install zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget curl 

2、安装 rvm


下载密钥:

[root@localhost ~]# gpg2 --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3

出现下面的情况:

gpgkeys: HTTP fetch error 6: Colud not resolve host: keys.gnupg.net; Name or service not known
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0

这个问题的解决方法见我这篇文章:redis 下载密钥报错

问题解决之后检查是否安装成功:

[root@localhost ~]# find / -name rvm -print

可以看到 rvm 安装成功!

激活 RVM(Ruby Version Manager)的命令。这个命令会加载 RVM 的相关环境变量和函数,以便在后续可以在当前的终端会话中使用 RVM 来管理 Ruby 版本和相关的 Gem 环境。

[root@localhost ~]# source /etc/profile.d/rvm.sh

检查和安装 RVM 所需的系统依赖

[root@localhost ~]# rvm requirements

安装在 Ruby 环境中常用的一些依赖项

[root@localhost ~]# rvmsudo yum -y install gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel

以下是每个软件包的含义:

至此,rvm 安装完毕!

3、安装 ruby


依次执行下面命令:

[root@localhost ~]# yum -y install automake autoconf libtool			# 安装软件构建和编译的工具
[root@localhost ~]# yum -y install ruby rubygems ruby-devel				# 安装 Ruby 运行时环境、RubyGems 和相关开发文件。
[root@localhost ~]# gem source --add https://gems.ruby-china.com		# 新建gem中国本地源

[root@localhost ~]# gem source -l																		# 查看gem源
*** CURRENT  SOURCES ***
https://rubygems.org/										# 默认的官方源
https://gems-ruby-china.com							        # 新添加的国内源

[root@localhost ~]# gem source --remove RubtGems.org | your community gem host 	# 删除国外官方源

[root@localhost ~]# rvm --version 																	# 验证rvm版本
rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

[root@localhost ~]# ruby --version    															# 验证ruby版本
ruby 2.0.0p648 (2015-12-16) [x86_64-linux]

这里需要升级一下ruby版本,2.0.0版本无法正常安装redis-dump

[root@localhost ~]# rvm list known						# 可以查看rvm支持的安装版本
[root@localhost ~]# rvm install "ruby-2.4.0"  # 这里是安装ruby2.4.0这一步很慢,根据网络情况来看
Install of ruby-2.3.3 - #complete
Please be aware that you just installed a ruby that requires 2 patches just to be compiled on an up to date linux system.
This may have known and unaccounted for security vulnerabilities.
Please consider upgrading to tuby-3.0.0 which which will have all of the latest security patches.
Ruby was built without documentation, to build it run: rvm docs generate-ri

在安装 ruby-2.4.0 的时候,可能会失败多次,失败的时候重试就行了,最终安装成功:

to build it run: rvm docs generate-ri

[root@localhost ~]# ruby docs generate-ri  		# 这里说ruby3.0.0版本有两个漏洞,需要手动打补丁
[root@localhost ~]# ruby --version						# 验证版本是否已更新
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]

4、安装 redis-dump


[root@localhost ~]# gem install redis-dump

如果在上面安装的是 ruby 2.4.0 之前的版本,可能会报错:

ERROR: Error installing redis-dump:

The last version of redis (>=4.0) to support your Ruby & RubyGems was 4.4.0. Try installing it with `gem install redis -v 4.4.0` and then running the current command agagin

redis requires Ruby version >= 2.4.0. The current ruby version is 2.3.3.222.

有两种解决方案:

1、升级 Ruby 版本:你可以尝试升级你的 Ruby 版本以满足 redis-dump gem 的要求。你可以使用 RVM 或 rbenv 等 Ruby 版本管理工具来安装较新的 Ruby 版本。例如,升级到 Ruby

rvm install 2.4.0
rvm use 2.4.0

2、安装兼容版本的 redis gem:根据错误消息,redis gem 要求版本 4.4.0 兼容于你的 Ruby 版本。你可以尝试安装这个特定版本的 redis gem,然后再安装 redis-dump gem:

[root@localhost ~]# gem install redis -v 4.4.0

然后再次运行:

[root@localhost ~]# gem install redis-dump

安装成功!

Done installing documentation for yajl-ruby, redis-dump after 0 seconds 2 gems installed

  • 6
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值