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

    参考方案

相关推荐
AAA修煤气灶刘哥9 小时前
别让Redis「歪脖子」!一次搞定数据倾斜与请求倾斜的捉妖记
redis·分布式·后端
christine-rr21 小时前
linux常用命令(4)——压缩命令
linux·服务器·redis
muyun280021 小时前
Docker 下部署 Elasticsearch 8 并集成 Kibana 和 IK 分词器
elasticsearch·docker·容器
麦兜*21 小时前
MongoDB Atlas 云数据库实战:从零搭建全球多节点集群
java·数据库·spring boot·mongodb·spring·spring cloud
凯子坚持 c1 天前
精通 Redis list:使用 redis-plus-plus 的现代 C++ 实践深度解析
c++·redis·list
熙客1 天前
SpringCloud概述
java·spring cloud·微服务
weixin_456904271 天前
跨域(CORS)和缓存中间件(Redis)深度解析
redis·缓存·中间件
波波烤鸭1 天前
Redis 高可用实战源码解析(Sentinel + Cluster 整合应用)
数据库·redis·sentinel
傻傻虎虎1 天前
【Docker】常用帮忙、镜像、容器、其他命令合集(2)
运维·docker·容器
MarkHard1231 天前
如何利用redis使用一个滑动窗口限流
数据库·redis·缓存