centos7安裝redis5 0 7集群

2021-10-01 11:18:19 字數 2437 閱讀 5084

啟動: cd /usr/local/redis-cluster        ./start-cluster.sh

cd /usr/locar/reds/src

redis-cli -p 7001 #連線

./redis-cli  --cluster help #檢視幫助

cluster nodes   #節點檢視

cluster info # 檢視

yum -y install  gcc

yum  -y install  tcl

wget

解壓到/usr/local -> redis-5.0.7

cd redis-5.0.7

make

報錯:

zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: no such file or directory

#include

使用:make malloc=libc

# 啟動並指定配置檔案 src/redis‐server redis.conf(注意要使用後台啟動,所以修改redis.conf裡的daemonize改為yes)

驗證啟動是否成功 ps ‐ef | grep redis

進入redis客戶端  /usr/local/redis/src/redis‐cli

退出客戶端   quit

退出redis服務: (1)pkill redis‐server 28 (2)kill 程序號   (3)src/redis‐cli shutdown

mkdir -p /usr/local/redis-cluster

mkdir 7001 7002 7003 7004 7005 7006

cd 7001 ,建立redis.conf

port 7001

#yes 設定後台執行

daemonize yes

#設定pidfile存放在 run目錄下的檔名

pidfile /var/run/redis_7001.pid

#指定資料檔案存放位置,必須要指定不同的目錄位置,不然會丟失資料

dir /usr/local/redis-cluster/7001/

#設定開啟aof模式

#啟動集群

cluster-enabled yes

#關聯集群節點資訊檔案,這裡700x好和port對應上

cluster-config-file "nodes-7001.conf"

#設定超時

cluster-node-timeout 5000

#關閉保護模式

protected-mode no

#日誌資訊,可有可無

logfile "redis.log"

#指定ip訪問的位址,設定0.0.0.0 預設是全部位址,不設定,後面會連線不上的

bind 0.0.0.0

requirepass 123456

masterauth 123456

複製 修改埠->其他5個 。 這裡萬一修改錯了,批量修改: sed -i "s/#bind/bind/g" 700*/redis.conf

sed -i "s/old/new/g" the path of the files

eg: sed -i "s/linux/unix/g" text2.txt text3.txt

挨著啟動6個redis

/usr/local/redis-5.0.7/src/redis-server  /usr/local/redis-cluster/7001/redis.conf

ps -ef | grep redis 檢查

關閉防火牆:systemctl stop firewalld

systemctl stop firewalld.service            #停止firewall

systemctl disable firewalld.service        #禁止firewall開機啟動

建立集群:

/usr/local/redis-5.0.7/src/redis-cli -a 123456 --cluster create --cluster-replicas 1 192.168.20.8:7001 192.168.20.8:7002 192.168.20.8:7003 192.168.20.8:7004 192.168.20.8:7005 192.168.20.8:7006

/usr/local/redis-5.0.7/src/redis-cli  --cluster create --cluster-replicas 1 192.168.20.8:7001 192.168.20.8:7002 192.168.20.8:7003 192.168.20.8:7004 192.168.20.8:7005 192.168.20.8:7006

還是參考之前的安裝 ok

Centos7安裝與配置Redis5

centos7安裝redis 一 安裝gcc依賴 由於 redis 是用 c 語言開發,安裝之前必先確認是否安裝 gcc 環境 gcc v 如果沒有安裝,執行以下命令進行安裝 root localhost local yum install y gcc root localhost local wg...

Centos7上建立Redis5集群

一.基本安裝 1.安裝 cd opt wget wget tar xzf redis 5.0.4.tar.gz ln s redis 5.0.4 redis cd redis make 2.測試 src redis server src redis cli redis set foo bar okr...

centos7 安裝redis和redis擴充套件

安裝redis make 如果make失敗,請安裝gcc yum install gcc 重新解壓安裝 使用 二進位制檔案是編譯完成後在src目錄下.執行如下 src redis server 你能使用redis的內建客戶端進行進行redis 的編寫 src redis cli redis setf...