dockercompose汇总
在工作中用到各种中间件,以下配置均为单提,没有采用集群,集群的配置后续加上
version: '3'
services:
gogs:
image: gogs/gogs # 指定使用gogs/gogs官方镜像
container_name: gogs
environment:
- TZ=Asia/Shanghai # 设置时区环境变量
#restart: always # 确保容器在停止后自动重启
privileged: true # Docker 容器默认以非特权用户的身份运行,这是出于安全考虑。特权模式允许容器拥有与主机相同的权限
volumes:
- ./data/gogs:/data # 映射本地的./data/gogs目录到容器的/data目录,用于存储Gogs数据
ports:
- "10022:22"
- "3001:3000" # 映射本地的端口3000到容器的SSH端口22和本地的端口3000到容器的HTTP端口3000
minio:
image: minio/minio
container_name: minio
volumes:
- ./data/minio:/data
ports:
- "9000:9000"
- "9001:9001"
environment:
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: minio123
command: server /data --console-address ":9001" # command指令中添加--console-address参数,否则浏览器访问控制台自动跳转端口导致无法访问
#restart: always
nginx:
image: nginx:latest
#image: nginx:1.22.1
container_name: nginx
#restart: always
ports:
- "80:80"
- "443:443"
environment:
- NGINX_PORT=80
volumes:
- ./data/nginx/html:/usr/share/nginx/html # 将本地的html目录挂载到容器的Nginx根目录
- ./data/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./data/nginx/logs:/var/log/nginx
redis:
# 指定服务名称,命令:--name redis
# 如果不指定,则将默认用docker-compose.yml所在文件夹名_服务名称_n命名
container_name: redis
#docker启动,容器启动
#restart: always
# 指定镜像:命令 redis:latest
image: redis:7.2.4
# 指定端口:命令 -p 主机端口:容器端口
ports:
- "16379:16379"
volumes:
- ./data/redis/conf/redis.conf:/etc/redis/redis.conf
- ./data/redis/data:/data
# 运行命令
command: redis-server /etc/redis/redis.conf
rabbitmq:
# 镜像 如果想访问图形管理 docker exec -it 9c217810b91c rabbitmq-plugins enable rabbitmq_management
# image: rabbitmq:3.13
# 带图形管理的镜像
image: rabbitmq:3.13-management
# 容器名称
container_name: rabbitmq
# 主机名称
#hostname: node_one
# 端口
ports:
# (epmd)epmd代表 Erlang端口映射守护进程,erlang发现口
#- "4369:4369"
# 下面两个AMQP 0-9-1 without and with TLSclient端通信口
#- "5671:5671"
- "5672:5672"
# 管理监听端口
#- "15671:15671"
# 管理界面ui使用的端口
- "15672:15672"
# ( Erlang distribution) server间内部通信口
#- "25672:25672"
#docker启动,容器启动
#restart: always
volumes:
#数据文件目录
- ./data/rabbitmq/lib:/var/lib/rabbitmq
# 配置文件目录
#- ./data/rabbitmq/etc:/etc/rabbitmq
# 日志文件目录
- ./data/rabbitmq/log:/var/log/rabbitmq
#environment:
# 默认虚拟机名
#- RABBITMQ_DEFAULT_VHOST=rabbitmq-one
# 用户名
#- RABBITMQ_DEFAULT_USER=root
# 密码
#- RABBITMQ_DEFAULT_PASS=root
# 设置时区
#- Asia/Shanghai
mongodb:
container_name: mongodb
image: mongo:latest
#restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
ports:
- "27017:27017"
volumes:
- ./data/mongo/db:/data/db
nacos:
# 容器名称
container_name: nacos
image: nacos/nacos-server:v2.1.1
#hostname: nacos
#restart: always
environment:
- MODE=standalone ##注意这里使用的是单机模式
- NACOS_AUTH_ENABLE=true
- NACOS_AUTH_IDENTITY_KEY=nacos
- NACOS_AUTH_IDENTITY_VALUE=nacos
- NACOS_AUTH_TOKEN=SecretKey012345678901234567890123456789012345678901234567890123456789
volumes:
- ./data/nacos/logs:/home/nacos/logs
- ./data/nacos/data:/home/nacos/data
ports:
- "8848:8848"
#- "9848:9848"
#- "9849:9849"
yapi:
image: jayfong/yapi:latest
container_name: yapi
#restart: always
ports:
- 3000:3000
environment:
# 随便设置一个账号(账号是邮箱的格式)
- YAPI_ADMIN_ACCOUNT=gufanbiao@163.com
# 设置账号的密码
- YAPI_ADMIN_PASSWORD=123456
# 禁用注册功能
- YAPI_CLOSE_REGISTER=true
# 设置连接 mongdb 的服务器地址,可以使用容器内部的 mongodb 服务名称
- YAPI_DB_SERVERNAME=mongodb
- YAPI_DB_PORT=27017
- YAPI_DB_DATABASE=yapidb
- YAPI_DB_USER=admin
- YAPI_DB_PASS=admin
- YAPI_DB_AUTH_SOURCE=admin
#- YAPI_DB_CONNECT_STRING="mongodb://jobs:123456@mongodb:27017/yapidb?authSource=admin"
# 禁用发送邮件的功能
- YAPI_MAIL_ENABLE=false
# 禁用 LDAP 登录功能
- YAPI_LDAP_LOGIN_ENABLE=false
# 不使用任何插件
- YAPI_PLUGINS=[]
#networks:
#- yapi_net
volumes:
#- ./data/yapi/config.json:/yapi/config.json # 宿主机配置文件路径:/容器内部配置文件路径
#- ./data/yapi/config:/yapi/config # 挂载配置文件目录
- ./data/yapi/log:/yapi/log # 挂载日志文件目录
#- ./data/yapi/init:/yapi/init # 挂载初始化脚本目录
#- ./data/mongo/db:/data/db # 挂载MongoDB数据目录
depends_on:
- mongodb
jenkins:
image: jenkins/jenkins
container_name: jenkins
ports:
- 8080:8080
- 50000:50000
volumes:
- ./data/jenkins/jenkins_home:/var/jenkins_home/
- ./data/jenkins/jenkins_logs:/var/log/jenkins # 挂载日志目录
environment:
JAVA_OPTS: '-Djava.util.logging.config.file=/var/jenkins_home/log.properties'
mysql8:
container_name: mysql8
image: mysql:8.0.31
#docker启动,容器启动
#restart: always
ports:
- "13306:3306"
# 防止被OOM kill, -1000为最低优先级
#oom_score_adj: -1000
environment:
# 等同于 -e MYSQL_ROOT_PASSWORD指定root的登录密码
MYSQL_ROOT_PASSWORD: 'root'
MYSQL_ALLOW_EMPTY_PASSWORD: 'no'
# 这里这个指令compose启动成功后会自动创建名为docker的数据库
MYSQL_DATABASE: 'totograin'
# 此处就是相当于 mysql create user,创建了数据库的登录用户
#MYSQL_USER: 'gufanbiao'
#MYSQL_PASSWORD: 'gufanbiao'
volumes:
- ./data/mysql8/data:/var/lib/mysql
# 这里的my.cnf配置下面有简单实例
- ./data/mysql8/conf.d:/etc/mysql/conf.d # 映射配置目录,宿主机:容器
- ./data/mysql8/log:/var/log/mysql
- ./data/mysql8/mysql-files:/var/lib/mysql-files
#- /etc/localtime:/etc/localtime:ro # 让容器的时钟与宿主机时钟同步,避免时间的问题,ro是read only的意思,就是只读。
#command:
# 使用指定的配置文件启动
#- --defaults-file=/etc/mysql/my.cnf
mysql5:
# 使用 MySQL 5.7.44 镜像
image: mysql:5.7.44
# 容器名称为 mysql5
container_name: mysql5
ports:
- "23306:3306"
# 容器退出时自动重启
#restart: always
# 防止被OOM kill, -1000为最低优先级
#oom_score_adj: -1000
environment:
# 等同于 -e MYSQL_ROOT_PASSWORD指定root的登录密码
MYSQL_ROOT_PASSWORD: 'root'
MYSQL_ALLOW_EMPTY_PASSWORD: 'no'
# 这里这个指令compose启动成功后会自动创建名为docker的数据库
MYSQL_DATABASE: 'totograin'
# 此处就是相当于 mysql create user,创建了数据库的登录用户
#MYSQL_USER: 'gufanbiao'
#MYSQL_PASSWORD: 'gufanbiao'
volumes:
# 挂载数据目录
- ./data/mysql5/data:/var/lib/mysql
# 这里的my.cnf配置下面有简单实例
- ./data/mysql5/conf.d:/etc/mysql/conf.d # 映射配置目录,宿主机:容器
- ./data/mysql5/log:/var/log/mysql
- ./data/mysql5/mysql-files:/var/lib/mysql-files
#- /etc/localtime:/etc/localtime:ro # 让容器的时钟与宿主机时钟同步,避免时间的问题,ro是read only的意思,就是只读。
postgres:
image: postgres:14
#restart: always
container_name: postgres
ports:
- 5432:5432
environment:
POSTGRES_DB: grain
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- ./data/postgres/data:/var/lib/postgresql/data/pgdata
#- ./data/postgres/logs:/var/log/postgresql
#- /etc/localtime:/etc/localtime
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.12.2
container_name: elasticsearch
#restart: always
volumes:
- ./data/es/data:/usr/share/elasticsearch/data
- ./data/es/logs:/usr/share/elasticsearch/logs
# 挂载分词器的目录
- ./data/es/plugins:/usr/share/elasticsearch/plugins
#- ./data/es/config/jvm.options:/usr/share/elasticsearch/config/jvm.options
- ./data/es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
ports:
- "9200:9200"
environment:
- discovery.type=single-node
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms1024m -Xmx2048m"
- TZ=Asia/Shanghai
- ELASTIC_PASSWORD=elastic # elastic账号密码
kibana:
image: docker.elastic.co/kibana/kibana:8.12.2
container_name: kibana
#restart: always
ports:
- "5601:5601"
#environment:在配置文件中设置
# - ELASTICSEARCH_HOSTS=http://elasticsearch:9200
# - ELASTICSEARCH_USERNAME=kibana
# - ELASTICSEARCH_PASSWORD=your_password
volumes:
- ./data/kibana/kibana.yml:/usr/share/kibana/config/kibana.yml
- ./data/kibana/data:/usr/share/kibana/data
depends_on:
- elasticsearch
tomcat8:
image: tomcat:8.5.40
#image: tomcat:latest
container_name: tomcat8
#restart: always
ports:
- "8081:8080" #8080和其他服务冲突使用8081
volumes:
- ./data/tomcat/logs:/usr/local/tomcat/logs
- ./data/tomcat/webapps:/usr/local/tomcat/webapps
#- ./data/tomcat/conf:/usr/local/tomcat/conf
environment:
TZ: Asia/Shanghai
#skyworking不是一个可以通过 docker-compose 直接安装的组件,包括 OAP 服务器、UI 和可能的存储后端(elasticsearch)
skyworking-oap:
image: apache/skywalking-oap-server:9.0.0
container_name: skywalking-oap
depends_on:
- elasticsearch
links:
- elasticsearch
#restart: always
ports:
- 11800:11800
- 12800:12800
environment:
SW_STORAGE: elasticsearch
SW_STORAGE_ES_CLUSTER_NODES: elasticsearch:9200
SW_HEALTH_CHECKER: default
SW_TELEMETRY: prometheus
SW_ES_USER: elastic
SW_ES_PASSWORD: elastic
healthcheck:
test: ["CMD", "./bin/swctl", "ch"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
skyworking-ui:
image: apache/skywalking-ui:9.0.0
container_name: skywalking-ui
depends_on:
- skyworking-oap
links:
- skyworking-oap
#restart: always
ports:
- 8083:8080
environment:
SW_OAP_ADDRESS: skyworking-oap:12800
#rocketmq
rmqnamesrv:
image: foxiswho/rocketmq:server
container_name: rocketmq-namesrv
ports:
- 9876:9876
volumes:
- ./data/rocketmq/srv_logs:/opt/logs
- ./data/rocketmq/srv_store:/opt/store
rmqbroker:
image: foxiswho/rocketmq:broker
container_name: rocketmq-broker
ports:
- 10909:10909
- 10911:10911
volumes:
- ./data/rocketmq/broker_logs:/opt/logs
- ./data/rocketmq/broker_store:/opt/store
- ./data/rocketmq/broker_conf/broker.conf:/etc/rocketmq/broker.conf
environment:
NAMESRV_ADDR: "rmqnamesrv:9876"
JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m"
command: mqbroker -c /etc/rocketmq/broker.conf
depends_on:
- rmqnamesrv
rmqconsole:
image: apacherocketmq/rocketmq-dashboard:latest
container_name: rocketmq-console
ports:
- 8082:8080
environment:
JAVA_OPTS: "-Drocketmq.namesrv.addr=rmqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"
depends_on:
- rmqnamesrv
- rmqbroker
#kafka
zookeeper: #服务名,可自定义
image: wurstmeister/zookeeper # 指定使用的镜像名及标签
container_name: zookeeper # 指定实例化后的容器名
#restart: always # 设置无论遇到什么错,重启容器
#privileged: true #让docker 应用容器 获取宿主机root权限
ports: # 容器内的映射端口,本地端口:容器内端口
- 2181:2181 # zookeeper对外的端口
volumes: # 设置数据卷挂载路径,本地目录:容器内目录,挂载本地文件到容器里面目录,实现数据持久化到宿主机
- ./data/zk/data:/data #本地目录使用相对路径
- ./data/zk/datalog:/datalog
- ./data/zk/conf:/conf
# - /etc/timezone:/etc/timezone # 指定时区
# - /etc/localtime:/etc/localtime
environment: # 定义环境变量
ZOO_MY_ID: 1 # zk服务器唯一Id,不能和其它服务器myid一样
ZOO_SERVERS: server.1=zookeeper:2181 # zk集群的服务器
kafka:
image: wurstmeister/kafka
container_name: kafka
#restart: always
privileged: true
ports:
- 9092:9092
environment:
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- ./data/kafka/data:/kafka
#- /var/run/docker.sock:/var/run/docker.sock
kafka-manager:
image: sheepkiller/kafka-manager:latest
#restart: always
container_name: kafa-manager
hostname: kafka-manager
#privileged: true
ports:
- "9002:9000"
environment:
#ZK_HOSTS: 192.168.1.102:2181,192.168.1.102:2182,192.168.1.102:2183
ZK_HOSTS: zookeeper:2181
#KAFKA_BROKERS: 192.168.1.102:9092,192.168.1.102:9093,192.168.1.102:9094 # 修改宿主机IP
KAFKA_BROKERS: kafka:9092
APPLICATION_SECRET: "random-secret"
KAFKA_MANAGER_AUTH_ENABLED: "true"
KAFKA_MANAGER_USERNAME: admin # web端账号
KAFKA_MANAGER_PASSWORD: password # web端密码
额外配置图

配置详情
es配置
es之elasticsearch.yml配置
http.port: 9200
http.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
# 开启安全控制
xpack.security.enabled: true
#xpack.security.transport.ssl.enabled: true
#xpack.security.transport.ssl.keystore.type: PKCS12
#xpack.security.transport.ssl.verification_mode: certificate
#xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
#xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
#xpack.security.transport.ssl.truststore.type: PKCS12
#xpack.security.audit.enabled: true
path.logs: /usr/share/elasticsearch/logs
es8版本的密码和之前的版本有些许区别,需要单独设置
es之jvm.options配置
## JVM configuration
################################################################
## IMPORTANT: JVM heap size
################################################################
##
## You should always set the min and max JVM heap
## size to the same value. For example, to set
## the heap to 4 GB, set:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms1g
-Xmx1g
-XX:+IgnoreUnrecognizedVMOptions
################################################################
## Expert settings
################################################################
##
## All settings below this section are considered
## expert settings. Don't tamper with them unless
## you understand what you are doing
##
################################################################
## GC configuration
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
## G1GC Configuration
# NOTE: G1GC is only supported on JDK version 10 or later.
# To use G1GC uncomment the lines below.
# -XX:-UseConcMarkSweepGC
# -XX:-UseCMSInitiatingOccupancyOnly
# -XX:+UseG1GC
# -XX:InitiatingHeapOccupancyPercent=75
## optimizations
# pre-touch memory pages used by the JVM during initialization
-XX:+AlwaysPreTouch
## basic
# explicitly set the stack size
-Xss1m
# set to headless, just in case
-Djava.awt.headless=true
# ensure UTF-8 encoding by default (e.g. filenames)
-Dfile.encoding=GBK
# use our provided JNA always versus the system one
-Djna.nosys=true
# turn off a JDK optimization that throws away stack traces for common
# exceptions because stack traces are important for debugging
-XX:-OmitStackTraceInFastThrow
# flags to configure Netty
-Dio.netty.noUnsafe=true
-Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0
# log4j 2
-Dlog4j.shutdownHookEnabled=false
-Dlog4j2.disable.jmx=true
-Djava.io.tmpdir=${
ES_TMPDIR}
## heap dumps
# generate a heap dump when an allocation from the Java heap fails
# heap dumps are created in the working directory of the JVM
-XX:+HeapDumpOnOutOfMemoryError
# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=data
# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=logs/hs_err_pid%p.log
## JDK 8 GC logging
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintTenuringDistribution
-XX:+PrintGCApplicationStoppedTime
-Xloggc:logs/gc.log
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=32
-XX:GCLogFileSize=64m
# JDK 9+ GC logging
:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
# due to internationalization enhancements in JDK 9 Elasticsearch need to set the provider to COMPAT otherwise
# time/date parsing will break in an incompatible way for some date patterns and locals
-Djava.locale.providers=COMPAT
# temporary workaround for C2 bug with JDK 10 on hardware with AVX-512
-XX:UseAVX=2
kibana配置
kibana之kibana.yml配置
server.name: kibana
# kibana的主机地址 0.0.0.0可表示监听所有IP
server.host: "0.0.0.0"
#
# 这边设置自己es的地址,
#elasticsearch.hosts: [ "http://127.0.0.1:9200/" ]
elasticsearch.hosts: [ "http://elasticsearch:9200/" ]
elasticsearch.username: 'elastic'
elasticsearch.password: 'elastic'
# # 显示登陆页面
xpack.monitoring.ui.container.elasticsearch.enabled: true
# 开启中文模式
i18n.locale: "zh-CN"
mysql5配置
mysql5之my.cnf配置
[mysql]
# 默认字符集
default-character-set=utf8mb4
[client]
# 客户端使用的端口号
port=3306
socket=/var/run/mysqld/mysqld.sock
default-character-set=utf8mb4
[mysqld]
# 限制 MySQL 服务器只能从 /var/lib/mysql-files 目录读取文件或将文件写入该目录
secure-file-priv=/var/lib/mysql-files
# docker mysql 默认配置
datadir=/var/lib/mysql
# 开启二进制日志功能
log-bin=/var/lib/mysql/mysql-bin
# InnoDB 数据文件存放目录
innodb_data_home_dir=/var/lib/mysql
# InnoDB 日志文件存放目录
innodb_log_group_home_dir=/var/lib/mysql
# MySQL 错误日志文件路径
log-error=/var/lib/mysql/mysql.log
# 存放 MySQL 进程 ID 的文件路径
pid-file=/var/lib/mysql/mysql.pid
socket=/var/run/mysqld/mysqld.sock
user=mysql
# 用于控制是否允许 MySQL 服务器使用符号链接
symbolic-links=0
# 使用主机名进行缓存查找,以提高连接性能
skip-host-cache
# 进行权限验证时,会尝试将客户端的主机名解析为 IP 地址
skip-name-resolve
#数据库服务器id,这个id用来在主从服务器中标记唯一mysql服务器
server-id=1
#系统数据库编码设置,排序规则
character_set_server=utf8mb4
collation_server=utf8mb4_bin
# 日志时间系统时间
log_timestamps=SYSTEM
# 默认时区东八区
default-time_zone='+8:00'
# 表名大小写不敏感
lower_case_table_names=1
# 自动提交所有事务
autocommit=1
# 跳过排它锁定
skip-external-locking
# 启用显式默认时间戳
explicit_defaults_for_timestamp=ON
#默认sql模式,严格模式
#sql_mode = ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,
#NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
#ONLY_FULL_GROUP_BY
#NO_ZERO_IN_DATE 不允许年月为0
#NO_ZERO_DATE 不允许插入年月为0的日期
#ERROR_FOR_DIVISION_BY_ZERO 在INSERT或UPDATE过程中,如果数据被零除,则产生错误而非警告。如 果未给出该模式,那么数据被零除时MySQL返回NULL
#NO_ENGINE_SUBSTITUTION 不使用默认的存储引擎替代
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
#是MySQL执行排序使用的缓冲大小。如果想要增加ORDER BY的速度,首先看是否可以让MySQL使用索引而不是额外的排序阶段
#如果不能,可以尝试增加sort_buffer_size变量的大小
sort_buffer_size=16M
#应用程序经常会出现一些两表(或多表)Join的操作需求,MySQL在完成某些 Join 需求的时候(all/index join),
#为了减少参与Join的“被驱动表”的读取次数以提高性能,需要使用到 Join Buffer 来协助完成 Join操作。
#当 Join Buffer 太小,MySQL 不会将该 Buffer 存入磁盘文件,而是先将Join Buffer中的结果集与需要 Join 的表进行 Join 操作
#然后清空 Join Buffer 中的数据,继续将剩余的结果集写入此 Buffer 中,
#如此往复。这势必会造成被驱动表需要被多次读取,成倍增加 IO 访问,降低效率。
#若果多表连接需求大,则这个值要设置大一点。
join_buffer_size=16M
#索引块的缓冲区大默认16M
key_buffer_size=64M
# 消息缓冲区会用到该列,该值太小则会在处理大包时产生错误。如果使用大的text,BLOB列,必须增加该值
max_allowed_packet=16M
# 最大连接数
max_connections=3000
# 连接错误最大数量
max_connect_errors=100
#表描述符缓存大小,可减少文件打开/关闭次数,一般max_connections*2。
table_open_cache=6000
#MySQL 缓存 table 句柄的分区的个数,每个cache_instance<=table_open_cache/table_open_cache_instances
table_open_cache_instances=32
#mysql打开最大文件数
open_files_limit=65535
#慢查询,开发调式阶段才需要开启慢日志功能。上线后关闭
slow_query_log=OFF
# 创建表时使用的默认存储引擎
default_storage_engine=InnoDB
# InnoDB 数据文件路径设置
innodb_data_file_path=ibdata1:10M:autoextend
# InnoDB 缓冲池大小
innodb_buffer_pool_size=2G
# InnoDB 日志文件大小
innodb_log_file_size=512M
# InnoDB 日志缓冲区大小
innodb_log_buffer_size=16M
# InnoDB 每次提交时刷新日志
innodb_flush_log_at_trx_commit=1
# InnoDB 加锁等待超时时间(秒)
innodb_lock_wait_timeout=60
# 网络缓冲区长度
net_buffer_length=32K
# 读取缓冲区大小
read_buffer_size=16M
# 随机读取缓冲区大小
read_rnd_buffer_size=1024K
# MyISAM 排序缓冲区大小
myisam_sort_buffer_size=265M
# 线程缓存大小
thread_cache_size=512
# 临时表大小
tmp_table_size=512M
[mysqldump]
# 快速导出数据
quick
# 允许的最大数据包大小
max_allowed_packet=16M
[myisamchk]
# 键缓存大小
key_buffer_size=512M
# 排序缓冲区大小
sort_buffer_size=16M
# 读取缓冲区大小
read_buffer=16M
# 写入缓冲区大小
write_buffer=16M
[mysqlhotcopy]
# 交互式超时时间
interactive-timeout
mysql8配置
mysql8之my.cnf配置
###### [client]配置模块 ######
[client]
default-character-set=utf8mb4
socket=/var/lib/mysql/mysql.sock
###### [mysql]配置模块 ######
[mysql]
# 设置MySQL客户端默认字符集
default-character-set=utf8mb4
socket=/var/lib/mysql/mysql.sock
###### [mysqld]配置模块 ######
[mysqld]
port=3306
user=mysql
# 设置sql模式 sql_mode模式引起的分组查询出现*this is incompatible with sql_mode=only_full_group_by,这里最好剔除ONLY_FULL_GROUP_BY
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
server-id = 1
# MySQL8 的密码认证插件 如果不设置低版本navicat无法连接
default_authentication_plugin=mysql_native_password
# 禁用符号链接以防止各种安全风险
symbolic-links=0
# 允许最大连接数
max_connections=1000
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 表名存储在磁盘是小写的,但是比较的时候是不区分大小写
lower_case_table_names=0
max_allowed_packet=16M
# 设置时区
default-time_zone='+8:00'
nginx配置
nginx之nginx.conf配置
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
client_max_body_size 100m;
root /usr/share/nginx/html/totodoc;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
Redis配置
Redis之redis.conf配置
# Redis configuration file example.
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first argument:
#
# ./redis-server /path/to/redis.conf
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
# units are case insensitive so 1GB 1Gb 1gB are all the same.
################################## INCLUDES ###################################
# Include one or more other config files here. This is useful if you
# have a standard template that goes to all Redis servers but also need
# to customize a few per-server settings. Include files can include
# other files, so use this wisely.
#
# Note that option "include" won't be rewritten by command "CONFIG REWRITE"
# from admin or Redis Sentinel. Since Redis always uses the last processed
# line as value of a configuration directive, you'd better put includes
# at the beginning of this file to avoid overwriting config change at runtime.
#
# If instead you are interested in using includes to override configuration
# options, it is better to use include as the last line.
#
# Included paths may contain wildcards. All files matching the wildcards will
# be included in alphabetical order.
# Note that if an include path contains a wildcards but no files match it when
# the server is started, the include statement will be ignored and no error will
# be emitted. It is safe, therefore, to include wildcard files from empty
# directories.
#
# include /path/to/local.conf
# include /path/to/other.conf
# include /path/to/fragments/*.conf
#
################################## MODULES #####################################
# Load modules at startup. If the server is not able to load modules
# it will abort. It is possible to use multiple loadmodule directives.
#
# loadmodule /path/to/my_module.so
# loadmodule /path/to/other_module.so
################################## NETWORK #####################################
# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all available network interfaces on the host machine.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
# Each address can be prefixed by "-", which means that redis will not fail to
# start if the address is not available. Being not available only refers to
# addresses that does not correspond to any network interface. Addresses that
# are already in use will always fail, and unsupported protocols will always BE
# silently skipped.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1 # listens on two specific IPv4 addresses
# bind 127.0.0.1 ::1 # listens on loopback IPv4 and IPv6
# bind * -::* # like the default, all available interfaces
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only on the
# IPv4 and IPv6 (if available) loopback interface addresses (this means Redis
# will only be able to accept client connections from the same host that it is
# running on).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# COMMENT OUT THE FOLLOWING LINE.
#
# You will also need to set a password unless you explicitly disable protected
# mode.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 0.0.0.0
# By default, outgoing connections (from replica to master, from Sentinel to
# instances, cluster bus, etc.) are not bound to a specific local address. In
# most cases, this means the operating system will handle that based on routing
# and the interface through which the connection goes out.
#
# Using bind-source-addr it is possible to configure a specific address to bind
# to, which may also affect how the connection gets routed.
#
# Example:
#
# bind-source-addr 10.0.0.1
# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and the default user has no password, the server
# only accepts local connections from the IPv4 address (127.0.0.1), IPv6 address
# (::1) or Unix domain sockets.
#
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured.
protected-mode no
# Redis uses default hardened security configuration directives to reduce the
# attack surface on innocent users. Therefore, several sensitive configuration
# directives are immutable, and some potentially-dangerous commands are blocked.
#
# Configuration directives that control files that Redis writes to (e.g., 'dir'
# and 'dbfilename') and that aren't usually modified during runtime

2454

被折叠的 条评论
为什么被折叠?



