Alions 8.6 下 Redis 7.2.0 集群搭建和配置

news2024/9/30 13:26:53

Redis 7.2.0 搭建和集群配置

  • 一.Redis 下载与单机部署
    • 1.Redis 下载
    • 2.虚拟机配置
    • 3.Redis 单机源码安装和测试
    • 4.Java 单机连接测试
      • 1.Pom 依赖
      • 2.配置文件
      • 3.启动类
      • 4.配置类
      • 5.单元测试
      • 6.测试结果
  • 二.Redis 集群部署
    • 1.主从
      • 1.从节点配置
      • 2.Java 测试
    • 2.哨兵
      • 1.哨兵节点配置
      • 2.复制一个哨兵节点(双哨兵)
      • 3.Java 测试访问哨兵
    • 3.集群
      • 1.集群配置文件修改
      • 2.Java 访问 Redis 集群测试

一.Redis 下载与单机部署

1.Redis 下载

Redis 官网

在这里插入图片描述

2.虚拟机配置

## 1.关闭防火墙
systemctl stop firewalld && systemctl disable firewalld && systemctl status firewalld
## 2.配置域名解析
echo '192.168.1.103 rd1' >> /etc/hosts
echo '192.168.1.104 rd2' >> /etc/hosts
echo '192.168.1.105 rd3' >> /etc/hosts
echo '192.168.1.106 rd4' >> /etc/hosts
echo '192.168.1.107 rd5' >> /etc/hosts
echo '192.168.1.108 rd6' >> /etc/hosts

关闭并禁用防火墙

在这里插入图片描述

3.Redis 单机源码安装和测试

## 1.解压缩
tar zxvf redis-7.2.0.tar.gz
## 2.进入源码安装目录
cd /home/redis-7.2.0/src/
## 3.编译和安装
make && make install PREFIX=/usr/local/redis
## 4.进入Redis解压目录
cd /home/redis-7.2.0/
## 5.修改配置
vim redis.conf
## 6.启动服务
/usr/local/redis/bin/redis-server redis.conf &
## 7.停止服务
kill -9 `ps aux |grep redis|grep -v grep | awk '{print $2}'`

以下行号仅供参考,增加配置后会有微小变动

行号原值新值含义
87bind 127.0.0.1 -::1bind 0.0.0.0 -::1绑定地址
111protected-mode yes#protected-mode no防火墙保护
533replicaof replicaof rd1 6379配置主节点(主从同步)
541masterauth masterauth 123456配置主节点密码(主从同步)
535requirepass 123456密码(在空行添加)

哨兵配置(可在配置哨兵模式时参考)

行号原值新值含义
92sentinel monitor sentinel monitor mymaster 192.168.1.103 6379 1哨兵初始监控的主机地址
112sentinel auth-pass mymaster MySUPER–secret-0123passw0rdsentinel auth-pass mymaster 123456哨兵配置主节点密码(保持所有节点密码一致,避免重新选取主节点后连接失败)
170requirepass requirepass 456789哨兵密码

服务启动

在这里插入图片描述

连接测试

在这里插入图片描述

连接

在这里插入图片描述

4.Java 单机连接测试

1.Pom 依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>redis-demo</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>20</maven.compiler.source>
        <maven.compiler.target>20</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>3.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
            <version>3.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-pool2</artifactId>
            <version>2.11.1</version>
        </dependency>

        <!-- 测试类 -->

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>3.1.2</version>
        </dependency>
    </dependencies>
</project>

2.配置文件

spring:
  data:
    redis:
      host: 192.168.1.103
      port: 6379
      password: 123456

3.启动类

package org.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * @author zhuwd && moon
 * @Description
 * @create 2023-08-22 22:28
 */
@SpringBootApplication
public class RedisApp {
    public static void main(String[] args) {
        SpringApplication.run(RedisApp.class,args);
    }
}

4.配置类

package org.example.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Component;

/**
 * @author zhuwd && moon
 * @Description
 * @create 2023-08-22 22:29
 */
@Component
public class RedisConfig {

    private RedisConnectionFactory redisConnectionFactory;

    @Autowired
    public void setRedisConnectionFactory(RedisConnectionFactory redisConnectionFactory) {
        this.redisConnectionFactory = redisConnectionFactory;
    }

