Building a redis cluster with three masters and three slaves
Building a redis cluster with three masters and three slaves
Article directory
-
- 1: Environment preparation
- 2: Download redis related software
- Three: Installation
- Four: Cluster creation
1: Environment preparation
Two virtual machines CentOS-7 + redis-4.0.1
two nodes + 6 redis instances
2: Download redis related software
Download the redis software, download address , select the version to download, I use wget to download directly, the command is as follows:
wget http://download.redis.io/releases/redis-4.0.1.tar.gz
Download ruby , select tar.gz to download
After the download is complete, place the software into the /usr/local/soft directory.
Three: Installation
3.1 Install redis
Install some dependencies required by redis
yum install -y tcl gcc zlib-devel openssl-devel
Unzip redis
tar -zxvf redis-4.0.1.tar.gz
#解压后
mv redis-4.0.1 redis
make MALLOC=libc
#创建redis集群的目录
cd /opt
mkdir redis-cluster
mkdir redis-cluster/nodes-{
7001,7002,7003}
#编辑redis.conf配置文件(以7001来举个例子,将7002和7003都编辑一下配置文件)
cd redis-cluster/nodes-7001
vi redis.conf
#redis.conf
bind 192.168.1.39
port 7001
pidfile redis_7001.pid
loglevel notice
logfile "/opt/redis-cluster/nodes-7001/redis_7001.log"
dir /opt/redis-cluster/nodes-7001/
cluster-config-file nodes-7001.conf
daemonize yes
supervised no
appendonly yes
cluster-enabled yes
cluster-node-timeout 15000
save 900 1
save 300 10
save 60 10000
dbfilename dump.rdb
appendfilename "appendonly.aof"
appendfsync everysec

On another machine, repeat the above steps, but make it 7001, 7002, 7003
Start each redis instance in sequence (use 7001 as a reference)
Just execute the following commands on both machines:
cd /usr/local/redis/src
./redis-server /opt/redis-cluster/nodes-7001/redis.conf
./redis-server /opt/redis-cluster/nodes-7002/redis