cd /root/tools
wget http://pnxcvm0bq.bkt.clouddn.com/redis-4.0.9.tar.gz
tar -zxvf redis-4.0.9.tar.gz
mkdir -p /home/heron/redis-cluster/redis-6379
cd redis-4.0.9
make PREFIX=/home/heron/redis-cluster/redis-6379/ install
mkdir /home/heron/redis-cluster/redis-6379/{conf,data,log,pid}
wget http://pnxcvm0bq.bkt.clouddn.com/redis.conf
mv redis.conf /home/heron/redis-cluster/redis-6379/conf/
chown -R heron.heron /home/heron/redis-cluster/
cat >> /home/heron/supervisor/conf/supervisord.conf << EOF
[program:redis-6379]
user=heron
command=/home/heron/redis-cluster/redis-6379/bin/redis-server /home/heron/redis-cluster/redis-6379/conf/redis.conf
directory=/home/heron/redis-cluster/redis-6379/
EOF
/home/heron/superctl update
yum -y install zlib ruby rubygems
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
find / -name rvm -print
source /usr/local/rvm/scripts/rvm
rvm install 2.4.1
rvm use 2.4.1
ruby --version
gem install redis
cp -rp /root/tools/redis-4.0.9/src/redis-trib.rb /usr/local/bin/
cp -rp /home/heron/redis-cluster/redis-6379/ /home/heron/redis-cluster/redis-6380
cp -rp /home/heron/redis-cluster/redis-6379/ /home/heron/redis-cluster/redis-6381
cp -rp /home/heron/redis-cluster/redis-6379/ /home/heron/redis-cluster/redis-6382
cp -rp /home/heron/redis-cluster/redis-6379/ /home/heron/redis-cluster/redis-6383
cp -rp /home/heron/redis-cluster/redis-6379/ /home/heron/redis-cluster/redis-6384
sed -i 's/6379/6380/g' /home/heron/redis-cluster/redis-6380/conf/redis.conf
sed -i 's/6379/6381/g' /home/heron/redis-cluster/redis-6381/conf/redis.conf
sed -i 's/6379/6382/g' /home/heron/redis-cluster/redis-6382/conf/redis.conf
sed -i 's/6379/6383/g' /home/heron/redis-cluster/redis-6383/conf/redis.conf
sed -i 's/6379/6384/g' /home/heron/redis-cluster/redis-6384/conf/redis.conf
sed -i 's/# cluster-config-file/cluster-config-file/g' /home/heron/redis-cluster/redis-6379/conf/redis.conf
sed -i 's/# cluster-config-file/cluster-config-file/g' /home/heron/redis-cluster/redis-6380/conf/redis.conf
sed -i 's/# cluster-config-file/cluster-config-file/g' /home/heron/redis-cluster/redis-6381/conf/redis.conf
sed -i 's/# cluster-config-file/cluster-config-file/g' /home/heron/redis-cluster/redis-6382/conf/redis.conf
sed -i 's/# cluster-config-file/cluster-config-file/g' /home/heron/redis-cluster/redis-6383/conf/redis.conf
sed -i 's/#cluster-config-file/cluster-config-file/g' /home/heron/redis-cluster/redis-6384/conf/redis.conf
sed -i 's/# cluster-enabled yes/cluster-enabled yes/g' /home/heron/redis-cluster/redis-6379/conf/redis.conf
sed -i 's/# cluster-enabled yes/cluster-enabled yes/g' /home/heron/redis-cluster/redis-6380/conf/redis.conf
sed -i 's/# cluster-enabled yes/cluster-enabled yes/g' /home/heron/redis-cluster/redis-6381/conf/redis.conf
sed -i 's/# cluster-enabled yes/cluster-enabled yes/g' /home/heron/redis-cluster/redis-6382/conf/redis.conf
sed -i 's/# cluster-enabled yes/cluster-enabled yes/g' /home/heron/redis-cluster/redis-6383/conf/redis.conf
sed -i 's/# cluster-enabled yes/cluster-enabled yes/g' /home/heron/redis-cluster/redis-6384/conf/redis.conf
cat >> /home/heron/supervisor/conf/supervisord.conf << EOF
[program:redis-6380]
user=heron
command=/home/heron/redis-cluster/redis-6380/bin/redis-server /home/heron/redis-cluster/redis-6380/conf/redis.conf
directory=/home/heron/redis-cluster/redis-6380/
[program:redis-6381]
user=heron
command=/home/heron/redis-cluster/redis-6381/bin/redis-server /home/heron/redis-cluster/redis-6381/conf/redis.conf
directory=/home/heron/redis-cluster/redis-6381/
[program:redis-6382]
user=heron
command=/home/heron/redis-cluster/redis-6382/bin/redis-server /home/heron/redis-cluster/redis-6382/conf/redis.conf
directory=/home/heron/redis-cluster/redis-6382/
[program:redis-6383]
user=heron
command=/home/heron/redis-cluster/redis-6383/bin/redis-server /home/heron/redis-cluster/redis-6383/conf/redis.conf
directory=/home/heron/redis-cluster/redis-6383/
[program:redis-6384]
user=heron
command=/home/heron/redis-cluster/redis-6384/bin/redis-server /home/heron/redis-cluster/redis-6384/conf/redis.conf
directory=/home/heron/redis-cluster/redis-6384/
EOF
chown -R heron.heron /home/heron/redis-cluster/
/home/heron/superctl update
/home/heron/superctl restart redis-6379
/usr/local/bin/redis-trib.rb create --replicas 1 127.0.0.1:6379 127.0.0.1:6380 127.0.0.1:6381 127.0.0.1:6382 127.0.0.1:6383 127.0.0.1:6384
php连接参考:
'redis_cluser_host'=>[
'127.0.0.1:6379',
'127.0.0.1:6380',
'127.0.0.1:6381',
'127.0.0.1:6382',
'127.0.0.1:6383',
'127.0.0.1:6384',
],