创建安装目录
mkdir -p /opt/redis/
cd /opt/redis/
ll
上传所有安装包到 /opt/redis/
下面的脚本分两段一段是安装redis 以及ruby集群所需要的软件例如zlib OpenSSL等,后边一段是用来配置集群信息的,默认是带密码的密码是pwd123, 如果有需要修改请修改redis.conf中最后两行以及脚本中对应的密码
tar -xzvf redis-4.0.8.tar.gz
cd redis-4.0.8
make && make install
cd src
cp redis-trib.rb /usr/local/bin/
cd /opt/redis/
mkdir /usr/local/ruby
cp ruby-2.5.0.tar.gz /usr/local/ruby
cd /usr/local/ruby
tar -vxf ruby-2.5.0.tar.gz
cd ruby-2.5.0/
./configure
make && make install
cd /opt/redis/
mkdir /usr/local/zlib
cp zlib-1.2.11.tar.gz /usr/local/zlib
cd /usr/local/zlib
tar -vxf zlib-1.2.11.tar.gz
cd zlib-1.2.11/
./configure --prefix=/usr/local/zlib
make
make install
cd /usr/local/ruby/ruby-2.5.0/ext/zlib/
ruby extconf.rb --with-zlib-include=/usr/local/zlib/include/ --with-zlib-lib=/usr/local/zlib/lib
sed -i 's/zlib\.o: \$(top_srcdir)/zlib\.o: \.\.\/\.\./g' Makefile
make
make install
cd /opt/redis/
mkdir /usr/local/rubygems
cp rubygems-2.7.7.zip /usr/local/rubygems
cd /usr/local/rubygems
unzip rubygems-2.7.7.zip
cd rubygems-2.7.7/
ruby setup.rb
cd /opt/redis/
mkdir /usr/local/openssl
cp openssl-1.0.2n.tar.gz /usr/local/openssl
cd /usr/local/openssl
tar -vzxf openssl-1.0.2n.tar.gz
cd openssl-1.0.2n/
./config -fPIC --prefix=/usr/local/openssl enable-shared
./config -t
make && make install
cd /usr/local/ruby/ruby-2.5.0/ext/openssl/
ruby extconf.rb --with-openssl-include=/usr/local/openssl/include/ --with-openssl-lib=/usr/local/openssl/lib
sed -i 's/\$(top_srcdir)/\.\.\/\.\./g' Makefile
make && make install
cd /opt/redis/
cp ./redis-3.2.2.gem /opt/redis/redis-4.0.8/
cd /opt/redis/redis-4.0.8
gem install --local redis-3.2.2.gem
------------------------------配置集群
cd /opt/redis
sed -i 's/192\.168\.31\.20/192\.168\.31\.81/g' redis.conf
mkdir -p /opt/redis/redis_cluster/7001/data
mkdir -p /opt/redis/redis_cluster/7002/data
mkdir -p /opt/redis/redis_cluster/7003/data
mkdir -p /opt/redis/redis_cluster/7004/data
mkdir -p /opt/redis/redis_cluster/7005/data
mkdir -p /opt/redis/redis_cluster/7006/data
cp redis.conf /opt/redis/redis_cluster/7001
cp redis.conf /opt/redis/redis_cluster/7002
cp redis.conf /opt/redis/redis_cluster/7003
cp redis.conf /opt/redis/redis_cluster/7004
cp redis.conf /opt/redis/redis_cluster/7005
cp redis.conf /opt/redis/redis_cluster/7006
find /opt/redis/redis_cluster/7001 -name "redis.conf" -type f -print -exec sed -i 's/7000/7001/g' {} \;
find /opt/redis/redis_cluster/7002 -name "redis.conf" -type f -print -exec sed -i 's/7000/7002/g' {} \;
find /opt/redis/redis_cluster/7003 -name "redis.conf" -type f -print -exec sed -i 's/7000/7003/g' {} \;
find /opt/redis/redis_cluster/7004 -name "redis.conf" -type f -print -exec sed -i 's/7000/7004/g' {} \;
find /opt/redis/redis_cluster/7005 -name "redis.conf" -type f -print -exec sed -i 's/7000/7005/g' {} \;
find /opt/redis/redis_cluster/7006 -name "redis.conf" -type f -print -exec sed -i 's/7000/7006/g' {} \;
redis-server /opt/redis/redis_cluster/7001/redis.conf
redis-server /opt/redis/redis_cluster/7002/redis.conf
redis-server /opt/redis/redis_cluster/7003/redis.conf
redis-server /opt/redis/redis_cluster/7004/redis.conf
redis-server /opt/redis/redis_cluster/7005/redis.conf
redis-server /opt/redis/redis_cluster/7006/redis.conf
sed -i 's/password => nil/password => "pwd123"/g' /usr/local/lib/ruby/gems/2.5.0/gems/redis-3.2.2/lib/redis/client.rb
systemctl stop firewalld.service
service iptables stop
sleep 2s
redis-trib.rb create --replicas 1 192.168.31.81:7001 192.168.31.81:7002 192.168.31.81:7003 192.168.31.81:7004 192.168.31.81:7005 192.168.31.81:7006
所有安装包下载地址为:
https://download.csdn.net/download/zwhfyy/12392983
版权声明:本文为zwhfyy原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。