compose部署redis和mysql_Docker-compose常用软件部署(mysql、redis、rabbitmq)

Docker-compose常用软件部署(mysql、redis、rabbitmq)

废话不多说,下面就直接给出部署文件已经启动脚本,这个会持续更新。以下的部署方式均是单例部署。高可用或者其他部署方案我会单独写相应的文章。

mysql数据库

redis缓存

rabbitmq消息队列

compose-mysql.yaml

version: '3'

# docker network create mysql_bridge

networks:

mysql_bridge:

driver: bridge

services:

mysql-server:

image: docker.io/mysql:5.7

container_name: mysql-server

restart: always

environment:

# 指定root密码。不指定则会启动失败

- MYSQL_ROOT_PASSWORD:123456

volumes:

# 同步本地时间

- /etc/localtime:/etc/localtime:ro

# 初始化执行的sql

# - ./init:/docker-entrypoint-initdb.d/

# db配置

- ./conf/my.cnf:/etc/my.cnf

# db文件存放地址

- ./db_data:/var/lib/mysql

ports:

- 3306:3306

networks:

- mysql_bridge

start-mysql.sh

#! /usr/bin/bash

# 定义一个名称变量

network_name="mysql_bridge"

filterName=`docker network ls | grep $network_name | awk '{ print $2 }'`

if [ "$filterName" == "" ]; then

# 不存在就创建

docker network create $network_name

echo "Created network $network_name success!!"

fi

docker-compose -f ./compose-mysql.yaml up -d

docker ps -a

docker logs -f mysql-server

compose-redis.yaml

version: '3'

# docker network create redis_bridge

networks:

redis_bridge:

driver: bridge

services:

redis-server:

image: docker.io/redis:latest

container_name: redis-server

restart: always

command: redis-server --requirepass "123456"

volumes:

- /etc/localtime:/etc/localtime:ro

- ./redis_data:/var/lib/redis

ports:

- 6379:6379

networks:

- redis_bridge

start-redis.sh

#! /usr/bin/bash

# 定义一个名称变量

network_name="redis_bridge"

filterName=`docker network ls | grep $network_name | awk '{ print $2 }'`

if [ "$filterName" == "" ]; then

# 不存在就创建

docker network create $network_name

echo "Created network $network_name success!!"

fi

docker-compose -f ./compose-redis.yaml up -d

docker ps -a

docker logs -f redis-server

compose-rabbitmq.yaml

version: '3'

# docker network create rabbitmq_bridge

networks:

rabbitmq_bridge:

driver: bridge

services:

rabbitmq:

image: rabbitmq:management-alpine

container_name: rabbitmq-server

restart: always

volumes:

- /etc/localtime:/etc/localtime:ro

- ./data:/var/lib/rabbitmq

environment:

- RABBITMQ_DEFAULT_USER=ming

- RABBITMQ_DEFAULT_PASS=ming123456

ports:

- "15672:15672"

- "5672:5672"

logging:

driver: "json-file"

options:

max-size: "200k"

max-file: "10"

networks:

- rabbitmq_bridge

start-rabbitmq.sh

#! /usr/bin/bash

# 定义一个名称变量

network_name="rabbitmq_bridge"

filterName=`docker network ls | grep $network_name | awk '{ print $2 }'`

if [ "$filterName" == "" ]; then

# 不存在就创建

docker network create $network_name

echo "Created network $network_name success!!"

fi

docker-compose -f ./compose-rabbitmq.yaml up -d

docker ps -a

docker logs -f rabbitmq-server

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值