部署3主3从redis伪集群

Posted Ray_chen

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了部署3主3从redis伪集群相关的知识,希望对你有一定的参考价值。

安装redis
mkdir -p /data/apps
yum -y install gcc tcl make gcc++
wget http://download.redis.io/releases/redis-4.0.0.tar.gz
tar xzf redis-4.0.0.tar.gz
cd redis-4.0.0
make && make install PREFIX=/data/apps/redis
cd /data/apps/redis
mkdir conf
cp /opt/redis-4.0.0/redis.conf ./conf
useradd -M redis
chown -R redis.redis /data/apps/redis
chmod g+s /data/apps/redis

mkdir -pv cluster/{7000,7007,7002,7003,7004,7005}
cp conf/redis.conf cluster/7000/redis.conf
cd cluster
vim 7000/redis.conf
# 端口号
port 7000
# 后台启动
daemonize yes
# 开启集群
cluster-enabled yes
#集群节点配置文件
cluster-config-file nodes-7000.conf
# 集群连接超时时间
cluster-node-timeout 5000
# 进程pid的文件位置
pidfile /var/run/redis-7000.pid
# 开启aof
appendonly yes
# aof文件路径
appendfilename "appendonly-7005.aof"
# rdb文件路径
dbfilename dump-7000.rdb


cp 7000/redis.conf ./{7001,7002,7003,7004,7005}/
sed -i ‘s/7000/7001/p‘ cluster/7001/redis.conf
sed -i ‘s/7000/7002/p‘ cluster/7002/redis.conf
sed -i ‘s/7000/7003/p‘ cluster/7003/redis.conf
sed -i ‘s/7000/7004/p‘ cluster/7004/redis.conf
sed -i ‘s/7000/7005/p‘ cluster/7005/redis.conf


cat <<EOF > start.sh
bin/redis-server cluster/7000/redis.conf
bin/redis-server cluster/7001/redis.conf
bin/redis-server cluster/7002/redis.conf
bin/redis-server cluster/7003/redis.conf
bin/redis-server cluster/7004/redis.conf
bin/redis-server cluster/7005/redis.conf

chmod +x start.sh
./start.sh


安装ruby
yum install ruby rubygems -y
gem install redis -y

安装rvm

1 导入秘钥
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
** 或提示找不到有效OpenPGP 数据,执行
curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -

2. 安装rvm
curl -sSL https://get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm install 2.3.0
rvm use 2.3.0 --default
ruby -v
gem -v

** 修改gem默认源
gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/


redis-trib 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

以上是关于部署3主3从redis伪集群的主要内容,如果未能解决你的问题,请参考以下文章

CentOS 7单机安装Redis Cluster(3主3从伪集群),仅需简单五步

Redis_13_Redis集群实现RedisCluster应对大数据量

Redis_10_Redis集群实现RedisCluster应对大数据量

redis伪集群搭建(亲测无坑)

redis集群搭建

Redis5以上版本伪集群搭建(高可用集群模式)