前言
- 记录一下工作常用的服务搭建配置,自测通过,持续更新中,欢迎收藏;
Redis
version: '3'
services:
redis:
# 镜像名 如果需要指定版本 就把 : 后面换成版本号
image: redis:6.2.6
# 容器名
container_name: redis
# 重启策略
restart: always
# 端口映射
ports:
- 6379:6379
volumes:
# 配置文件映射
- ./redis.conf:/usr/local/etc/redis/redis.conf
- ./data:/data
- /etc/localtime:/etc/localtime:ro
# 额外配置 密码之类
command: ["redis-server", "--appendonly", "yes"]
MySQL
version: '3'
services:
master:
image: mysql:8.0.22
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=replicas_db
- TZ=Asia/Shanghai
command: --default-authentication-plugin=mysql_native_password
ports:
- "3306:3306"
restart: always
hostname: redblue-mysql
privileged: true
volumes:
- ./master_data:/var/lib/mysql
- ./master/my.cnf:/etc/mysql/my.cnf
- ./master_files:/var/lib/mysql-files
volumes:
master_data:
master_files:
my.cnf
[mysqld]
## 设置server_id,一般设置为IP,注意要唯一
server_id=100
## 复制过滤:也就是指定哪个数据库不用同步(mysql库一般不同步)
binlog-ignore-db=mysql
## 开启二进制日志功能,可以随便取,最好有含义(关键就是这里了)
log-bin=replicas-mysql-bin
## 为每个session分配的内存,在事务过程中用来存储二进制日志的缓存
binlog_cache_size=1M
## 主从复制的格式(mixed,statement,row,默认格式是statement)
binlog_format=mixed
## 二进制日志自动删除/过期的秒数。默认值为0,表示不自动删除。
binlog_expire_logs_seconds=604800
## 跳过主从复制中遇到的所有错误或指定类型的错误,避免slave端复制中断。
## 如:1062错误是指一些主键重复,1032错误是因为主从数据库数据不一致
slave_skip_errors=1062
## 禁用dns解析
skip-name-resolve
## 表名小写,不区分大小写
lower_case_table_names=1
## 数据库默认字符集,主流字符集支持一些特殊表情符号(特殊表情符占用4个字节)
character-set-server=utf8mb4
## 数据库字符集对应一些排序等规则,注意要和character-set-server对应
collation-server=utf8mb4_general_ci
## 设置client连接mysql时的字符集,防止乱码
init_connect='SET NAMES utf8mb4'
## TIMESTAMP如果没有显示声明NOT NULL,允许NULL值
explicit_defaults_for_timestamp=true
## 设置mysql 8.0 的加密方式为 mysql_native_password (默认为:caching_sha2_password)
default_authentication_plugin=mysql_native_password
RabbitMQ
version: '3'
services:
rabbitmq:
image: rabbitmq:management
container_name: rabbitmq
restart: always
hostname: my-rabbitmq
ports:
- 15672:15672
- 5672:5672
volumes:
- ./data:/var/lib/rabbitmq
environment:
- RABBITMQ_DEFAULT_USER=rabbitmq
- RABBITMQ_DEFAULT_PASS=rabbitmq
ES + kibana + cerebro
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.8.1
container_name: elasticsearch
environment:
- discovery.type=single-node
- http.port=9200
- http.cors.enabled=true
# - http.cors.allow-origin=http://192.168.93.139:1358
- http.cors.allow-origin=*
# - http.cors.allow-origin=http://localhost:1358,http://127.0.0.1:1358
- http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
- http.cors.allow-credentials=false
- bootstrap.memory_lock=true
- 'ES_JAVA_OPTS=-Xms512m -Xmx512m'
volumes:
- ./data:/usr/share/elasticsearch/data
- ./ik-7.8.1:/usr/share/elasticsearch/plugins/ik-7.8.1
ports:
- 9200:9200
- 9300:9300
restart: always
kibana:
image: docker.elastic.co/kibana/kibana-oss:7.8.1
container_name: kibana
ports:
- 5601:5601
depends_on:
- elasticsearch
mem_limit: 512m
restart: always
cerebro:
image: lmenezes/cerebro:0.8.4
container_name: cerebro
ports:
- "9000:9000"
command:
- -Dhosts.0.host=http://elasticsearch:9200
Nacos
version: '3'
services:
nacos:
image: nacos/nacos-server:2.0.3
container_name: nacos
environment:
- "PREFER_HOST_MODE=hostname"
- "MODE=standalone"
- "MYSQL_DATABASE_NUM=1"
- "SPRING_DATASOURCE_PLATFORM=mysql"
- "MYSQL_SERVICE_HOST=127.0.0.1"
- "MYSQL_SERVICE_DB_NAME=name"
- "MYSQL_SERVICE_PORT=3306"
- "MYSQL_SERVICE_USER=root"
- "MYSQL_SERVICE_PASSWORD=root"
volumes:
- ./standalone-logs/:/home/nacos/logs
- ./custom.properties:/home/nacos/init.d/custom.properties
ports:
- 8848:8848
restart: on-failure
Sentinel
version: '3'
services:
sentinel-dashboard:
image: bladex/sentinel-dashboard:1.7.1
container_name: sentinel-dashboard
restart: always
environment:
JAVA_OPTS: "-Dserver.port=8858 -Dcsp.sentinel.dashboard.server=localhost:8858 -Dproject.name=sentinel-dashboard"
ports: #避免出现端口映射错误,建议采用字符串格式 8080端口为Dockerfile中EXPOSE端口
- "8858:8858"
volumes:
- ./root/logs:/root/logs
本记录持续更新中
本文含有隐藏内容,请 开通VIP 后查看