docker启动mariadb单机版

行云流水
2022-07-27 / 1 评论 / 210 阅读 / 正在检测是否收录...

前言

MariaDB则是MySQL的一个分支,作为mysql的替代品。

部署

基本环境配置

参考: docker和docker-compose一键安装脚本

配置文件

tree mariadb/

mariadb/
├── conf
│   └── my.cnf
└── docker-compose.yaml

[client]
default-character-set = utf8
port        = 3306
socket      = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0
[galera]
[mysqldump]
quick
quote-names
max_allowed_packet  = 16M
[mysql]
[isamchk]
key_buffer      = 16M
!include /etc/mysql/mariadb.cnf
!includedir /etc/mysql/conf.d/

#mysqld设置
[mysqld]
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
log-error   = /var/lib/mysql/mariadb.log
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
lc_messages_dir = /usr/share/mysql
character-set-server = utf8
lc_messages = en_US
skip-external-locking
max_connections     = 500
max_user_connections = 100
connect_timeout     = 5
max_connect_errors = 100
wait_timeout        = 600
max_allowed_packet  = 16M
thread_cache_size       = 128
sort_buffer_size    = 4M
bulk_insert_buffer_size = 16M
tmp_table_size      = 128M
max_heap_table_size = 32M
myisam_recover_options = BACKUP
key_buffer_size     = 128M
table_open_cache    = 400
myisam_sort_buffer_size = 512M
concurrent_insert   = 2
read_buffer_size    = 2M
read_rnd_buffer_size    = 1M
query_cache_limit       = 128K
query_cache_size        = 64M

#慢查询日志配置
slow-query-log =  on
long_query_time = 10
slow_query_log_file = /var/log/mysql/mariadb-slow.log

#引擎配置
default_storage_engine  = InnoDB
innodb_buffer_pool_size = 2048M
innodb_log_file_size    = 128M
innodb_log_buffer_size  = 16M
innodb_file_per_table   = 1
innodb_open_files   = 400
innodb_io_capacity  = 400
innodb_flush_method = O_DIRECT
innodb_data_home_dir = /var/lib/mysql
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /var/lib/mysql
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

#新增配置
net_buffer_length = 8K
explicit_defaults_for_timestamp = true
open_files_limit = 65535

#主主配置
log-bin=mysql-bin
max_binlog_size     = 100M
expire_logs_days    = 10
binlog_cache_size   = 1M
binlog_format       = mixed
read-only           = 0
relay_log           = mysql-relay-bin
log-slave-updates   = ON

##和m2区别
server-id           = 1
auto-increment-offset = 1
auto-increment-increment = 2

version: '3.5'
services:
  mariadb:
    container_name: mariadb
    image: mariadb:10.3.28
    ports:
      - "3306:3306"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./conf/my.cnf:/etc/mysql/my.cnf
      - /data/mysqldb:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: rooxxxx123
      TIME_ZONE: Asia/Shanghai
    restart: always
    networks:
      -  mariadb_net
networks:
 mariadb_net:

启动

docker-compose up -d

评论 (1)

取消
只有登录/注册用户才可评论
  1. 头像
    BUG
    · Windows 10 · Google Chrome
    沙发

    转发了

    回复