    @Bean(name = "redisTemplate")
    public RedisTemplate<String, Object> redisTemplate(){
        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
        // 序列化key
        redisTemplate.setKeySerializer(new StringRedisSerializer());
        redisTemplate.setValueSerializer(new StringRedisSerializer());
        // 序列化hash
        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
        redisTemplate.setHashValueSerializer(new StringRedisSerializer());
        // 连接redis数据库
        redisTemplate.setConnectionFactory(redisConnectionFactory);
        return redisTemplate;
    }
}

5.单元测试

import org.example.RedisApp;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @author zhuwd && moon
 * @Description
 * @create 2023-08-22 22:29
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = RedisApp.class)
public class TestApp {

    @Autowired
    RedisTemplate<String, Object> redisTemplate;

    @Test
    public void test(){
        redisTemplate.opsForValue().set("test","haha");
    }
}

6.测试结果

在这里插入图片描述

查看值

在这里插入图片描述

二.Redis 集群部署

集群信息

HostIP
rd1192.168.1.103
rd2192.168.1.104
rd3192.168.1.105
rd4192.168.1.106
rd5192.168.1.107
rd6192.168.1.108
## 1.将修改后的配置文件复制到安装目录
cp /home/redis-7.2.0/redis.conf /usr/local/redis/

1.主从

1.从节点配置

## 1.将 Redis 包拷贝到 rd2 / rd3
scp -r /usr/local/redis root@rd2:/usr/local/redis
scp -r /usr/local/redis root@rd3:/usr/local/redis
## 2.修改 rd2 / rd3 上 redis.conf 配置增加主节点信息 replicaof rd1 6379 / masterauth 123456
vi /usr/local/redis/redis.conf
## 3.依次启动 rd1 rd2 rd3
/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf &
## 4.客户端连接
/usr/local/redis/bin/redis-cli
## 5.认证
auth 123456

Redis 安装包复制

在这里插入图片描述

增加主节点配置

在这里插入图片描述

主节点启动信息

在这里插入图片描述

从节点启动信息

在这里插入图片描述

查看主从信息

在这里插入图片描述

2.Java 测试

通过上面测试代码写入主节点

在这里插入图片描述

主从模式故障不支持自动恢复,需要人为处理,从节点读需要手动写读取代码

2.哨兵

1.哨兵节点配置

## 1.复制 redis 包到 rd4
scp -r /usr/local/redis root@rd4:/usr/local/redis
## 2.拷贝 sentinel 配置文件
scp -r /home/redis-7.2.0/sentinel.conf root@rd4:/usr/local/redis/
## 3.修改哨兵配置 
# sentinel monitor <master-redis-name> <master-redis-ip> <master-redis-port> <quorum>
# quorum 表示当有多少个 sentinel 认为一个 master 失效时才算真正失效(取值参考 sentinels/2 + 1)
vi /usr/local/redis/sentinel.conf
## 将 92 行修改为 sentinel monitor mymaster 192.168.1.103 6379 1
## 在 112 行增加 sentinel auth-pass mymaster 123456
## 在 170 行增加 requirepass 123456
## 4.启动哨兵
/usr/local/redis/bin/redis-sentinel /usr/local/redis/sentinel.conf &
## 5.查看信息
/usr/local/redis/bin/redis-cli -p 26379
127.0.0.1:26379> info

修改配置

