redis-3.2.8-Sentinel集群安装和部署
呃呃呃 来到新公司运维人手不够天天搞运维服务器,好久没更新了~,有空更新一个吧!!很基础的安装,避免踩坑 安装环境准备:采用的全部是本地kvm出来的centos7虚拟机sentinel1 192.168.1.206sentinel2 192.168.1.209sentinel3 192.168.1.208redis-master 192.168.1
呃呃呃 来到新公司运维人手不够天天搞运维服务器,好久没更新了~,有空更新一个吧!!很基础的安装,避免踩坑
安装环境准备:
采用的全部是本地kvm出来的centos7虚拟机
sentinel1 192.168.1.206
sentinel2 192.168.1.209
sentinel3 192.168.1.208
redis-master 192.168.1.206
redis-slave1 192.168.1.209
redis-slave2 192.168.1.208
每台机器上执行
echo 1 > /proc/sys/vm/overcommit_memory
部署redis数据节点
1、启动主节点
下载redis3.2.8安装包
cd /usr/local/src
wget http://download.redis.io/releases/redis-3.2.8.tar.gz
tar zxvf redis-3.2.8.tar.gz
cd ..
ln -s /usr/local/src/redis-3.2.8 redis
cd redis
make
make install
mkdir /data/redis/data/ -p
配置文件
redis-6379.conf
====================
port 6379
bind 192.168.1.206
protected-mode no
daemonize yes
logfile "6379.log"
dbfilename "dump-6379.rdb"
dir "/data/redis/data/"
============================
启动主节点
redis-server redis-6379.conf
确认是否启动
redis-cli -h 192.168.1.206 -p 6379 ping
PONG
2、启动2个从节点
配置文件 对比主节点添加了slaveof配置
cd /usr/local/redis
redis-6379.conf
========================
port 6379
bind 192.168.1.209
daemonize yes
protected-mode no
logfile "6379.log"
dbfilename "dump-6379.rdb"
dir "/data/redis/data/"
slaveof 192.168.1.206 6379
==========================
port 6379
bind 192.168.1.208
daemonize yes
protected-mode no
logfile "6379.log"
dbfilename "dump-6379.rdb"
dir "/data/redis/data/"
slaveof 192.168.1.206 6379
启动从节点
redis-server redis-6379.conf
确认是否启动
redis-cli -h 192.168.1.209 -p 6379 ping
redis-cli -h 192.168.1.208 -p 6379 ping
确认主从关系
主库视角
redis-cli -h 192.168.1.206 -p 6379 info replication
# Replication
role:master
connected_slaves:2
slave0:ip=192.168.1.209,port=6379,state=online,offset=407,lag=1
slave1:ip=192.168.1.208,port=6379,state=online,offset=407,lag=1
master_repl_offset:407
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:406
从库视角
redis-cli -h 192.168.1.209 -p 6379 info replication
# Replication
role:slave
master_host:192.168.1.206
master_port:6379
master_link_status:up
master_last_io_seconds_ago:3
master_sync_in_progress:0
slave_repl_offset:1
slave_priority:100
slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
部署sentinel节点 分别部署3台的sentinel节点
配置文件
redis-sentinel-26379.conf
==========================
port 26379
daemonize yes
protected-mode no
logfile "26379.log"
dir /data/redis/data/
sentinel monitor mymaster 192.168.1.206 6379 2
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 180000
登录验证
redis-cli -h 192.168.1.206 -p 26379
192.168.1.206:26379> sentinel ckquorum mymaster
OK 3 usable Sentinels. Quorum and failover authorization can be reached
更多推荐
所有评论(0)