首先安装redis
我的redis安装在/app/redis/文件夹下
第二步,写两个redis实例的配置文件,一主一从。我的设计如下,6379端口为主,6380端口为从。
6379:redis_master.conf(配置文件内容很多,这里只写与主从配置有关的配置项)
daemonize yes # 后台启动 pidfile /var/run/redis.pid # pid port 6479 # 端口号 slave-serve-stale-data yes slave-read-only yes requirepass mypassword # 密码
6380:redis_slave.conf(配置文件内容很多,这里只写与主从配置有关的配置项)
daemonize no pidfile /var/run/redis.pid port 6380 slave-serve-stale-data yes slave-read-only yes slaveof localhost 6379 masterauth mypassword
然后分别启动主从redis
原文:http://www.cnblogs.com/cuihang/p/5049245.html