• 【Mac开发环境搭建】Docker安装Redis、Nacos


    Dokcer安装Redis

    拉取镜像

    docker pull redis
    
    • 1

    创建配置文件

    在这里插入图片描述

    # bind 127.0.0.1 -::1
    bind 0.0.0.0 
    
    # 是否启用保护模式
    protected-mode no
    
    # redis端口
    port 6379
    
    # 密码设置(需要密码就取消下面的注释)
    # requirepass root12345678
    
    tcp-backlog 511
    
    # 用户多少秒没有操作就断开连接,设置为0为不断开
    timeout 0
    
    # 后端连接会经常断开,设置为60不断开
    tcp-keepalive 60
    
    # 是否以守护线程的方式运行
    daemonize no
    
    pidfile /var/run/redis_6379.pid
    
    loglevel notice
    
    logfile ""
    
    databases 16
    
    always-show-logo no
    
    set-proc-title yes
    
    proc-title-template "{title} {listen-addr} {server-mode}"
    
    # 将数据持久化到dump.rdb的频率
     save 3600 1
     save 300 100
     save 60 10000
    
    stop-writes-on-bgsave-error yes
    
    rdbcompression yes
    
    rdbchecksum yes
    
    dbfilename dump.rdb
    
    rdb-del-sync-files no
    
    dir ./
    
    replica-serve-stale-data yes
    
    replica-read-only yes
    
    repl-diskless-sync no
    
    repl-diskless-sync-delay 5
    
    repl-diskless-load disabled
    
    repl-disable-tcp-nodelay no
    
    replica-priority 100
    
    acllog-max-len 128
    
    lazyfree-lazy-eviction no
    lazyfree-lazy-expire no
    lazyfree-lazy-server-del no
    replica-lazy-flush no
    
    lazyfree-lazy-user-del no
    
    lazyfree-lazy-user-flush no
    
    oom-score-adj no
    
    oom-score-adj-values 0 200 800
    
    disable-thp yes
    
    # 是否需要持久化存储
    appendonly yes
    appendfilename "appendonly.aof"
    appendfsync everysec
    
    no-appendfsync-on-rewrite no
    
    auto-aof-rewrite-percentage 100
    auto-aof-rewrite-min-size 64mb
    
    aof-load-truncated yes
    
    aof-use-rdb-preamble yes
    
    lua-time-limit 5000
    
    
    slowlog-log-slower-than 10000
    
    slowlog-max-len 128
    
    latency-monitor-threshold 0
    
    notify-keyspace-events ""
    
    list-max-ziplist-size -2
    
    list-compress-depth 0
    
    set-max-intset-entries 512
    
    zset-max-ziplist-entries 128
    zset-max-ziplist-value 64
    
    hll-sparse-max-bytes 3000
    
    stream-node-max-bytes 4096
    stream-node-max-entries 100
    
    activerehashing yes
    
    client-output-buffer-limit normal 0 0 0
    client-output-buffer-limit replica 256mb 64mb 60
    client-output-buffer-limit pubsub 32mb 8mb 60
    
    hz 10
    
    dynamic-hz yes
    
    rdb-save-incremental-fsync yes
    
    jemalloc-bg-thread yes
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137

    创建容器

    docker run -p 6379:6379 --name redis \
    -v /Users/mac/Dev/DockerData/Redis/data:/data \
    -v /Users/mac/Dev/DockerData/Redis/conf/redis.conf:/etc/redis/redis.conf \
    -d redis redis-server /etc/redis/redis.conf
    
    • 1
    • 2
    • 3
    • 4

    连接测试

    在这里插入图片描述

    Redis连接工具[Quick Redis]

    下载链接:https://www.quick123.net/

    在这里插入图片描述

    在这里插入图片描述

    设置Redis自启动

    如果想要启动Docker就自动启动Redis容器,可以在命令中运行如下命令

     docker update redis --restart=always
    
    • 1

    在这里插入图片描述

    Docker安装Nacos

    docker run \
    -d -p 8848:8848 \
    -p 9848:9848 \
    --name nacos \
    -e MODE=standalone \
    -e TIME_ZONE='Asia/Shanghai' \
    nacos/nacos-server:v2.1.2
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    在这里插入图片描述

    启动成功之后,可以通过http://localhost:8848/nacos/index.html来访问控制台

    在这里插入图片描述

  • 相关阅读:
    尚硅谷-JVM-内存和垃圾回收篇(P1~P203)
    高層建築設計和建造:從避難層到設備間和防風防火防水的設計理念,酒店住宅辦公樓都有什麽房間(精簡)
    LeetCode第14题:最长公共前缀
    解码平台收集
    园子周边:Polo 衫效果图预览
    校园日 | 看高校数据安全建设典型案例
    oracle截取字符串前几位用substr函数如何操作?
    Java学习----习题总结
    【flutter / dart 版本】Websocket获取B站直播间弹幕教程——基于B站直播开发平台
    读高性能MySQL(第4版)笔记07_优化数据类型(下)
  • 原文地址:https://blog.csdn.net/laodanqiu/article/details/134451365