1.環(huán)境和版本
服務(wù)器:centos
redis版本號(hào):redis-5.0.4
- redis使用端口號(hào)
節(jié)點(diǎn) | 端口 |
---|---|
master | 6379 |
slave | 6380 |
slave | 6381 |
- 備注:外網(wǎng)連接需更改firewall防火墻配置
2.步驟
2.1安裝redis和相關(guān)軟件
wget http://download.redis.io/releases/redis-5.0.4.tar.gz
tar xzf redis-5.0.4.tar.gz
cd redis-5.0.4.tar.gz
make
mv redis-5.0.4 /usr/local/redis
2.2配置
主節(jié)點(diǎn)
vim /usr/local/redis/redis.conf
修改行: daemonize yes ,保存退出
#啟動(dòng)
redis-server /usr/local/redis/redis.conf
從節(jié)點(diǎn)
cd
mkdir -p redis/{6380,6381}/{conf,db,log}
cp /usr/local/redis/redis.conf redis/6380/conf/
vim redis/6380/conf/redis.conf
修改配置(其它節(jié)點(diǎn)修改6380端口)
daemonize yes
port 6380
pidfile /root/redis/6380/redis.pid
logfile /root/redis/6380/log/redis.log
dir /root/redis/6380/db/
replicaof 127.0.0.1 6379
#啟動(dòng)
redis-server /root/redis/6380/conf/redis.conf