1.复制配置文件到集群中 以此类推
cp /usr/local/redis/redis-6.2.1/redis.conf /usr/local/rediscluster/7001/7001.conf
2. 修改配置文件 以此类推
3.启动redis
4.
./redis-trib.rb create --replicas 1 192.168.96.128:7001 192.168.96.128:7002 192.168.96.128:7003 192.168.96.128:7004 192.168.96.128:7005 192.168.96.128:7006
常见问题
1.wget不是内部命令 2、yum安装
yum -y install wget
2.报错: redis requires Ruby version >= 2.2.2的报错,查了资料发现是Centos默认支持 ruby 到 2.0.0,可 gem 安装redis需要最低是2.2.2
查找相关的解决方案
执行的命令:
① 卸载当前ruby(当前使用centos系统)
yum remove ruby
② 下载ruby稳定版
cd /usr/local/rvm/rubies
wget https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.gz
③ 安装ruby
tar zxvf ruby-2.5.1.tar.gz
cd ruby-2.5.1
./configure --prefix=/usr/local/rvm
make && make install
④ 查看安装后的版本
/usr/local/rvm/bin/ruby -v
⑤ 镜像加速
此时使用gem install redis不会报错了,但是你会发现很慢,为了更快速的安装,这里使用国内的镜像(https://gems.ruby-china.com/) 执行若报错,https改为http
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
gem sources -l
出现异常:/usr/bin/gem: No such file or directory
解决方案:ln -s /usr/local/rvm/bin/gem /usr/bin/gem
⑥ 安装
gem install redis
6. 再次执行创建集群的命令
./redis-trib.rb create --replicas 1 10.0.192.64:7001 10.0.192.64:7002 10.0.192.64:7003 10.0.192.64:7004 10.0.192.64:7005 10.0.192.64:7006
[root@hart]/usr/local/redis-cluster/bin# ./redis-trib.rb create --replicas 1 10.0.192.64:7001 10.0.192.64:7002 10.0.192.64:7003 10.0.192.64:7004 10.0.192.64:7005 10.0.192.64:7006
.1.11:7004 192.168.1.11:7005 192.168.1.11:7006
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- redis (LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from ./redis-trib.rb:25
解决办法:1.下载 并上传redis-3.0.0.gem
2.执行 gem install redis-3.0.0.gem
参考博客:
https://blog.csdn.net/mst1010/article/details/80984699
https://blog.csdn.net/mst1010/article/details/80984699