Redis高可用部署

Get:redis cluster 部署,主备切换,在线扩容,动态增删节点


1.centos7 安装redis cluster

#下载redis压缩包
wget http://download.redis.io/releases/redis-4.0.10.tar.gz       

#解压
tar -zxvf redis-4.0.10.tar.gz   

#移动redis文件夹到usr/local目录
mv redis-4.0.10 /usr/local/   

#编译
make

#编译测试
make test 

make出现异常:/bin/sh: cc: command not found

安装:yum -y install gcc

继续make 出现error: jemalloc/jemalloc.h: No such file or directory 

解决:make MALLOC=libc

make test 问题:You need tcl 8.5 or newer in order to run the Redis test

解决:yum install tcl

2. 集群部署

#创建集群目录

mkdir cluster-redis

#创建节点文件夹 7006为后续节点扩容备用

mkdir 7000 7001 7002 7003 7004 7005 7006

#每个节点创建redis.conf 如下:

touch redis-7000.conf

port 7000
bind 127.0.0.1
daemonize yes
cluster-enabled yes
cluster-config-file nodes_7000.conf
cluster-node-timeout 15000

#启动节点 6个全部启动

#查询redis节点

#安装Ruby
yum -y install ruby rubygems

#安装rvm
curl -L get.rvm.io | bash -s stable

如报错执行: gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

#继续按照rvm
curl -L get.rvm.io | bash -s stable
source /usr/local/rvm/scripts/rvm

#查看rvm库中已知的ruby版本
rvm list known
#安装ruby
rvm install 2.5.1
#使用新版本
rvm use 2.5.1
#移除旧版本
rvm remove 2.0.0
#查看当前版本
ruby --version

#安装相关依赖
gem install redis

3. 启动集群

[root@localhost src]#  ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005

如图:代表启动成功

4. 相关命令操作

查看集群信息

集群节点查看

猜你喜欢

转载自blog.csdn.net/u011385940/article/details/82800931