安装redis集群(三主三从)

安装依赖关系

yum install zlib*
yum install openssl*
yum install ImageMagick‐devel –y
yum install gcc*

安装ruby

tar ‐zxvf ruby‐2.4.1.tar.gz
cd ruby‐2.4.1
./configure ‐‐prefix=/data/redisCluster/ruby
make
make install

配置环境变量
在/etc/profile里增加如下

export PATH=/data/redisCluster/ruby/bin:$PATH

使环境变量生效

source /etc/profile

安装rubygem

tar ‐zxvf rubygems‐2.6.12.tgz
cd rubygems‐2.6.12
ruby setup.rb
##验证
gem ‐v

更换gem源

gem sources查看当前gem源
gem sources ‐‐remove删除当前gem源
gem sources ‐a https://gems.ruby-china.com添加gem源

搭建redis

##解压安装包
tar ‐zxvf redis‐3.0.5.tar.gz
cd redis‐3.0.5
make
cd ..
cp redis‐3.0.5/src/redis‐trib.rb /bin/
cp redis‐3.0.5/src/redis‐server /bin/
cp redis‐3.0.5/src/redis‐cli /bin/
gem install redis ‐‐version 3.0.5
##内核调优
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
##使其生效
sysctl ‐p
##建立目录
mkdir ‐p /data/redisCluster/redis/data/6300
mkdir ‐p /data/redisCluster/redis/data/6301
mkdir ‐p /data/redisCluster/redis/data/6302
mkdir ‐p /data/redisCluster/redis/data/6303
mkdir ‐p /data/redisCluster/redis/data/6304
mkdir ‐p /data/redisCluster/redis/data/6305

配置文件修改,放入/etc目录下
redis_6300.conf~6305,配置信息参考如下:
安装redis集群(三主三从)_第1张图片
启动服务

//(如果启动失败就直接进去/etc目录执行redis‐server redis_6300.conf)
redis‐server /etc/redis_6300.conf
redis‐server /etc/redis_6301.conf
redis‐server /etc/redis_6302.conf
redis‐server /etc/redis_6303.conf
redis‐server /etc/redis_6304.conf
redis‐server /etc/redis_6305.conf
echo "redis‐server /etc/redis_6300.conf" >> /etc/rc.local
echo "redis‐server /etc/redis_6301.conf" >> /etc/rc.local
echo "redis‐server /etc/redis_6302.conf" >> /etc/rc.local
echo "redis‐server /etc/redis_6303.conf" >> /etc/rc.local
echo "redis‐server /etc/redis_6304.conf" >> /etc/rc.local
echo "redis‐server /etc/redis_6305.conf" >> /etc/rc.local

初始化集群,节点角色由顺序决定,先master之后是slave,前三个是master,后三个是slave(有的时候也不准。。。)

redis‐trib.rb create ‐‐replicas 1 49.4.128.152:6300 49.4.128.152:6301 49.4.128.152:6302
49.4.128.152:6303 49.4.128.152:6304 49.4.128.152:6305
#查看集群状态
redis‐trib.rb check 49.4.128.152:6300

ERR Slot 0 is already busy (Redis::CommandError)报错

错误提示是说:slot插槽被占用了、这是因为 搭建集群前时,以前redis的旧数据和配置信息没有清理干净。
解决方案:
/redis-cli -h IP -p 端口
flushall
cluster reset

然后再重新执行创建集群服务命令即可

redis‐trib.rb create ‐‐replicas 1 49.4.128.152:6300 49.4.128.152:6301 49.4.128.152:6302
49.4.128.152:6303 49.4.128.152:6304 49.4.128.152:6305
#查看集群状态
redis‐trib.rb check 49.4.128.152:6300

你可能感兴趣的:(软件使用安装)