【Mac开发环境搭建】Docker安装Redis、Nacos
Dokcer安装Redis
拉取镜像
docker pull redis
创建配置文件
# 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
创建容器
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
连接测试
Redis连接工具[Quick Redis]
下载链接:https://www.quick123.net/
设置Redis自启动
如果想要启动Docker就自动启动Redis容器,可以在命令中运行如下命令
docker update redis --restart=always
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
启动成功之后,可以通过http://localhost:8848/nacos/index.html来访问控制台