1,到官网下载redis源码
我下载的4.0.14版本
2,安装redis主库
tar xf redis-4.0.14.tar.gz
cd redis-4.0.14
yum install gcc -y
make && make install PREFIX=/usr/local/redis
3,配置6379端口的主库redis
cp redis.conf /usr/local/redis/
vim /usr/local/redis/redis.conf
修改主库需要密码,因为我们是一台主机装主从redis,所以bind主机127.0.0.1就好了,如果是两台主机主从,那么主从的redis端口要通,bind 要把对方加进去
4,开启主库redis
nohup /usr/local/redis/bin/redis-server /usr/local/redis/redis.conf &
开启了
5,配置和开启redis从库
cp redis.conf /usr/local/redis/redis6380.conf
vim /usr/local/redis/redis6380.conf
6,开启redis从库
nohup /usr/local/redis/bin/redis-server /usr/local/redis/redis6380.conf &
7,验证主从
ok,完成.