初试redis主从同步

2017-08-02  本文已影响0人  羽翼未丰的小鸟

redis主从同步

环境:

主机1 centos7 redis3.2.1 master

主机2 centos7 redis3.2.1 slave

步骤:

搭建redis环境

cd /soft

wget http://download.redis.io/releases/redis-3.2.1.tar.gz

tar -zxvf redis-3.2.1.tar.gz

cd redis-3.2.1.tar.gz

make && make install

cp /usr/local/bin/redis-server /usr/bin/

mkdir /install/redis/

cp /soft/redis-3.2.1/redis.conf /install/redis/redis.conf

主机1 配置(master)

vi /install/redis/redis.conf

daemonize yes

#save 900 1

#save 300 10

#save 60 10000

redis-server /install/redis/redis.conf

主机2配置(slave)

vi /install/redis/redis.conf

daemonize yes

save 900 1

save 300 10

save 60 10000

slaveof 192.168.2.202 6379

redis-server /install/redis/redis.conf

检查启动是否正常

ps -ef|grep redis

测试:

master

cp /usr/local/bin/redis-cli /usr/bin/

redis-cli

set autor yc

master

slave

cp /usr/local/bin/redis-cli /usr/bin/

redis-cli

get autor

slave
上一篇下一篇

猜你喜欢

热点阅读