redis集群安裝指令碼

2021-07-26 16:29:40 字數 2997 閱讀 8326

yum install gcc

mkdir /opt/package/

cd /opt/package/

wget

tar zxvf redis-3.2.4.tar.gz

mv redis-3.2.4 /usr/local/redis

dir='/usr/local/redis'

cd $dir

make&&make install

cd src

cp redis-trib.rb /usr/local/bin/

cd $dir

mkdir redis-cluster

cd redis-cluster

mkdir 9000 9001 9002

cd $dir

cp redis.conf redis-cluster/9000

cp redis.conf redis-cluster/9001

cp redis.conf redis-cluster/9002

cd $dir

cd redis-cluster/9000

sed -i '/^port/ s/6379/9000/' redis.conf

sed -i '/^bind/ s/127.0.0.1/172.18.3.184/' redis.conf

sed -i '/^daemonize/ s/no/yes/' redis.conf

sed -i '/^pidfile/ s/var\/run\/redis_6379.conf/var\/run\/redis_9000.conf/' redis.conf

sed -i 's/# cluster-enabled yes/cluster-enabled yes/' redis.conf

sed -i 's/# cluster-config-file nodes-6379.conf/cluster-config-file nodes-9000.conf/' redis.conf

sed -i 's/# cluster-node-timeout 15000/cluster-node-timeout 15000/' redis.conf

cd $dir

cd redis-cluster/9001

sed -i '/^port/ s/6379/9001/' redis.conf

sed -i '/^bind/ s/127.0.0.1/172.18.3.184/' redis.conf

sed -i '/^daemonize/ s/no/yes/' redis.conf

sed -i '/^pidfile/ s/var\/run\/redis_6379.conf/var\/run\/redis_9001.conf/' redis.conf

sed -i 's/# cluster-enabled yes/cluster-enabled yes/' redis.conf

sed -i 's/# cluster-config-file nodes-6379.conf/cluster-config-file nodes-9001.conf/' redis.conf

sed -i 's/# cluster-node-timeout 15000/cluster-node-timeout 15000/' redis.conf

cd $dir

cd redis-cluster/9002

sed -i '/^port/ s/6379/9002/' redis.conf

sed -i '/^bind/ s/127.0.0.1/172.18.3.184/' redis.conf

sed -i '/^daemonize/ s/no/yes/' redis.conf

sed -i '/^pidfile/ s/var\/run\/redis_6379.conf/var\/run\/redis_9002.conf/' redis.conf

sed -i 's/# cluster-enabled yes/cluster-enabled yes/' redis.conf

sed -i 's/# cluster-config-file nodes-6379.conf/cluster-config-file nodes-9002.conf/' redis.conf

sed -i 's/# cluster-node-timeout 15000/cluster-node-timeout 15000/' redis.conf

redis-server /usr/local/redis/redis-cluster/9000/redis.conf

redis-server /usr/local/redis/redis-cluster/9001/redis.conf

redis-server /usr/local/redis/redis-cluster/9002/redis.conf

ps -ef|grep redis

###################

#一般安裝部署兩台伺服器,每台三個節點,執行以上指令碼在兩台操作相同,只需要修改ip和埠即可

###################

redis集群 安裝部署後使用./redis-trib.rb  前需要執行以下

安裝ruby

yum install ruby rubygems -y

wget

gem install -l ./redis-3.2.1.gem

./redis-trib.rb  create --replicas 1 172.18.3.184:9000 172.18.3.184:9001 172.18.3.184:9002 172.18.3.185:9003 172.18.3.185:9004 172.18.3.185:9005

########測試集群

./redis-trib.rb check 172.18.3.184:9000

./redis-cli -c -h 172.18.3.184 -p 7000

redis集群維護指令碼

redis集群維護 一 啟動100 101上的6個節點 主機 192.168.199.101 cd home redis cluster nodes 7001 執行 nohup home redis 4.0.14 src redis server redis.conf cd home redis c...

Redis集群安裝

第一步 安裝和解壓 root node1 tar zxvf redis 3.2.6.tar.gz c usr local root node1 mv redis 3.2.6 redis root node1 cd usr local redis root node1 make 配置環境變數 root...

redis集群安裝

上次咱們講到了 的安裝,這次咱們來說說 集群的搭建,並且在這篇部落格中,我會總結一下我遇到的問題 安裝版本 現在的最新版本 執行環境 yum install ruby yum install rubygems 安裝環境使用的包 root localhost gem install redis 3.0...