centos7 redis集羣安裝

.說明:該集羣的端口號爲7001-7006共六個端口,三主三從

centos7 redis集羣安裝

1.下載解壓redis

wget http://download.redis.io/releases/redis-3.2.4.tar.gz
如果沒有速度,用我提供的:
鏈接:https://pan.baidu.com/s/1Ed80F22l5Re9Oz8nkcUl8g
提取碼:jde0

tar -zxvf redis-3.2.4.tar.gz

2.編譯並安裝

cd redis-3.2.4 make && make install

2.創建cluster文件夾,再cluster下創建7001-7006文件夾,將redis-3.2.4編譯好後的bin文件夾跟redis.conf複製到7001,其他7002-7006同

在這裏插入圖片描述在這裏插入圖片描述

3.更改7001-7006每個文件中的redis.conf文件 vim redis.conf
更改內容

1.端口更改 port:7001
2.protected-mode no
3.註釋掉bind:120.0.0.1
4.daemonize yes //後臺啓動
5. cluster-enabled yes

5.如果你的服務器是阿里雲的,配置安全組

7001 ,17001 , 7002,17002 , 7003,17003 ,7004,17004 , 7005,17005 ,
7006,17006

共12個端口

6.yum -yinstall zlib ruby rubygems 安裝依賴
再下載 redis-3.3.0.gem(下面是百度雲的鏈接)
鏈接:https://pan.baidu.com/s/1jT0R1P6wVQmqIyOfdT-N-A
提取碼:7n2i
上傳redis-3.3.0.gem

gem install -l redis-3.3.0.gem

7.將redis中的redis-trib.rb複製到7001文件下(如果找不到該文件,使用find / -name redis-trib.rb命令查找)

8.建立主從節點

./redis-trib.rb create --replicas 1 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 127.0.0.1:7006

9.爲方便開啓服務,在cluster文件下新建start-all.sh

cd 7001
./redis-server redis.conf
cd ..
cd 7002
./redis-server redis.conf
cd ..
cd 7003
./redis-server redis.conf
cd ..
cd 7004
./redis-server redis.conf
cd ..
cd 7005
./redis-server redis.conf
cd ..
cd 7006
./redis-server redis.conf
cd ..

8.啓動

./start-all.sh 啓動服務 (後臺方式)

  進入隨便7001-7006其中的一個文件夾 以 redis-cli -c -h 127.0.0.1  -p 7001  (前臺方式)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章