安裝 REDIS 叢集
REDIS是KEY-VALUE資料庫,用於做快取是很不錯的選擇。
一、REDIS 叢集安裝步驟
安裝相關軟體yum install -y ruby ruby-rdoc;
rpm -ivh rubygems-1.3.7-2.3.noarch.rpm
下載
wget
gem install redis-3.2.1.gem --local
wget
tar zxvf redis-3.0.4.tar.gz
建立目錄並安裝redis
mkdir -p /usr/local/software/
mv redis-3.0.4 /usr/local/software/
cd /usr/local/software/redis-3.0.4
make
make install
建立叢集需要的目錄
mkdir -p /usr/local/software/redis-cluster
cd /usr/local/software/redis-cluster
mkdir 7001
mkdir 7002
mkdir 7003
cp -R /usr/local/software/redis-3.0.4/* /usr/local/software/redis-cluster/7001/
cp -R /usr/local/software/redis-3.0.4/* /usr/local/software/redis-cluster/7002/
cp -R /usr/local/software/redis-3.0.4/* /usr/local/software/redis-cluster/7003/
修改配置檔案redis.conf
cp /usr/local/software/redis-3.0.4/redis.conf /usr/local/software/redis-cluster/
cd /usr/local/software/redis-cluster/
vim redis.conf
##修改配置檔案中的下面選項
bind 192.168.1.93
port 7001
daemonize yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
logfile "/usr/local/software/redis-cluster/7001/redis-7001.log"
appendonly yes
##修改完redis.conf配置檔案中的這些配置項之後把這個配置檔案分別複製到7001/7002/7003目錄下面
cd /usr/local/software/redis-cluster
mv ./7001/redis.conf ./7001/redis.conf.bak
mv ./7002/redis.conf ./7002/redis.conf.bak
mv ./7003/redis.conf ./7003/redis.conf.bak
cp redis.conf ./7001/
cp redis.conf ./7002/
cp redis.conf ./7003/
##注意:複製完成之後要修改7001/7002/7003目錄下面redis.conf檔案中的port引數,分別改為對應的資料夾的名稱
分別啟動這3個redis例項
cd /usr/local/software/redis-cluster/7001
redis-server ./redis.conf
cd /usr/local/software/redis-cluster/7002
redis-server ./redis.conf
cd /usr/local/software/redis-cluster/7003
redis-server ./redis.conf
關閉
/usr/local/software/redis-3.0.4/src/redis-cli -h 127.0.0.1 -p 7001 shutdown
/usr/local/software/redis-3.0.4/src/redis-cli -h 127.0.0.1 -p 7002 shutdown
/usr/local/software/redis-3.0.4/src/redis-cli -h 127.0.0.1 -p 7003 shutdown
開放防火牆:
-A RH-Firewall-1-INPUT -p tcp --dport 7001 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --dport 7002 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --dport 7003 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --dport 17001 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --dport 17002 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --dport 17003 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --dport 6379 -j ACCEPT
##啟動之後使用命令檢視redis的啟動情況
ps -ef|grep redis
如下圖顯示則說明啟動成功
6:執行redis的建立叢集命令建立叢集,讓三個例項互相通訊:
cd /usr/local/software/redis-3.0.4/src
./redis-trib.rb create --replicas 1 192.168.1.70:7001 192.168.1.70:7002 192.168.1.70:7003 192.168.1.93:7001 192.168.1.93:7002 192.168.1.93:7003
二、重建叢集
#關閉叢集#killall -9 redis-server
或
/usr/local/software/redis-3.0.4/src/redis-cli -h 127.0.0.1 -p 7001 shutdown
/usr/local/software/redis-3.0.4/src/redis-cli -h 127.0.0.1 -p 7002 shutdown
/usr/local/software/redis-3.0.4/src/redis-cli -h 127.0.0.1 -p 7003 shutdown
或
/usr/local/software/redis-3.0.4/src/redis-cli -h 192.168.1.70 -p 7001 shutdown
/usr/local/software/redis-3.0.4/src/redis-cli -h 192.168.1.70 -p 7002 shutdown
/usr/local/software/redis-3.0.4/src/redis-cli -h 192.168.1.70 -p 7003 shutdown
/usr/local/software/redis-3.0.4/src/redis-cli -h 192.168.1.93 -p 7001 shutdown
/usr/local/software/redis-3.0.4/src/redis-cli -h 192.168.1.93 -p 7002 shutdown
/usr/local/software/redis-3.0.4/src/redis-cli -h 192.168.1.93 -p 7003 shutdown
#刪除舊叢集相關檔案
cd /usr/local/software/redis-cluster/7001
rm -rf nodes*.conf appendonly.aof redis-700*.log
cd /usr/local/software/redis-cluster/7002
rm -rf nodes*.conf appendonly.aof redis-700*.log
cd /usr/local/software/redis-cluster/7003
rm -rf nodes*.conf appendonly.aof redis-700*.log
# 啟動叢集
cd /usr/local/software/redis-cluster/7001
redis-server redis.conf
cd /usr/local/software/redis-cluster/7002
redis-server redis.conf
cd /usr/local/software/redis-cluster/7003
redis-server redis.conf
建立叢集
cd /usr/local/software/redis-3.0.4/src
./redis-trib.rb create --replicas 1 192.168.1.93:7001 192.168.1.93:7002 192.168.1.93:7003 192.168.1.70:7001 192.168.1.70:7002 192.168.1.70:7003
測試
/usr/local/software/redis-3.0.4/src/redis-cli -c -p 7001 -h 192.168.1.93
cluster nodes
set hello world
exit
/usr/local/software/redis-3.0.4/src/redis-cli -c -p 7002 -h 192.168.1.93
get hello
exit
/usr/local/software/redis-3.0.4/src/redis-cli -c -p 7003 -h 192.168.1.93
get hello
exit
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10995764/viewspace-2124691/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- redis-3.0.6 安裝叢集Redis
- redis 5.0 叢集的安裝Redis
- Redis安裝+叢集+效能監控Redis
- Redis叢集環境安裝指南Redis
- centos安裝redis3.0.0叢集CentOSRedisS3
- Redis叢集方案,Codis安裝測試Redis
- CentOS6.6安裝Redis3.0.3叢集CentOSRedisS3
- Redis安裝之叢集-哨兵模式(sentinel)模式Redis模式
- linux安裝redis-6.0.1單機和叢集LinuxRedis
- redis安裝,主從複製,哨兵機制,叢集Redis
- 【詳細教程】Linux安裝redis並搭建叢集LinuxRedis
- 安裝Kafka叢集Kafka
- Redis系列:搭建Redis叢集(叢集模式)Redis模式
- redis 叢集Redis
- redis叢集Redis
- 完整安裝always on叢集
- 安裝Consul叢集
- 快速安裝 kafka 叢集Kafka
- FastDFS 叢集 安裝 配置AST
- Redis cluster 叢集Redis
- redis叢集搭建Redis
- redis系列:叢集Redis
- 搭建 Redis 叢集Redis
- Redis Cluster(叢集)Redis
- Redis 叢集方法Redis
- Redis叢集方案Redis
- Redis 叢集方案Redis
- Redis-叢集Redis
- redis叢集原理Redis
- 安裝Zookeeper和Kafka叢集Kafka
- redis偽叢集配置Cluster叢集模式Redis模式
- Redis叢集 - cluster叢集、資料分片Redis
- Linux-Centos6.8安裝redis-4.0.10 官方叢集版LinuxCentOSRedis
- Centos7下安裝redis實戰(單機版以及叢集)CentOSRedis
- windows下安裝redis叢集-陳陣-專題視訊課程WindowsRedis
- 認識Redis叢集——Redis ClusterRedis
- 安裝Greenplum 5.2 叢集實戰
- Cloudera Manager安裝 & 搭建CDH叢集Cloud