Redis配置
单机模式
Redis修改配置文件
1)#vim redis.conf
2)关闭IP绑定 69行
3)关闭保护模式 88行 protected-mode no
4)开启后台启动,不影响当前终端操作 136行 daemonize yes
多台Redis
1)分片配置——采用多台Redis来实现内存扩容
创建shards目录并复制redis.conf到里面
# mkdir shards
# cp redis.conf shards/6379.conf
# cp redis.conf shards/6380.conf
# cp redis.conf shards/6381.conf
修改配置文件对应的端口号
92行
启动多个Redis
#redis-server 6379.conf
#redis-server 6380.conf
#redis-server 6381.conf
查询结果
#ps -ef|grep redis

2)主从复制——数据的自动迁移
准备哨兵目录,复制shards目录为sentinel
# cp -r shards sentinel
删除RDB文件
# rm -f dump.rdb
启动3台redis
# redis-server 6379.conf
将80和81挂在79上
# SLAVEOF 192.168.163.129 6379

哨兵配置
复制配置文件sentinel.conf到sentinel下
# cp sentinel.conf sentinel
关闭保护模式 -17行
Protected-mode no
开启后台启动 -26行
Daemonize yes
修改哨兵的监听
Sentinel monitor mymaster 192.168.163.129 6379 1
修改超时时间
Sentinel down-after-miliseconds mymaster 10000
启动哨兵机制
# redis-sentinel sentinel.conf

浙公网安备 33010602011771号