redis主從同步
環(huán)境:
主機(jī)1 centos7 redis3.2.1 master
主機(jī)2 centos7 redis3.2.1 slave
步驟:
搭建redis環(huán)境
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
主機(jī)1 配置(master)
vi /install/redis/redis.conf
daemonize yes
#save 900 1
#save?300?10
#save?60?10000
redis-server /install/redis/redis.conf
主機(jī)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
檢查啟動(dòng)是否正常
ps -ef|grep redis
測(cè)試:
master
cp /usr/local/bin/redis-cli /usr/bin/
redis-cli
set autor yc
slave
cp /usr/local/bin/redis-cli /usr/bin/
redis-cli
get autor