插入图片描述](https://img-blog.csdnimg.cn/23fad4f11e32475e840313b3320c1ae3.png

哨兵启动信息,注意端口为 26379

图片描述](https://img-blog.csdnimg.cn/0651a222fce84eddbf019df0547b2c72.png

查看哨兵信息

在这里插入图片描述

2.复制一个哨兵节点(双哨兵)

## 1.停止所有节点
kill -9 `ps aux |grep redis|grep -v grep | awk '{print $2}'`
## 2.创建日志目录
mkdir -p logfile /var/log/redis
## 3.修改配置文件 增加日志输出 大概 355 行
vi /usr/local/redis/redis.conf
vi /usr/local/redis/sentinel.conf
## 增加 logfile /var/log/redis/redis.log
## 增加 logfile /var/log/redis/sentinel.log
## 4.复制配置好的哨兵文件到 rd5
scp -r /usr/local/redis root@rd5:/usr/local/redis
## 5.启动 rd1 / rd2 / rd3
/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf &
## 6.启动 rd4 / rd5 的哨兵
/usr/local/redis/bin/redis-sentinel /usr/local/redis/sentinel.conf &

3.Java 测试访问哨兵

配置文件

spring:
  data:
    redis:
      password: 123456 # 访问主从节点的密码
      sentinel:
        master: mymaster
        nodes: 192.168.1.106:26379,192.168.1.107:26379
        password: 123456 # 访问哨兵的密码
      lettuce:
        pool:
          max-idle: 50
          min-idle: 10
          max-active: 100
          max-wait: 1000
          
logging:
  level:
    root: info
    io.lettuce.core: debug
    org.springframework.data.redis: debug

配置类

package org.example.config;

import io.lettuce.core.ReadFrom;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisClusterConfiguration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Component;

import java.time.Duration;
import java.util.HashSet;

/**
 * @author zhuwd && moon
 * @Description
 * @create 2023-08-22 22:29
 */
@Component
public class RedisConfig {

    /**
     * 配置 Redis 工厂
     * @param properties
     * @return
     */
    @Bean(name = "redisConnectionFactory")
    public RedisConnectionFactory redisConnectionFactory(RedisProperties properties) {

        //取配置
        RedisProperties.Cluster cluster = properties.getCluster();
        RedisProperties.Sentinel sentinel = properties.getSentinel();
        RedisProperties.Pool pool = properties.getLettuce().getPool();
        //池化配置
        LettucePoolingClientConfiguration poolingClientConfiguration = LettucePoolingClientConfiguration.builder().readFrom(ReadFrom.ANY_REPLICA).build();
        if (null != pool){
            if (pool.getMaxIdle() > 0){
                poolingClientConfiguration.getPoolConfig().setMaxIdle(pool.getMaxIdle());
            }
            if (pool.getMinIdle() > 0){
                poolingClientConfiguration.getPoolConfig().setMinIdle(pool.getMinIdle());
            }
            if (pool.getMaxActive() > 0){
                poolingClientConfiguration.getPoolConfig().setMaxTotal(pool.getMaxActive());
            }
            if (pool.getMaxWait().compareTo(Duration.ZERO) > 0){
                poolingClientConfiguration.getPoolConfig().setMaxWait(pool.getMaxWait());
            }
        }
        //Redis 配置
        if (null != cluster){
            //集群
            RedisClusterConfiguration clusterConfiguration = new RedisClusterConfiguration(cluster.getNodes());
            if (null != properties.getPassword()){
                clusterConfiguration.setPassword(properties.getPassword());
            }
            if (null != cluster.getMaxRedirects()){
                clusterConfiguration.setMaxRedirects(cluster.getMaxRedirects());
            }
            return new LettuceConnectionFactory(clusterConfiguration,poolingClientConfiguration);
        } else if (null != sentinel){
            //哨兵
            RedisSentinelConfiguration sentinelConfiguration = new RedisSentinelConfiguration(sentinel.getMaster(),new HashSet<>(sentinel.getNodes()));
            sentinelConfiguration.setSentinelPassword(sentinel.getPassword());
            sentinelConfiguration.setPassword(properties.getPassword());
            //设置从节点读
            return new LettuceConnectionFactory(sentinelConfiguration,poolingClientConfiguration);
        } else {
            //单机
            RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
            config.setHostName(properties.getHost());
            config.setPort(properties.getPort());
            config.setPassword(properties.getPassword());
            return new LettuceConnectionFactory(config);
        }
    }

    /**
     * redis 配置
     * @param redisConnectionFactory
     * @return
     */
    @Bean(name = "redisTemplate")
    public RedisTemplate<String, Object> redisTemplate(@Qualifier("redisConnectionFactory") RedisConnectionFactory redisConnectionFactory){
        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
        // 序列化key
        redisTemplate.setKeySerializer(new StringRedisSerializer());
        redisTemplate.setValueSerializer(new StringRedisSerializer());
        // 序列化hash
        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
        redisTemplate.setHashValueSerializer(new StringRedisSerializer());
        // 连接redis数据库
        redisTemplate.setConnectionFactory(redisConnectionFactory);
        return redisTemplate;
    }

}

启动类

package org.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * @author zhuwd && moon
 * @Description
 * @create 2023-08-22 22:28
 */
@SpringBootApplication
public class RedisApp {

    public static void main(String[] args) {
        SpringApplication.run(RedisApp.class,args);
    }
}

测试类

package org.example.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhuwd && moon
 * @Description
 * @create 2023-08-23 20:13
 */
@RequestMapping("/redis")
@RestController
public class RedisTest {

    @Autowired
    RedisTemplate<String, Object> redisTemplate;

    @GetMapping("/write")
    public void write(String key,String val){
        redisTemplate.opsForValue().set(key,val);
    }

    @GetMapping("/read")
    public void read(String key){
        System.out.println(redisTemplate.opsForValue().get(key));
    }
}

查看主节点:/usr/local/redis/bin/redis-cli -p 26379

在这里插入图片描述

启动服务

在这里插入图片描述

测试写集群:127.0.0.1:8080/redis/write?key=test&val=hello

在这里插入图片描述

写节点:rd3

在这里插入图片描述

读数据:rd2

在这里插入图片描述

杀掉主节点并等待:kill -9 ps aux |grep redis|grep -v grep | awk '{print $2}'

在这里插入图片描述

查看 rd4 哨兵,主节点切为 rd2

这里插入图片描述](https://img-blog.csdnimg.cn/3350f7bb15df4a74bde5c2034fd62771.png

查看 rd5 哨兵,主节点

在这里插入图片描述

写测试:127.0.0.1:8080/redis/write?key=test&val=reHello

在这里插入图片描述

读测试:127.0.0.1:8080/redis/read?key=test

在这里插入图片描述

恢复 rd5 服务:/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf &

在这里插入图片描述

通过 rd1 查看从节点信息

在这里插入图片描述

3.集群

清除之前测试写入的数据
查找持久化文件:find / -type f -name dump.rdb 如果存在也删掉

1.集群配置文件修改

## 1.在 rd1 复制配置文件
cp /home/redis-7.2.0/redis.conf /usr/local/redis/redis-cluster.conf
## 2.编辑
vim /usr/local/redis/redis-cluster.conf
## 设置密码 requirepass 123456
## 关闭保护模式 protected-mode no
## 开启集群 cluster-enabled yes 约1586行
## 设置配置文件 cluster-config-file redis-cluster.conf 约1594行
## 设置超时 cluster-node-timeout 15000 约1600行
## 设置主节点密码 masterauth 123456
## 设置日志 logfile /var/log/redis/redis-cluster.log
## 3.将 redis-cluster.conf 分发到 rd2 / rd3 / rd4 / rd5 / rd6
scp /usr/local/redis/redis-cluster.conf root@rd2:/usr/local/redis/
scp /usr/local/redis/redis-cluster.conf root@rd3:/usr/local/redis/
scp /usr/local/redis/redis-cluster.conf root@rd4:/usr/local/redis/
scp /usr/local/redis/redis-cluster.conf root@rd5:/usr/local/redis/
scp /usr/local/redis/redis-cluster.conf root@rd6:/usr/local/redis/
## 4.依次启动 rd1 / rd2 /rd3 /rd4 /rd5 / rd6
/usr/local/redis/bin/redis-server /usr/local/redis/redis-cluster.conf &
## 5.清空已有数据
## 5.创建集群 在任一节点执行
## -a 密码认证,若没写密码无效带这个参数
## --cluster create 创建集群实例列表 IP:PORT IP:PORT IP:PORT IP:PORT IP:PORT IP:PORT
## --cluster-replicas 复制因子1(即每个主节点需2个从节点)
/usr/local/redis/bin/redis-cli -a 123456 --cluster create --cluster-replicas 1 192.168.1.103:6379 192.168.1.104:6379 192.168.1.105:6379 192.168.1.106:6379 192.168.1.107:6379 192.168.1.108:6379

启动所有节点服务

在这里插入图片描述

创建集群:集群至少要三个主节点,

在这里插入图片描述

查看集群信息和集群节点

在这里插入图片描述

新建三台虚拟机

HostIP
rd7192.168.1.109
rd8192.168.1.110
rd9192.168.1.111
## 1.新建三台虚拟机并分发配置 rd7 / rd8 /rd9
scp -r /usr/local/redis root@192.168.1.109:/usr/local/
scp -r /usr/local/redis root@192.168.1.110:/usr/local/
scp -r /usr/local/redis root@192.168.1.111:/usr/local/
## 2.创建日志目录 / 关闭防火墙并禁用
mkdir -p /var/log/redis
systemctl stop firewalld && systemctl disable firewalld
## 3.启动 rd7 / rd8 /rd9
/usr/local/redis/bin/redis-server /usr/local/redis/redis-cluster.conf &
## 4.将新节点添加到当前集群 在 rd1 执行
## -a 密码认证,若没写密码无效带这个参数
## --cluster add-node 创建集群实例列表 IP:PORT IP:PORT IP:PORT IP:PORT IP:PORT IP:PORT
## 要有一个节点为当前集群的节点
## /usr/local/redis/bin/redis-cli -a 123456 --cluster add-node 192.168.1.109:6379 192.168.1.110:6379 192.168.1.111:6379 192.168.1.103:6379

查看集群命令说明:/usr/local/redis/bin/redis-cli --cluster help

在这里插入图片描述

## 添加主节点
/usr/local/redis/bin/redis-cli -a 123456 --cluster add-node 192.168.1.109:6379 192.168.1.103:6379
## 如果 slot 分配不均,可以用如下命令修复集群
## 分配不均报错如下 [ERR] Not all 16384 slots are covered by nodes.
/usr/local/redis/bin/redis-cli -a 123456 --cluster fix 192.168.1.103:6379
## 执行 resharding 指令来为它分配 hash slots
## 执行下面命令后要依次设置移动 slot 的节点 ID 源节点列表,可直接用 all
/usr/local/redis/bin/redis-cli -a 123456 --cluster reshard 192.168.1.103:6379

添加主节点并查看结果(部分截图)

在这里插入图片描述

查看主从节点状态:/usr/local/redis/bin/redis-cli -a 123456 --cluster check 192.168.1.103:6379 | grep ‘M|S’

在这里插入图片描述

## 随机添加从节点,优先添加到从节点少的节点下
/usr/local/redis/bin/redis-cli -a 123456 --cluster add-node 192.168.1.110:6379 192.168.1.103:6379 --cluster-slave
## 添加到指定主节点下(添加到 103 即 rd1 下面)
/usr/local/redis/bin/redis-cli -a 123456 --cluster add-node 192.168.1.111:6379 192.168.1.103:6379 --cluster-slave --cluster-master-id 9e99c815e3660680439261573c5c5b382573cf1c

随机添加

在这里插入图片描述

查看主从节点状态:/usr/local/redis/bin/redis-cli -a 123456 --cluster check 192.168.1.103:6379

在这里插入图片描述

2.Java 访问 Redis 集群测试

配置集群主节点

spring:
  data:
    redis:
      password: 123456 # 访问主从节点的密码
      cluster:
        max-redirects: 10
        nodes: 192.168.1.103:6379,192.168.1.105:6379,192.168.1.108:6379,192.168.1.109:6379
      lettuce:
        pool:
          max-idle: 50
          min-idle: 10
          max-active: 100
          max-wait: 1000
          enabled: true

logging:
  level:
    root: info
    io.lettuce.core: debug
    org.springframework.data.redis: debug

修改插入方法计算 SLOT

package org.example.controller;

import io.lettuce.core.codec.CRC16;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhuwd && moon
 * @Description
 * @create 2023-08-23 20:13
 */
@RestController
@RequestMapping("/redis")
public class RedisTest {

    @Autowired
    RedisTemplate<String, Object> redisTemplate;

    private static final int SLOT_S = 16384;

    @GetMapping("/write")
    public void write(String key,String val){
        int slot = CRC16.crc16(key.getBytes())%SLOT_S;
        redisTemplate.opsForValue().set(key,val);
        System.out.println("slot " + slot + " key " + key + " val " + val);
    }

    @GetMapping("/read")
    public void read(String key){
        System.out.println(redisTemplate.opsForValue().get(key));
    }
}

测试插入数据:127.0.0.1:8080/redis/write?key=test&val=reHello

在这里插入图片描述

查看日志插入主节点为 rd3【192.168.1.105】,槽号为 6918

在这里插入图片描述

读数据:127.0.0.1:8080/redis/read?key=test

在这里插入图片描述

从节点 192.168.1.104 为 rd2,查看其是否为 rd3 从节点:/usr/local/redis/bin/redis-cli -a 123456 --cluster check 192.168.1.103:6379

在这里插入图片描述

客户端查看数据

在这里插入图片描述

查看集群槽号 12376 属于 103 节点 rd1

在这里插入图片描述

插入 Key 测试其节点:127.0.0.1:8080/redis/write?key=RedisTJXY&val=12376

在这里插入图片描述

查看客户端数据

在这里插入图片描述

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/920052.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

使用 ChatGPT 创建 PowerPoint 演示文稿

让 ChatGPT 成为您的助手来帮助您编写电子邮件很简单,因为众所周知,它非常能够生成文本。很明显,ChatGPT 无法帮助您做饭。但您可能想知道它是否可以生成文本以外的其他内容。在上一篇文章中,您了解到 ChatGPT 只能通过中间语言为您生成图形。在这篇文章中,您将了解使用中…

无涯教程-PHP - intval() 函数

PHP 7引入了一个新函数 intdiv()&#xff0c;该函数对其操作数执行整数除法并将该除法返回为int。 <?php$valueintdiv(10,3);var_dump($value);print(" ");print($value); ?> 它产生以下浏览器输出- int(3) 3 PHP - intval() 函数 - 无涯教程网无涯教程网…

Matlab绘制二值图像

二值化介绍 只有黑白两种颜色的图像称为黑白图像或单色图像&#xff0c;是指图像的每个像素只能是黑或者白&#xff0c;没有中间的过渡&#xff0c;故又称为二值图像。其特点是二值图像的像素值只能为0和1&#xff0c;分别代表黑色和白色&#xff0c;图像中的每个像素值用1位存…

C++ 网络编程项目fastDFS分布式文件系统(六)--qt(client)+login

目录 1. 登录和注册协议 1.1 注册协议 1.2 登录协议 2. 单例模式 1. 登录和注册协议 1.1 注册协议 # URL http://192.168.1.100:80/reg # post数据格式 { userName:xxxx, nickName:xxx, firstPwd:xxx, phone:xxx, email:xxx } 2. 服务器端 - Nginx 服务器端的配置。 loc…

数据结构初阶--排序

目录 一.排序的基本概念 1.1.什么是排序 1.2.排序算法的评价指标 1.3.排序的分类 二.插入排序 2.1.直接插入排序 2.2.希尔排序 三.选择排序 3.1.直接选择排序 3.2.堆排序 重建堆 建堆 排序 四.交换排序 4.1.冒泡排序 4.2.快速排序 快速排序的递归实现 法一&a…

基于OpenCV实战(基础知识一)

目录 简介 1.计算机眼中的图像 2.图片的读取、显示与保存 3.视频的读取与显示 简介 OpenCV是一个流行的开源计算机视觉库&#xff0c;由英特尔公司发起发展。它提供了超过2500个优化算法和许多工具包&#xff0c;可用于灰度、彩色、深度、基于特征和运动跟踪等的图像处理和…

蓝帽杯半决赛2022

手机取证_1 iPhone手机的iBoot固件版本号:&#xff08;答案参考格式&#xff1a;iBoot-1.1.1&#xff09; 直接通过盘古石取证 打开 取证大师和火眼不知道为什么都无法提取这个 手机取证_2 该手机制作完备份UTC8的时间&#xff08;非提取时间&#xff09;:&#xff08;答案…

[虚幻引擎 UE5] EditableText(可编辑文本) 限制只能输入数字并且设置最小值和最大值

本蓝图函数可以格式化 EditableText 控件输入的数据&#xff0c;让其只能输入一定范围内的整数。 蓝图函数 调用方法 下载蓝图&#xff08;5.2.1版本&#xff09;https://dt.cq.cn/archives/618

yolo笔记

目录 输入端Mosaic数据增强数据增强Copy-paste数据增强- MixUp数据增强- Albumentations数据增强- Augment HSV (Hue, Saturation, Value)色度、饱和度、浓度数据增强- Random horizontal flip自适应锚框计算自适应图片缩放 BackboneFocus结构CSP结构CSP结构Neck 损失函数IOU_L…

【hello git】初识Git

目录 一、简述Git 二、Linux 下 Git 的安装&#xff1a;CentOS 2.1 基本命令 2.2 示例&#xff1a; 三、Linux 下 Git 的安装&#xff1a;ubuntu 3.1 基本命令 3.2 示例&#xff1a; 一、简述Git Git &#xff1a;版本控制器&#xff0c;记录每次的修改以及版本迭代的一个管…

OpenEuler 安装mysql

下载安装包 建议直接使用在openEuler官方编译移植过的mysql-5.7.21系列软件包 参考&#xff1a;操作系统迁移实战之在openEuler上部署MySQL数据库 | 数据库迁移方案 | openEuler社区官网 MySQL 5.7.21 移植指南&#xff08;openEuler 20.03 LTS SP1&#xff09; | 数据库移植…

java Spring Boot将不同配置拆分入不同文件管理

关于java多环境开发 最后还有一个小点 我们一般会将不同的配置 放在不同的配置文件中 好处肯定就在于 想换的时候非常方便 那么 我们直接看代码 我们将项目中的 application.yml 更改代码如下 spring:profiles:active: dev这里 意思是 我们选择了dev 环境 然后创建一个文件 …

进行Stable Diffusion的ai训练怎么选择显卡?

Stable Diffusion主要用于从文本生成图像&#xff0c;是人工智能技术在内容创作行业中不断发展的应用。要在本地计算机上运行Stable Diffusion&#xff0c;您需要一个强大的 GPU 来满足其繁重的要求。强大的 GPU 可以让您更快地生成图像&#xff0c;而具有大量 VRAM 的更强大的…

如何使用CSS实现一个响应式轮播图?

聚沙成塔每天进步一点点 ⭐ 专栏简介⭐ 使用CSS实现响应式轮播图的示例⭐ HTML 结构⭐ CSS 样式 (styles.css)⭐ JavaScript 代码 (script.js)⭐ 实现说明⭐ 写在最后 ⭐ 专栏简介 前端入门之旅&#xff1a;探索Web开发的奇妙世界 记得点击上方或者右侧链接订阅本专栏哦 几何带…

前端进阶Html+css10----定位的参照对象(高频面试题)

1.relative的参照对象 1&#xff09;元素按照标准流进行排布&#xff1b; 2&#xff09;定位参照对象是元素自己原来的位置&#xff0c;可以通过left、right、top、bottom来进行位置调整&#xff1b; 2.absolute&#xff08;子绝父相&#xff09; 1&#xff09;元素脱离标准流…

SpringBoot +Vue3 简单的前后端交互

前端&#xff1a;Vue3 创建项目&#xff1a; npm create vuelatest > cd <your-project-name> > npm install > npm run dev 项目结构图如下&#xff1a; 1、查看入口文件内容&#xff1a;main.js 代码如下&#xff1a; import ./assets/main.css impor…

AWS 提示证书签名过期无法自动更新

如果域名没有通过验证的话&#xff0c;证书的过去是没有办法自动更新的。 验证的方式也非常简单&#xff0c;通过下面的配置&#xff0c;把 CNAME添加到你的域名上面&#xff0c;AWS 就可会自动完成验证了。 当添加完成后&#xff0c;AWS 验证需要的时间大致在 30 分钟到 1 个…

smaps解析

我们查看应用内存都是通过adb shell dumpsys meminfo 应用名称或者pid 的方式获取 能获取的内容如下&#xff1a; 图1 数据项pss即是应用所占用的内存。那图中各项内容是怎么来的呢&#xff1f; 图2 图1种除了 EGL mtrack&#xff0c;GL mtrack都是从smaps文件种解析获得 EG…

.NET Core 实现日志打印输出在控制台应用程序中

在本文中&#xff0c;我们将探讨如何在 .NET Core 应用程序中将日志消息输出到控制台&#xff0c;从而更好地了解应用程序的运行状况。 .NET Core 实现日志打印输出在控制台应用程序中 在 .NET Core 中&#xff0c;日志输出打印是使用 Microsoft.Extensions.Logging 命名空间…

Android——基本控件下(十七)

1. 文本切换&#xff1a;TextSwitcher 1.1 知识点 &#xff08;1&#xff09;理解TextSwitcher和ViewFactory的使用。 1.2 具体内容 范例&#xff1a;切换显示当前时间 <LinearLayout xmlns:android"http://schemas.android.com/apk/res/android"xmlns:tools&…