Docker 集成 redis,并在nacos进行配置时需要注意点

安装redis镜像

shell 复制代码
docker pull redis:6.0.6

redis配置文件

  • 创建相关配置文件

    shell 复制代码
    mkdir /apps/redis
    cd /apps/redis
    touch redis.conf
    vim redis.conf

    redis.conf内容:

    #开启保护

    protected-mode yes

    #开启远程连接

    bind 0.0.0.0

    #自定义密码

    port 6379

    timeout 0

    900s内至少一次写操作则执行bgsave进行RDB持久化

    save 900 1

    save 300 10

    save 60 10000

    rdbcompression yes

    dbfilename dump.rdb

    dir /data

    appendonly yes

    appendfsync everysec

docker-compose文件内容

  • 创建编排文件

    shell 复制代码
    cd /apps
    touch docker-compose.yaml

    具体内容如下:

    shell 复制代码
    services: 
      myredis:
          container_name: myredis
          image: redis:6.0.6
          restart: always
          ports:
            - 36379:6379
          privileged: true
          command: redis-server /etc/redis/redis.conf --appendonly yes
          volumes:
            - ./redis/data:/data
            - ./redis/redis.conf:/etc/redis/redis.conf
  • 执行安装

    shell 复制代码
    docker-compose -f docker-compose.yaml up -d

nacos进行配置时需要注意点

  • nacos使用配置中心,启动项目控制台报错:NACOS HTTP-GET The maximum number of tolerable server reconnection errors has been reached

    由于Redisson在解析配置时,无法解析"!<org.redisson.codec.JsonJacksonCodec> {}"导致的,解决方式在config: 后添加" |"

    参考方案

相关推荐
lichenyang4532 天前
Docker 学习笔记(五):Docker Compose,用一个 YAML 启动前端、后端和 MongoDB
docker
lichenyang4532 天前
Docker 学习笔记(四):Dockerfile,把项目打成自己的镜像
docker·容器
lichenyang4532 天前
Docker 学习笔记(三):Docker 网络、bridge、子网和容器互通
docker·容器
lichenyang4532 天前
Docker 学习笔记(二):docker run 的参数到底在控制什么?
docker·容器
用户3074596982072 天前
Redis 延时队列详解
redis
烤代码的吐司君2 天前
Redis 数据结构 ZSet, BIT, HyperLogLog,Geo 空间数据
redis·后端
吃饱了得干活3 天前
Spring Cloud Gateway 微服务网关:路由、断言、过滤器
java·spring cloud
leeyi5 天前
Checkpoint 机制:Agent 怎么在断电后接着跑
redis·aigc·agent
云技纵横6 天前
一个 @Async 让循环依赖暴雷:Spring 代理的暗坑
redis
Patrick_Wilson6 天前
从「改个端口」到 502:Next.js on k8s 的容器端口、Service 映射与 env 覆盖
docker·kubernetes·next.js