当前位置:网站首页>Redis分布式集群搭建
Redis分布式集群搭建
2022-06-13 08:35:00 【T浩浩】
redis版本 6.0.6 集群版本3主3从
准备阶段
1.官网下载redis安装包
2.解压到指定文件夹
3.进入解压好的安装包安装redis
安装阶段
并且创建6个文件夹 7000 70001 7002 7003 7004 7005
make install PREFIX=/usr/local/app/redis/7000
安装好后将/usr/local/app/redis/7000/* 复制到其他几个文件夹
cp -r /usr/local/app/redis/7000/* /usr/local/app/redis/7001
配置阶段
# 配置文件进行了精简,完整配置可自行和官方提供的完整conf文件进行对照。端口号自行对应修改
#后台启动的意思
daemonize yes
#端口号
port 7000
# IP绑定,redis不建议对公网开放,这里绑定了服务器私网IP及环回地址
bind 172.17.0.13 127.0.0.1
# redis数据文件存放的目录
dir /redis/workingDir
# 日志文件
logfile "/redis/logs/cluster-node-7000.log"
# 开启AOF
appendonly yes
# 开启集群
cluster-enabled yes
# 集群持久化配置文件,内容包含其它节点的状态,持久化变量等,会自动生成在上面配置的dir目录下
cluster-config-file cluster-node-6381.conf
# 集群节点不可用的最大时间(毫秒),如果主节点在指定时间内不可达,那么会进行故障转移
cluster-node-timeout 5000
# 云服务器上部署需指定公网ip
cluster-announce-ip 122.51.151.130
# Redis总线端口,用于与其它节点通信
cluster-announce-bus-port 17000
启动redis(可以创建shell脚本直接全部启动)
touch redis-start.sh
vi redis-start.sh
cd /usr/local/app/redis/7000/bin
redis-server redis.conf
cd /usr/local/app/redis/7001/bin
redis-server redis.conf
cd /usr/local/app/redis/7002/bin
redis-server redis.conf
cd /usr/local/app/redis/7003/bin
redis-server redis.conf
cd /usr/local/app/redis/7004/bin
redis-server redis.conf
cd /usr/local/app/redis/7005/bin
redis-server redis.conf
修改文件权限
chmod u+x redis-start.sh
执行文件
./redis-start.sh
查看redis启动状态
ps aux|grep redis
创建redis集群
进入/usr/local/app/redis/7000/bin
./redis-cli --cluster create 192.168.0.80:7000 192.168.0.80:7001 192.168.0.80:7002 192.168.0.80:7003 192.168.0.80:7004 192.168.0.80:7005 --cluster-replicas 1
查看集群状态
cat nodes.conf
配置完成了
使用客户端 使用集群要加-c
./redis-cli -h 127.0.0.1 -p 7000 -c
注意:需要在防火墙和服务器出入规则添加 7000 17000端口,其他几个端口也一样
边栏推荐
- When submitting the laravel admin form and using the required verification, an error is reported when the value is 0
- Logstash configuration reference article
- 微服务项目搭建三:自动生成代码
- How to download and install stm32cubemx
- Emotion handling skills
- Tmall product details interface, tmall product coupon interface, tmall API interface, tmall price monitoring interface, tmall price comparison interface, brand rights protection interface, tmall sales
- Start from scratch - implement the jpetstore website -1- establish the project framework and project introduction
- Is there any good management software to solve the problems faced by tea wholesalers
- filebeat采集日志到ELK
- WARNING:tornado. access:404 GET /favicon. ICO (172.16.8.1) 1.84ms [with static file settings]
猜你喜欢
Notes on development experience: TP5 exp query, SQL analysis, JQ, applet, right-click menu, Linux skills, shell skills, mysql, etc
How to download and install stm32cubemx
JS - set countdown for Date object case
容器概念和云原生
1.SolidWorks各模块的学习顺序
MySQL queries difference sets (missing data) by linking tables based on an associated field
Buuctf web (V)
4、 Js-es5-i / O
Buffer Overflow Vulnerability Lab
Process and scheduled task management
随机推荐
Learning record 4:einops / / cudnn benchamark=true // hook
学习记录4: einops // cudnn.benchamark=true // hook
Notes on MySQL transaction not automatically submitting
Four ways to install MySQL in Linux
Installing pytorch under Anaconda
Buuctf web (V)
HCIP_ OSPF irregular area
淘宝商品历史价格接口/商品历史价走势接口代码对接分享
【leetcode周赛记录】第80场双周赛记录
Penetration problem (main directory, password explosion, database uploading Trojan horse)
Buuctf web (VII)
How to download and install stm32cubemx
LVM management exercise
Shellshock Attack Lab
Time and date processing in JS
Namespace in TS (1)
Dest0g3 520 orientation
Methods of importing and exporting settings in Altium Designer
Svg text stroke effect
Sizeof, strlen find character length