1. 新建文件夹
mkdir -p /data/redis/master/data
mkdir -p /data/redis/slave1/data
mkdir -p /data/redis/slave2/d
ata
创建主配置⽂件
redis.conf
bind 0.0.0.0
port 6379
daemonize yes
requirepass "123456"
logfile "/usr/local/redis/log/redis1.log"
dbfilename "xdclass1.rdb"
dir "/usr/local/redis/data"
appendonly yes
appendfilename "appendonly1.aof"
masterauth "123456"
创建两个从配置⽂件
redis.conf
bind 0.0.0.0
port 6380
daemonize yes
requirepass "123456"
logfile "/usr/local/redis/log/redis2.log"
dbfilename "xdclass2.rdb"
dir "/usr/local/redis/data"
appendonly yes
appendfilename "appendonly2.aof"
replicaof 8.129.113.233 6379
masterauth "123456"
bind 0.0.0.0
port 6381
daemonize yes
requirepass "123456"
logfile "/usr/local/redis/log/redis3.log"
dbfilename "xdclass3.rdb"
dir "/usr/local/redis/data"
appendonly yes
appendfilename "appendonly3.aof"
replicaof 8.129.113.233 6379
masterauth "123456"
#
启动主
./redis-server /data/redis/master/data/redis.conf
#
启动从
./redis-server /data/redis/slave1/data/redis.conf
./redis-server /data/redis/slave2/data/redis.conf
redis的启动文件在 /usr/local/redis/bin