docker 方式部署 mysql8.0.22
docker方式部署主要场景:测试环境,用户内网环境,不方便联网下载rpm包的生产环境1. 下载镜像docker pull mysql:8.0.222. 创建数据文件夹mkdir -p /apps/mysql/data/apps/mysql/conf/apps/myql/files/apps/mysql/data 用于存放各种数据文件、日志文件等/apps/mysql/conf 映射配置文件/ap
·
docker方式部署主要场景:测试环境,用户内网环境,不方便联网下载rpm包的生产环境
1. 下载镜像
docker pull mysql:8.0.22
2. 创建数据文件夹
mkdir -p /apps/mysql/data /apps/mysql/conf /apps/mysql/files
- /apps/mysql/data 用于存放各种数据文件、日志文件等
- /apps/mysql/conf 映射配置文件
- /apps/mysql/files 当指定了外部配置文件与外部存储路径时,也需要指定 /var/lib/mysql-files的外部目录,不然启动会报 on ‘/var/lib/mysql-files’ No such file or directory
3. 创建自己的my.cnf配置文件
在文件夹 /apps/mysql/conf 创建mysql配置文件my.cnf
###########################################################################
本配置参考 https://imysql.com/my-cnf-wizard.html
注意:
(1)本配置假设物理服务器内存为 16G,总表数量在300之内,中小型企业业务 #
(2)请根据实际情况作调整部分参数
(3)本人不对这些建议结果负相应责任
###########################################################################
[client]
port = 3306
socket =/var/lib/mysql/mysqld.sock
[mysql]
no-auto-rehash
[mysqld]
port = 3306
datadir = /var/lib/mysql
socket = /var/lib/mysql/mysqld.sock
log-error = /var/lib/mysql/error.log
pid-file = /var/lib/mysql/mysqld.pid
skip_name_resolve = 1
default_time_zone = "+8:00"
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
init_connect='SET NAMES utf8mb4'
lower_case_table_names = 1
transaction_isolation = READ-COMMITTED
explicit_defaults_for_timestamp = true
open_files_limit = 65535
max_connections = 300
max_connect_errors = 600
back_log = 110
table_open_cache = 600
table_definition_cache = 700
table_open_cache_instances = 64
thread_stack = 512K
external-locking = FALSE
max_allowed_packet = 128M
sort_buffer_size = 4M
join_buffer_size = 4M
thread_cache_size = 20
interactive_timeout = 1800
wait_timeout = 1800
lock_wait_timeout = 3600
tmp_table_size = 64M
max_heap_table_size = 64M
server-id = 110
log-bin=mysql-bin
binlog_format = ROW
binlog_row_image = FULL
binlog_expire_logs_seconds = 1209600
master_info_repository = TABLE
relay_log_info_repository = TABLE
log_slave_updates
relay_log_recovery = 1
slave_skip_errors = ddl_exist_errors
innodb_flush_log_at_trx_commit = 1
sync_binlog = 1
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G
gtid_mode = on
enforce_gtid_consistency = 1
key_buffer_size = 15M
read_buffer_size = 8M
read_rnd_buffer_size = 4M
bulk_insert_buffer_size = 64M
innodb_thread_concurrency = 0
innodb_buffer_pool_size = 8G
innodb_buffer_pool_instances = 4
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_data_file_path = ibdata1:1G:autoextend
innodb_log_buffer_size = 32M
innodb_log_files_in_group = 3
innodb_log_file_size = 2G
innodb_undo_log_truncate = 1
innodb_max_undo_log_size = 4G
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_sync = 0
innodb_flush_neighbors = 0
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_purge_threads = 4
innodb_page_cleaners = 4
innodb_open_files = 65535
innodb_max_dirty_pages_pct = 50
innodb_flush_method = O_DIRECT
innodb_lru_scan_depth = 4000
innodb_checksum_algorithm = crc32
innodb_lock_wait_timeout = 20
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_sort_buffer_size = 67108864
innodb_autoinc_lock_mode = 1
innodb_file_per_table = 1
innodb_online_alter_log_max_size = 4G
#--###########################-- innodb性能设置 结束 --##########################################
[mysqldump]
quick
max_allowed_packet = 128M
这里主要主要,几个重要文件存放的地址,这里统一存放/var/lib/mysql下,即映射到主机目录 /apps/mysql/data
###########################################################################
本配置参考 https://imysql.com/my-cnf-wizard.html
注意:
(1)本配置假设物理服务器内存为 16G,总表数量在300之内,中小型企业业务 #
(2)请根据实际情况作调整部分参数
(3)本人不对这些建议结果负相应责任
###########################################################################
3. 启动镜像
docker run -p 3306:3306 --restart=always --name mysql8 -v /apps/mysql/conf/my.cnf:/etc/mysql/my.cnf -v /apps/mysql/files:/var/lib/mysql-files -v /apps/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=Mypd12345_ -d mysql:8.0.22
一般正常情况,启动没问题,mysql镜像版本 8.0.22
完 !
更多推荐
已为社区贡献5条内容
所有评论(0)