t05_docker相关部署合集

部署Redis

linux文件目录

image-20230721214632345

启动redis容器

docker run --restart=always --log-opt max-size=100m --log-opt max-file=2 -p 39107:6379 --name myredis39107 -v /home/docker-config/redis/myredis/redis.conf:/etc/redis/redis.conf -v /home/docker-config/redis/myredis/data:/data -d redis redis-server /etc/redis/redis.conf  --appendonly yes  --requirepass mima

注意mima,就是我们输入的密码

我们也可以通过进入redis更改密码

root@cab388a395ff:/data# redis-cli 
127.0.0.1:6379> auth 000415
OK
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "000415"
127.0.0.1:6379> config set requirepass root2580
OK
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "root2580"
127.0.0.1:6379> 

# 启动
systemctl start redis
# 停止
systemctl stop redis
# 重启
systemctl restart redis
# 查看状态
systemctl status redis

在linux主机上链接redis

root@iZp5qw8rqo26yzZ /h/d/r/myredis# docker exec -it cab388a395ff redis-cli -a mima
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> 

远程服务上执行命令

redis-cli -h IP地址 -p 端口 -a 密码

redis.conf配置文件

# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#bind 127.0.0.1

protected-mode no
port 6379
tcp-backlog 511
requirepass 000415
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile ""
databases 30
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-disable-tcp-nodelay no
replica-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
appendonly yes
appendfilename "appendonly.aof"
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-max-len 128
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
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
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes

部署Mysql

1、下载mysql

:后边是版本号,可以选择其他版本

docker pull mysql:8.0.21

2、运行

docker run -d \
  --name mysql-container \
  -e MYSQL_ROOT_PASSWORD=root \
  -p 39105:3306 \
  mysql:8.0.21
docker run -p 39106:3306 --name mysql-master \
-v /mydata/mysql-master/log:/var/log/mysql \
-v /mydata/mysql-master/data:/var/lib/mysql \
-v /mydata/mysql-master/conf:/etc/mysql/conf.d \
-e MYSQL_ROOT_PASSWORD=r  \
-d mysql:8.0 
posted @   六个小豹  阅读(5)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
点击右上角即可分享
微信分享提示