本文主要提供基于DBFS之上构建MySQL 5.7数据库的配置文件my.cnf参考。

MySQL 5.7配置文件说明:
  • 目录说明,“/mnt/dbfs/v-bp196g0zi82d0pqte8r9/”为用户DBFS服务挂载目录。可根据用户具体挂载目录进行更改。
  • 此配置文件中,已经关闭MySQL Double Write Buffer。
  • 此配置文件中,与内存、连接数等相关的配置项,用户可根据具体情况做更改。
  • 此配置文件仅做参考,不做强制要求。
MySQL 5.7配置文件如下:
[mysqld_safe]
pid-file=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/run/mysqld.pid
malloc-lib=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/mysql-5.7.26/lib/libjemalloc.so

[mysql]
port=3307
prompt=\\u@\\d \\r:\\m:\\s>
default-character-set=utf8mb4
no-auto-rehash

[client]
port=3307
socket=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/run/mysql.sock

[mysqld]
#dir
core-file
basedir=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/mysql-5.7.26
datadir=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/data
tmpdir=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/tmp
lc_messages_dir=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/mysql-5.7.26/share
log-error=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/log/alert.log
slow_query_log_file=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/log/slow.log
general_log_file=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/log/general.log
socket=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/run/mysql.sock

# close 5.6 variables for 5.5
binlog_checksum=none
log_bin_use_v1_row_events=on
explicit_defaults_for_timestamp=OFF
binlog_row_image=FULL
binlog_rows_query_log_events=OFF
binlog_stmt_cache_size=32768

#innodb
innodb_data_home_dir=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/data
innodb_log_group_home_dir=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/data
innodb_data_file_path=ibdata1:1G;ibdata2:1G:autoextend
innodb_buffer_pool_instances=4
innodb_log_files_in_group=4
innodb_log_file_size=1G
innodb_log_buffer_size=200M
innodb_flush_log_at_trx_commit=1
innodb_max_dirty_pages_pct=60
innodb_io_capacity_max=10000
innodb_io_capacity=6000
innodb_thread_concurrency=32
innodb_read_io_threads=8
innodb_write_io_threads=8
innodb_open_files=615350
innodb_file_format=Barracuda
innodb_file_per_table=1
innodb_flush_method=O_DIRECT
innodb_change_buffering=none
innodb_adaptive_flushing=1
innodb_old_blocks_time=1000
innodb_stats_on_metadata=0
innodb_use_native_aio=1
innodb_lock_wait_timeout=5
innodb_rollback_on_timeout=0
innodb_purge_threads=4
innodb_strict_mode=1
transaction-isolation=READ-COMMITTED
innodb_disable_sort_file_cache=ON
innodb_lru_scan_depth=2048
innodb_flush_neighbors=0
innodb_sync_array_size=16
innodb_print_all_deadlocks
innodb_checksum_algorithm=CRC32
innodb_max_dirty_pages_pct_lwm=10
innodb_buffer_pool_size=8G
innodb_read_ahead_threshold=0
innodb_doublewrite=off

#myisam
concurrent_insert=2
delayed_insert_timeout=300

#replication
master-info-file=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/log/master.info
relay-log=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/log/relaylog
relay_log_info_file=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/log/relay-log.info
relay-log-index=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/log/mysqld-relay-bin.index
slave_load_tmpdir=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/tmp
slave_type_conversions="ALL_NON_LOSSY"
slave_net_timeout=4
skip-slave-start=OFF
sync_master_info=10000
sync_relay_log_info=1
master_info_repository=TABLE
relay_log_info_repository=TABLE
relay_log_recovery=0
slave_exec_mode=STRICT
slave_parallel_type=DATABASE
slave-parallel-workers=32

#binlog
log-bin=/mnt/dbfs/v-bp196g0zi82d0pqte8r9/my3307/log/mysql-bin
server_id=195697006
binlog_cache_size=32K
max_binlog_cache_size=2G
max_binlog_size=500M
max_relay_log_size=500M
relay_log_purge=OFF
binlog-format=ROW
sync_binlog=1
sync_relay_log=1
log-slave-updates=0
expire_logs_days=0
rpl_stop_slave_timeout=300
slave_checkpoint_group=1024
slave_checkpoint_period=300
slave_pending_jobs_size_max=1073741824
slave_rows_search_algorithms='TABLE_SCAN,INDEX_SCAN'
slave_sql_verify_checksum=OFF
master_verify_checksum=OFF

#gtid
gtid_mode=OFF
enforce_gtid_consistency=OFF

#server
default-storage-engine=INNODB
character-set-server=utf8mb4
lower_case_table_names=1
skip-external-locking
open_files_limit=615350
safe-user-create
local-infile=1
sql_mode='NO_ENGINE_SUBSTITUTION'
performance_schema=0


log_slow_admin_statements=1
log_warnings=3
long_query_time=1
slow_query_log=1
general_log=0

query_cache_type=0
query_cache_limit=1M
query_cache_min_res_unit=1K

table_definition_cache=32768
metadata_locks_hash_instances=256
metadata_locks_cache_size=32768
eq_range_index_dive_limit=200
table_open_cache_instances=16
table_open_cache=32768

thread_stack=512K
binlog_cache_size=32K
net_buffer_length=16384
thread_cache_size=256
read_rnd_buffer_size=128K
sort_buffer_size=256K
join_buffer_size=128K
read_buffer_size=128K

port=3307
skip-name-resolve
skip-ssl
max_connections=10000
max_user_connections=8000
max_connect_errors=65536
max_allowed_packet=1G
connect_timeout=8
net_read_timeout=30
net_write_timeout=60
back_log=1024

log_queries_not_using_indexes=0
log_timestamps=SYSTEM