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: 后添加" |"

    参考方案

相关推荐
分布式存储与RustFS4 天前
MinIO 官方 Docker 镜像被移除:依赖它的项目该怎么办
docker·云原生·devops·对象存储·minio·分布式存储
IT大白鼠4 天前
Redis 系列 · 第 01 篇——认知入门:Redis 是什么
redis·nosql
彧azz4 天前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
玉&心4 天前
通过Arthas在线诊断K8S中的内存及JVM等使用情况
docker·k8s·arthas
xing-xing4 天前
Docker容器中Nginx站点根目录网页配置访问
nginx·docker
guo_wen_qiang4 天前
上传本地镜像到harbor中
docker·容器·持续部署
羑悻的小杀马特4 天前
Dockerfile 全景指南:从入门编写dockerfile到生产环境镜像优化实战,一步步带你从啃透制作指令到镜像制作落地!
docker·dockerfile·镜像制作
BianHuanShiZhe4 天前
docker常见命令
docker
lbb 小魔仙4 天前
OpenClaw + cpolar 实战:远程 NAS、分享小游戏、RDP,再配置公网 AI 入口
数据库·人工智能·redis·oracle·prometheus
夕除4 天前
redis--018
redis