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

文章目录

Dokcer安装Redis

拉取镜像

Bash 复制代码
docker pull redis

创建配置文件

XML 复制代码
# 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

创建容器

Bash 复制代码
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容器,可以在命令中运行如下命令

Bash 复制代码
 docker update redis --restart=always

Docker安装Nacos

Bash 复制代码
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来访问控制台

相关推荐
Mintimate11 小时前
WorkBuddy 上手: 让脚本项目 Homebrew CN 变成会排障的 Agent
macos·边缘计算·agent
lichenyang4532 天前
Docker 学习笔记(五):Docker Compose,用一个 YAML 启动前端、后端和 MongoDB
docker
lichenyang4532 天前
Docker 学习笔记(四):Dockerfile,把项目打成自己的镜像
docker·容器
lichenyang4532 天前
Docker 学习笔记(三):Docker 网络、bridge、子网和容器互通
docker·容器
lichenyang4532 天前
Docker 学习笔记(二):docker run 的参数到底在控制什么?
docker·容器
fthux2 天前
如果你用 Mac,那你可能需要 Noti Shift
macos·开源·github
用户3074596982072 天前
Redis 延时队列详解
redis
烤代码的吐司君2 天前
Redis 数据结构 ZSet, BIT, HyperLogLog,Geo 空间数据
redis·后端
counterxing4 天前
最近发现一个 Mac 工具,有点像把 Raycast、语音输入法、截图和录屏塞到了一起
macos·ai编程·claude
leeyi5 天前
Checkpoint 机制:Agent 怎么在断电后接着跑
redis·aigc·agent