当前位置:网站首页>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 命令
边栏推荐
猜你喜欢

研发了 5 年的时序数据库,到底要解决什么问题?

ShapeableImageView 的使用,告别shape、三方库

JWT学习

J9数字论:互联网跨链桥有什么作用呢?

快速掌握jmeter(一)——实现自动登录与动态变量

【Psychology · Characters】Issue 1

连续三次 | 灵雀云入选Gartner中国ICT技术成熟度曲线报告

idea 配置resin

Brain-computer interface 003 | Musk said that he has realized a virtual self-dialogue with the cloud, and related concept shares have risen sharply

线程池原理与实践|从入门到放弃,深度解析
随机推荐
ShardingSphere-proxy +PostgreSQL实现读写分离(静态策略)
JVM内存和垃圾回收-05.虚拟机栈
什么是现场服务管理系统(FSM)?有什么好处?
What is a Field Service Management System (FSM)?what is the benefit?
SQL-UDT是什么功能?
A Review of Nature Microbiology: Focusing on the Algae--Ecological Interface of Phytoplankton-Bacteria Interactions
SCANIA SCANIA OTL tag is introduced
7月29-31 | APACHECON ASIA 2022
【学习日记】win64配置openni的vs2022编译环境
牛客题目——滑动窗口的最大值、矩阵最长递增路径、顺时针旋转矩阵、接雨水问题
使用位运算实现加减乘除(+、-、*、/)及比较器的用法
JWT学习
idea 配置resin
Introduction of uncommon interfaces of openlayers
shell:条件语句
ssh配置
动态生成不同类型的订单,请问如何存放到Mongodb数据库?
线程池原理与实践|从入门到放弃,深度解析
【C语言刷题】Leetcode203——移除链表元素
golang刷leetcode 经典(13) 最小高度树