当前位置:网站首页>Redis cluster configuration
Redis cluster configuration
2022-08-02 22:33:00 【1 2 3 Chasing dreams together】
目录
1、Create two bridge virtual machine instance
1.2 Modify the local network configuration file
2.1.5 Specify the installation directory and install
2.2.2 Open the two bridge virtual machine
1、Create two bridge virtual machine instance
1.1 Modify the bridge network

1.2 Modify the local network configuration file
viPattern edit the file
vi /etc/sysconfig/network-scripts/ifcfg-ens33
内容:
TYPE="Ethernet"
BOOTPROTO="static"#修改为static
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="dc066b37-0113-45bb-aac0-04748211c9a7"
DEVICE="ens33"
ONBOOT="yes" #修改为yes
IPADDR=192.168.1.70 #修改本地Ip网段下ip 不能与本地ip相同
GATEWAY=192.168.1.1#Modified for the local gateway
NETMASK=255.255.255.0#Is modified to the local subnet mask
1.3 测试
互相ping下看是否能ping通

2、配置redis集群
2.1 安装redis
2.1.1.安装依赖
redis是由C语言开发,Therefore need to make sure that the server has been installed before installationgcc,Can be installed through the following command to check the server whether:
gcc -v
If not installed using the following command to install:
yum install -y gcc
2.1.2 下载redis安装包上传服务器并解压
# 命令下载,So I download directory for:/usr/local/redis,According to own actual situation to adjust here
wget https://download.redis.io/releases/redis-6.2.6.tar.gz
2.1.3 解压文件
#进入到文件目录
cd /usr/local/redis
# 解压
tar -zxvf redis-6.2.6.tar.gz
2.1.4 编译文件
# Enter the unzipped directory
cd /usr/local/redis/redis-6.2.6
# 编译
make
2.1.5 Specify the installation directory and install
make install PREFIX=/usr/local/redis
2.1.6 修改配置
port 8081 #修改默认端口号
daemonize yes #To the daemon startup services
protected-mode yes #关闭保护模式
bind 0.0.0.0 -::1 #允许任何ip访问
2.1.7 启动服务
进入到安装目录中
redis-server redis.conf
设置开机自启
cd /lib/systemd/system/
# 新建文件
vim redis.service
[Unit]
Description=redis-server
After=network.target[Service]
Type=forking
# ExecStartNeed according to the actual situation changes into its own address
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
PrivateTmp=true[Install]
WantedBy=multi-user.target
# 开机自动启动
systemctl enable redis.service
# 启动redis服务
systemctl start redis.service
# 查看服务状态
systemctl status redis.service
# 停止服务
systemctl stop redis.service
# 取消开机自动启动(卸载服务)
systemctl disabled redis.service
2.1.8 防火墙
Add custom port
firewall-cmd --add-port=端口/tcp --zone=public --permanent #永久添加
systemctl restart firewalld #重启防火墙
2.2 配置redis集群
2.2.1 修改配置文件
cluster-enabled yes #开启集群模式
cluster-config-file nodes-8004.conf#修改配置文件名
appendonly yes#开启AOF快照模式
appendfilename "appendonly8004.aof"#修改配置文件名
2.2.2 Open the two bridge virtual machine
把redis.configAccording to the above configuration copy out6Copy of the open6个redis服务 Achieve a master from mode
编写启动脚本
./redis-server redis8003.conf
./redis-server redis8004.conf
./redis-server redis8005.conf
启动脚本
./start.sh
2.2.3 开启集群
1代表开启3个主节点 Each one from node
./redis-cli --cluster create 192.168.1.70:8003 192.168.1.70:8004 192.168.1.70:8005 192.168.1.71:8001 192.168.1.71:8002 192.168.1.71:8006 --cluster-replicas 1
连接节点
redis-cli -c -p 端口
放行端口
放行8003,8004.....A port on the original release of 在放行18003,18004.......
Cluster mode commonly used commands
1. 查看redis是否是集群模式,info cluster 命令
2. 查看集群的所有节点信息,cluster nodes 命令
3. 查看集群中各个节点的slot区间,cluster slots 命令
4. 查看指定key所在slot的值,cluster keyslot key 命令
边栏推荐
猜你喜欢

解析Collection接口中的常用的被实现子类重写的方法

openlayers不常用接口介绍

【LeetCode】118. 杨辉三角 - Go 语言题解

EasyCVR平台通过国标GB28181接入柯达NVR显示注册失败,该如何解决?

程序员也许都缺一个“二舅”精神

Golang swagger :missing required param comment parameters

Based on OpenGL glaciers and firebird (illumination calculation model, visual, particle system)

牛客题目——滑动窗口的最大值、矩阵最长递增路径、顺时针旋转矩阵、接雨水问题

溜不溜是个问题

Kali命令ifconfig报错command not found
随机推荐
golang刷leetcode 经典(13) 最小高度树
ShardingSphere-proxy +PostgreSQL实现读写分离(静态策略)
7.24 - 每日一题 - 408
什么是现场服务管理系统(FSM)?有什么好处?
【学习日记】win64配置openni的vs2022编译环境
竞赛:糖尿病遗传风险检测挑战赛(科大讯飞)
Redis 5 种数据结构及对应使用场景
7.25 - 每日一题 - 408
MySQL安装(详细,适合小白)
openlayers版本更新差别
You want the metagenomics - microbiome knowledge in all the (2022.8)
el-tree渲染大量数据的解决方案(不通过懒加载)
JVM内存和垃圾回收-06.本地方法栈
Mppt photovoltaic maximum power point tracking control matlab simulation
TPAMI2022 | TransCL:基于Transformer的压缩学习,更灵活更强大
Therapy | How to Identify and Deal with Negative Thoughts
J9数字论:互联网跨链桥有什么作用呢?
golang刷leetcode动态规划(11)不同路径
golang刷leetcode 动态规划(13) 最长公共子序列
JWT学习