linux安装redis哨兵-创新互联
安装环境
文章标题:linux安装redis哨兵-创新互联
转载来源:http://lswzjz.com/article/cdjhic.html
服务器一台:
创新互联公司成立于2013年,先为辽宁等服务建站,辽宁等地企业,进行企业商务咨询服务。为辽宁企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。- 服务器IP:172.169.3.251
- 主从端口:6379、6380、6381
- 哨兵端口,26379、26380、26381
- 安装目录:/usr/local/redis
- 配置文件目录:/usr/loca/redis/conf
wget https://download.redis.io/releases/redis-6.2.7.tar.gz
2、解压redistar -zxvf redis-6.2.7.tar.gz
mv redis-6.2.7 /usr/local/redis
3、编译、安装cd /usr/local/redis
make
make install PREFIX=/usr/local/redis
配置主从、哨兵在目录 /usr/loca/redis/conf 下创建以下文件
- redis1.conf
- redis2.conf
- redis3.conf
- sentinel1.conf
- sentinel2.conf
- sentinel3.conf
bind 0.0.0.0
port 6379
daemonize yes
protected-mode no
slave-read-only no
masterauth 1234
requirepass 1234
redis2.confreplicaof 改为 redis1的ip和端口
bind 0.0.0.0
port 6380
daemonize yes
protected-mode no
slave-read-only no
masterauth 1234
requirepass 1234
replicaof 172.169.3.251 6379
redis3.confreplicaof 改为 redis1的ip和端口
bind 0.0.0.0
port 6381
daemonize yes
protected-mode no
slave-read-only no
masterauth 1234
requirepass 1234
replicaof 172.169.3.251 6379
sentinel1.confmyaster 后面 ip和端口 改为redis1的ip和端口
port 26379
dir /tmp
protected-mode no
daemonize yes
sentinel monitor mymaster 172.169.3.251 6379 2
sentinel auth-pass mymaster 1234
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 10000
sentinel deny-scripts-reconfig yes
sentinel2.confmyaster 后面 ip和端口 改为redis1的ip和端口
port 26380
dir /tmp
protected-mode no
daemonize yes
sentinel monitor mymaster 172.169.3.251 6379 2
sentinel auth-pass mymaster 1234
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 10000
sentinel deny-scripts-reconfig yes
sentinel3.confmyaster 后面 ip和端口 改为redis1的ip和端口
port 26381
dir /tmp
protected-mode no
daemonize yes
sentinel monitor mymaster 172.169.3.251 6379 2
sentinel auth-pass mymaster 1234
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 10000
sentinel deny-scripts-reconfig yes
启动服务start_all.sh
#bin/bash
REDIS_HOME=/usr/local/redis
CONFIG_HOME=/usr/loca/redis/conf
$REDIS_HOME/bin/redis-server $CONFIG_HOME/conf/redis1.conf &
sleep 1s
$REDIS_HOME/bin/redis-server $CONFIG_HOME/conf/redis2.conf &
sleep 1s
$REDIS_HOME/bin/redis-server $CONFIG_HOME/conf/redis3.conf &
sleep 1s
$REDIS_HOME/bin/redis-server $CONFIG_HOME/conf/sentinel1.conf --sentinel &
sleep 1s
$REDIS_HOME/bin/redis-server $CONFIG_HOME/conf/sentinel2.conf --sentinel &
sleep 1s
$REDIS_HOME/bin/redis-server $CONFIG_HOME/conf/sentinel3.conf --sentinel &
chmod 777 start_all.sh
./start_all.sh
查看服务ps -ef|grep redis
查看集群状态./redis-cli -p 6379 -a 1234
info replication
应用配置# 哨兵的IP和端口
spring.redis.sentinel.nodes=172.169.3.186:26379,172.169.3.186:26380,172.169.3.186:26381
# sentinel monitor mymaster 172.169.3.251 6379 2 与 这里的 mymaster 一致
spring.redis.sentinel.master=mymaster
# 哨兵是否需要密码,如果未配置,则不需要
spring.redis.sentinel.password=
# redis主从的密码,配置的为1234,故需要配置
spring.redis.password=1234
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧
文章标题:linux安装redis哨兵-创新互联
转载来源:http://lswzjz.com/article/cdjhic.html