redis-cluster安裝與配置
阿新 • • 發佈:2018-12-25
叢集的配置:
tar xzvf redis-3.2.5.tar.gz -C /usr/local/software/
[[email protected] redis-3.2.5]# make
[[email protected] redis-3.2.5]# make install
[[email protected] redis-3.2.5]# echo "vm.overcommit_memory=1">>/etc/sysctl.conf
[[email protected] redis-3.2.5]# /sbin/sysctl -p
mkdir -p /usr/local/software/redis/{bin,conf}
cp /usr/local/software/redis-3.2.5/src/redis-server /usr/local/software/redis/bin/
cp /usr/local/software/redis-3.2.5/src/redis-cli /usr/local/software/redis/bin/
cp /usr/local/software/redis-3.2.5/src/redis-benchmark /usr/local/software/redis/bin/
cp /usr/local/software/redis-3.2.5/src/redis-sentinel /usr/local/software/redis/bin/
mkdir -p /usr/local/software/data/redis/{redis-6379,redis-6380,redis-6381,redis-6382,redis-6383,redis-6384,redis-6385,redis-6386}/{run,logs,dbcache}
redis-6379.conf配置檔案:
#bind 127.0.0.1//取消本地IP繫結
protected-mode no//在配置之前一定要取消保護模式
port 6379//監聽埠
daemonize yes//後臺執行
pidfile /usr/local/software/data/redis/redis-6379/run/redis_6379.pid//定義pid儲存路徑
logfile "/usr/local/software/data/redis/redis-6379/logs/redis_6379.log"//定義日誌儲存路徑
dir /usr/local/software/data/redis/redis-6379/dbcache//資料儲存目錄
(不要配置密碼 # requirepass mldnjava 註釋掉)
cluster-enabled yes//開啟RedisCluster叢集
cluster-config-file nodes-6379.conf//定義 cluster 配置的儲存檔案
cluster-node-timeout 15000//定義節點的超時時間(超過這個時間認為節點已經掛掉)
複製檔案: cp /usr/local/software/redis/conf/redis-6379.conf /usr/local/software/redis/conf/redis-6380.conf
整版替換: 1,$s/6379/6380/g
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6379.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6380.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6381.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6382.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6383.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6384.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6385.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6386.conf
如果要想配置redis叢集,請一定要先保證你的主機上擁有ruby許可權
烏班圖下: apt-get install ruby ruby-dev rubygems
CentOS下: yum install ruby ruby-dev rubygems
sudo yum install curl
yum update nss
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
安裝RVM
[ [email protected] /]# curl -L get.rvm.io | bash -s stable
[[email protected] /]# source /usr/local/rvm/scripts/rvm
檢視rvm庫中已知的ruby版本
[[email protected] /]# rvm list known
安裝一個ruby版本
[[email protected] /]# rvm install 2.3.4
使用一個ruby版本
[[email protected] /]# rvm use 2.3.4
Using /usr/local/rvm/gems/ruby-2.3.4
解除安裝一個已知版本
[ [email protected] /]# rvm remove 2.0.0
ruby-2.0.0-p648 - #already gone
Using /usr/local/rvm/gems/ruby-2.3.4
首先需要進行 redis 的編譯操作:
[[email protected] /]#
gem install redis
複製一個 redis 叢集的配置工具到 redis 的主目錄之中:
cp /usr/local/software/redis-3.2.5/src/redis-trib.rb /usr/local/software/redis/bin/
/usr/local/software/redis/bin/redis-trib.rb help
./bin/redis-server ./conf/redis-6379.conf
./bin/redis-server ./conf/redis-6380.conf
./bin/redis-server ./conf/redis-6381.conf
./bin/redis-server ./conf/redis-6382.conf
./bin/redis-server ./conf/redis-6383.conf
./bin/redis-server ./conf/redis-6384.conf
./bin/redis-server ./conf/redis-6385.conf
./bin/redis-server ./conf/redis-6386.conf
/usr/local/software/redis/bin/redis-trib.rb create --replicas 1 192.168.68.139:6379 192.168.68.139:6380 192.168.68.139:6381 192.168.68.139:6382 192.168.68.139:6383
192.168.68.139:6384 192.168.68.139:6385 192.168.68.139:6386
Using 4 masters:
192.168.68.139:6379
192.168.68.139:6380
192.168.68.139:6381
192.168.68.139:6382
Adding replica 192.168.68.139:6383 to 192.168.68.139:6379
Adding replica 192.168.68.139:6384 to 192.168.68.139:6380
Adding replica 192.168.68.139:6385 to 192.168.68.139:6381
Adding replica 192.168.68.139:6386 to 192.168.68.139:6382
/usr/local/software/redis/bin/redis-cli -h 192.168.68.139 -p 6381 -c
----------------------------------------------------------------------------------------
單節點的配置:
tar xzvf redis-3.0.0.tar.gz -C /usr/local/software/
[ [email protected] redis-3.0.0]# make
[[email protected] redis-3.0.0]# make install
mkdir -p /usr/local/software/redis1/{bin,conf}
cp /usr/local/software/redis-3.0.0/src/redis-server /usr/local/software/redis1/bin/
cp /usr/local/software/redis-3.0.0/src/redis-cli /usr/local/software/redis1/bin/
cp /usr/local/software/redis-3.0.0/src/redis-benchmark /usr/local/software/redis1/bin/
cp /usr/local/software/redis-3.0.0/src/redis-sentinel /usr/local/software/redis1/bin/
mkdir -p /usr/local/software/data/redis1/redis-6379/{run,logs,dbcache}
cp redis.conf /usr/local/software/redis1/conf/
vi redis.conf
daemonize yes
pidfile /usr/local/software/data/redis1/redis-6379/run/redis_6379.pid
logfile "/usr/local/software/data/redis1/redis-6379/logs/redis_6379.log"
dir /usr/local/software/data/redis1/redis-6379/dbcache
tar xzvf redis-3.2.5.tar.gz -C /usr/local/software/
[[email protected] redis-3.2.5]# make
[[email protected] redis-3.2.5]# make install
[[email protected] redis-3.2.5]# echo "vm.overcommit_memory=1">>/etc/sysctl.conf
[[email protected] redis-3.2.5]# /sbin/sysctl -p
mkdir -p /usr/local/software/redis/{bin,conf}
cp /usr/local/software/redis-3.2.5/src/redis-server /usr/local/software/redis/bin/
cp /usr/local/software/redis-3.2.5/src/redis-cli /usr/local/software/redis/bin/
cp /usr/local/software/redis-3.2.5/src/redis-benchmark /usr/local/software/redis/bin/
cp /usr/local/software/redis-3.2.5/src/redis-sentinel /usr/local/software/redis/bin/
mkdir -p /usr/local/software/data/redis/{redis-6379,redis-6380,redis-6381,redis-6382,redis-6383,redis-6384,redis-6385,redis-6386}/{run,logs,dbcache}
redis-6379.conf配置檔案:
#bind 127.0.0.1//取消本地IP繫結
protected-mode no//在配置之前一定要取消保護模式
port 6379//監聽埠
daemonize yes//後臺執行
pidfile /usr/local/software/data/redis/redis-6379/run/redis_6379.pid//定義pid儲存路徑
logfile "/usr/local/software/data/redis/redis-6379/logs/redis_6379.log"//定義日誌儲存路徑
dir /usr/local/software/data/redis/redis-6379/dbcache//資料儲存目錄
(不要配置密碼 # requirepass mldnjava 註釋掉)
cluster-enabled yes//開啟RedisCluster叢集
cluster-config-file nodes-6379.conf//定義 cluster 配置的儲存檔案
cluster-node-timeout 15000//定義節點的超時時間(超過這個時間認為節點已經掛掉)
複製檔案: cp /usr/local/software/redis/conf/redis-6379.conf /usr/local/software/redis/conf/redis-6380.conf
整版替換: 1,$s/6379/6380/g
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6379.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6380.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6381.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6382.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6383.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6384.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6385.conf
/usr/local/software/redis/bin/redis-server /usr/local/software/redis/conf/redis-6386.conf
如果要想配置redis叢集,請一定要先保證你的主機上擁有ruby許可權
烏班圖下: apt-get install ruby ruby-dev rubygems
CentOS下: yum install ruby ruby-dev rubygems
sudo yum install curl
yum update nss
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
安裝RVM
[
[[email protected] /]# source /usr/local/rvm/scripts/rvm
檢視rvm庫中已知的ruby版本
[[email protected] /]# rvm list known
安裝一個ruby版本
[[email protected] /]# rvm install 2.3.4
使用一個ruby版本
[[email protected] /]# rvm use 2.3.4
Using /usr/local/rvm/gems/ruby-2.3.4
解除安裝一個已知版本
[
ruby-2.0.0-p648 - #already gone
Using /usr/local/rvm/gems/ruby-2.3.4
首先需要進行 redis 的編譯操作:
[[email protected] /]#
gem install redis
複製一個 redis 叢集的配置工具到 redis 的主目錄之中:
cp /usr/local/software/redis-3.2.5/src/redis-trib.rb /usr/local/software/redis/bin/
/usr/local/software/redis/bin/redis-trib.rb help
./bin/redis-server ./conf/redis-6379.conf
./bin/redis-server ./conf/redis-6380.conf
./bin/redis-server ./conf/redis-6381.conf
./bin/redis-server ./conf/redis-6382.conf
./bin/redis-server ./conf/redis-6383.conf
./bin/redis-server ./conf/redis-6384.conf
./bin/redis-server ./conf/redis-6385.conf
./bin/redis-server ./conf/redis-6386.conf
/usr/local/software/redis/bin/redis-trib.rb create --replicas 1 192.168.68.139:6379 192.168.68.139:6380 192.168.68.139:6381 192.168.68.139:6382 192.168.68.139:6383
192.168.68.139:6384 192.168.68.139:6385 192.168.68.139:6386
Using 4 masters:
192.168.68.139:6379
192.168.68.139:6380
192.168.68.139:6381
192.168.68.139:6382
Adding replica 192.168.68.139:6383 to 192.168.68.139:6379
Adding replica 192.168.68.139:6384 to 192.168.68.139:6380
Adding replica 192.168.68.139:6385 to 192.168.68.139:6381
Adding replica 192.168.68.139:6386 to 192.168.68.139:6382
/usr/local/software/redis/bin/redis-cli -h 192.168.68.139 -p 6381 -c
----------------------------------------------------------------------------------------
單節點的配置:
tar xzvf redis-3.0.0.tar.gz -C /usr/local/software/
[
[[email protected] redis-3.0.0]# make install
mkdir -p /usr/local/software/redis1/{bin,conf}
cp /usr/local/software/redis-3.0.0/src/redis-server /usr/local/software/redis1/bin/
cp /usr/local/software/redis-3.0.0/src/redis-cli /usr/local/software/redis1/bin/
cp /usr/local/software/redis-3.0.0/src/redis-benchmark /usr/local/software/redis1/bin/
cp /usr/local/software/redis-3.0.0/src/redis-sentinel /usr/local/software/redis1/bin/
mkdir -p /usr/local/software/data/redis1/redis-6379/{run,logs,dbcache}
cp redis.conf /usr/local/software/redis1/conf/
vi redis.conf
daemonize yes
pidfile /usr/local/software/data/redis1/redis-6379/run/redis_6379.pid
logfile "/usr/local/software/data/redis1/redis-6379/logs/redis_6379.log"
dir /usr/local/software/data/redis1/redis-6379/dbcache