下载redis
wget https://download.redis.io/releases/redis-5.0.14.tar.gz
解压
tar -zxvf redis-5.0.14.tar.gz
安装环境
yum install gcc
编译安装
cd redis-5.0.14 make && make install
复制文件
cp redis.conf 6379.conf cp redis.conf 6380.conf cp redis.conf 6381.conf
6379.conf
bind 0.0.0.0 protected-mode no port 6379 daemonize no pidfile “/var/run/redis_6379.pid” dir “/usr/local/redis/data/6379”
./redis-server /usr/local/redis/conf/6379.conf
6380.conf
bind 0.0.0.0
protected-mode no port 6380 daemonize no pidfile “/var/run/redis_6380.pid” dir “/usr/local/redis/data/6380” replicaof 192.168.56.10 6379 主从配置
./redis-server /usr/local/redis/conf/6380.conf
6380.conf
bind 0.0.0.0 protected-mode no port 6381 daemonize no pidfile “/var/run/redis_6381.pid” dir “/usr/local/redis/data/6381” replicaof 192.168.56.10 6379 主从配置
./redis-server /usr/local/redis/conf/6381.conf
查看主从配置
redis-cli -h 127.0.0.1 -port 6379 执行info指令
哨兵
复制redis解压后文件夹中sentinel.conf文件 cp sentinel.conf sentinel-6379.conf cp sentinel.conf sentinel-6380.conf cp sentinel.conf sentinel-6381.conf
sentinel-6379.conf
protected-mode no port 26379 pidfile “/var/run/redis-sentinel-26379.pid” sentinel monitor mymaster 192.168.56.10 6379 2 #2是选举主节点
./redis-sentinel /usr/local/redis/conf/sentinel-6379.conf
sentinel-6380.conf
protected-mode no port 26380 pidfile “/var/run/redis-sentinel-26380.pid” sentinel monitor mymaster 192.168.56.10 6379 2 #2是选举主节点
./redis-sentinel /usr/local/redis/conf/sentinel-6380.conf
sentinel-6381.conf
protected-mode no port 26380 pidfile “/var/run/redis-sentinel-26381.pid” sentinel monitor mymaster 192.168.56.10 6379 2 #2是选举主节点
./redis-sentinel /usr/local/redis/conf/sentinel-6381.conf
主节点关闭后在从节点中选举一个作为master
|