mariadb数据库优化需要根据自己业务需求以及根据硬件配置来进行参数优化,下面是一些关于mariadb数据库参数优化的配置文件。

1 如下为128G内存32线程处理器的mariadb配置参数优化:

[client]
#password= your_password
port= 3306
socket= /tmp/mysql.sock
!includedir /opt/local/mysql/wsrep
# The MySQL server
[mysqld]
port= 3306
socket= /tmp/mysql.sock
basedir = /opt/local/mysql
datadir=/opt/local/mysql/data #数据库存放目录
relay-log=/opt/local/mysql/relaylog/s74-relay-bin
pid-file = /opt/local/mysql/mysql.pid
log-error = /opt/local/mysql/logs/mysqld.log
open_files_limit = 65535 #
#skip-locking
skip-external-locking #跳过外部锁定
back_log=3000 #暂存的连接数量
skip-name-resolve #关闭mysql的dns反查功能
memlock #将mysqld 进程锁定在内存中
lower_case_table_names = 1
#query_response_time_stats=1
#core-file
#core-file-size = unlimited
query_cache_type=1 #查询缓存 (0 = off、1 = on、2 = demand)
performance_schema=0 #收集数据库服务器性能参数
net_read_timeout=3600 #连接繁忙阶段(query)起作用
net_write_timeout=3600 #连接繁忙阶段(query)起作用
key_buffer_size = 32M #设置索引块缓存大小
max_allowed_packet = 128M #通信缓冲大小
table_open_cache = 1024 #table高速缓存的数量
sort_buffer_size = 12M #每个connection(session)第一次需要使用这个buffer的时候,一次性分配设置的内存
read_buffer_size = 8M #顺序读取数据缓冲区使用内存
#sort_buffer_size = 32M
#read_buffer_size = 32M
read_rnd_buffer_size = 32M #随机读取数据缓冲区使用内存
myisam_sort_buffer_size = 32M #MyISAM表发生变化时重新排序所需的缓冲
thread_cache_size = 120 #重新利用保存在缓存中线程的数量
query_cache_size = 64M
join_buffer_size = 8M #Join操作使用内存
bulk_insert_buffer_size = 32M #批量插入数据缓存大小
delay_key_write=ON #在表关闭之前,将对表的update操作指跟新数据到磁盘,而不更新索引到磁盘,把对索引的更改记录在内存。这样MyISAM表可以使索引更新更快。在关闭表的时候一起更新索引到磁盘
delayed_insert_limit=4000
delayed_insert_timeout=600
delayed_queue_size=4000
# Try number of CPU's*2 for thread_concurrency
# The variable only affects Solaris!
thread_concurrency = 64 #CPU核数 * 2
max_connections=1500 #最大连接(用户)数。每个连接MySQL的用户均算作一个连接
max_connect_errors=30 #最大失败连接限制
interactive_timeout=600 #服务器关闭交互式连接前等待活动的秒数
wait_timeout=3600 #服务器关闭非交互连接之前等待活动的秒数
slow_query_log #慢查询记录日志
long_query_time = 0.1 #慢查询记录时间 0.1秒
slow_query_log_file=/opt/local/mysql/logs/slow_query.log #慢查询日志路径
#log_slow_verbosity=full
log_slow_verbosity=query_plan #
# Replication Master Server (default)
# binary logging is required for replication
log-bin=/opt/local/mysql/binlog/mysql-bin #binlog 名称
log-slave-updates #从master取得并执行的二进制日志写入自己的二进制日志文件中
replicate-ignore-db=mysql #不同步的表
# binary logging format - mixed recommended
binlog_format=row #binlog 格式 分别为 row=行格式 丶 mixed=混合格式 丶 STATEMENT=SQL语句复制模式
event_scheduler=1 #计划任务 事件调度器
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id= 1 #
# Point the following paths to different dedicated disks
#tmpdir= /tmp/
#log-update = /path-to-dedicated-directory/hostname
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /data/mysql-5.1.48/mysql-data/
#innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
#innodb_log_group_home_dir = /data/mysql-5.1.48/mysql-data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_file_format=barracuda
innodb_file_format_max=barracuda
innodb_file_per_table=1
innodb_fast_shutdown=0
innodb_buffer_pool_size = 90000M
innodb_buffer_pool_instances = 4
#innodb_additional_mem_pool_size = 20M
#innodb_use_sys_malloc = 20M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 512M
#innodb_log_buffer_size = 8M
innodb_log_files_in_group = 3
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 3
innodb_rollback_on_timeout = on
innodb_flush_method=O_DIRECT
transaction-isolation=READ-COMMITTED
innodb_thread_concurrency=0
innodb_io_capacity=800
innodb_purge_threads=1
innodb_open_files=65535
#innodb_stats_update_need_lock=0
#innodb_flush_neighbor_pages=0
#innodb_aio_pending_ios_per_thread=256
#for binlog_format=row
innodb_autoinc_lock_mode=2
#innodb_fast_checksum = 1
innodb_read_io_threads = 8
innodb_write_io_threads = 12
innodb_stats_on_metadata = 0
#使用线程池处理连接
thread_handling=pool-of-threads
thread_pool_oversubscribe=30
thread_pool_size=64
thread_pool_idle_timeout=7200
thread_pool_max_threads=2000
#查询优化器开关
#optimizer_switch='index_condition_pushdown=on'
#optimizer_switch='mrr=on'
#optimizer_switch='mrr_sort_keys=on'
#optimizer_switch='mrr_cost_based=off'
#mrr_buffer_size=32M
#optimizer_switch='join_cache_incremental=on'
#optimizer_switch='join_cache_hashed=on'
#optimizer_switch='join_cache_bka=on'
#join_cache_level=4
#join_buffer_size=32M
#join_buffer_space_limit=32M
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[isamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout

2 如下为256G内存64线程处理器的mariadb配置参数优化:

[client]
#password= your_password
port= 3306
socket= /tmp/mysql.sock
!includedir /opt/local/mysql/wsrep
# The MySQL server
[mysqld]
port= 3306
socket= /tmp/mysql.sock
basedir = /opt/local/mysql
datadir=/opt/local/mysql/data #数据库存放目录
relay-log=/opt/local/mysql/relaylog/s74-relay-bin
pid-file = /opt/local/mysql/mysql.pid
log-error = /opt/local/mysql/logs/mysqld.log
open_files_limit = 65535 #
#skip-locking
skip-external-locking #跳过外部锁定
back_log=3000 #暂存的连接数量
skip-name-resolve #关闭mysql的dns反查功能
memlock #将mysqld 进程锁定在内存中
lower_case_table_names = 1
#query_response_time_stats=1
#core-file
#core-file-size = unlimited
query_cache_type=1 #查询缓存 (0 = off、1 = on、2 = demand)
performance_schema=0 #收集数据库服务器性能参数
net_read_timeout=3600 #连接繁忙阶段(query)起作用
net_write_timeout=3600 #连接繁忙阶段(query)起作用
key_buffer_size = 32M #设置索引块缓存大小
max_allowed_packet = 128M #通信缓冲大小
table_open_cache = 1024 #table高速缓存的数量
sort_buffer_size = 12M #每个connection(session)第一次需要使用这个buffer的时候,一次性分配设置的内存
read_buffer_size = 8M #顺序读取数据缓冲区使用内存
#sort_buffer_size = 32M
#read_buffer_size = 32M
read_rnd_buffer_size = 32M #随机读取数据缓冲区使用内存
myisam_sort_buffer_size = 32M #MyISAM表发生变化时重新排序所需的缓冲
thread_cache_size = 120 #重新利用保存在缓存中线程的数量
query_cache_size = 64M
join_buffer_size = 8M #Join操作使用内存
bulk_insert_buffer_size = 32M #批量插入数据缓存大小
delay_key_write=ON #在表关闭之前,将对表的update操作指跟新数据到磁盘,而不更新索引到磁盘,把对索引的更改记录在内存。这样MyISAM表可以使索引更新更快。在关闭表的时候一起更新索引到磁盘
delayed_insert_limit=4000
delayed_insert_timeout=600
delayed_queue_size=4000
# Try number of CPU's*2 for thread_concurrency
# The variable only affects Solaris!
thread_concurrency = 96 #CPU核数 * 2
max_connections=1500 #最大连接(用户)数。每个连接MySQL的用户均算作一个连接
max_connect_errors=30 #最大失败连接限制
interactive_timeout=600 #服务器关闭交互式连接前等待活动的秒数
wait_timeout=3600 #服务器关闭非交互连接之前等待活动的秒数
slow_query_log #慢查询记录日志
long_query_time = 0.1 #慢查询记录时间 0.1秒
slow_query_log_file=/opt/local/mysql/logs/slow_query.log #慢查询日志路径
#log_slow_verbosity=full
log_slow_verbosity=query_plan #
# Replication Master Server (default)
# binary logging is required for replication
log-bin=/opt/local/mysql/binlog/mysql-bin #binlog 名称
log-slave-updates #从master取得并执行的二进制日志写入自己的二进制日志文件中
replicate-ignore-db=mysql #不同步的表
# binary logging format - mixed recommended
binlog_format=row #binlog 格式 分别为 row=行格式 丶 mixed=混合格式 丶 STATEMENT=SQL语句复制模式
event_scheduler=1 #计划任务 事件调度器
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id= 1 #
# Point the following paths to different dedicated disks
#tmpdir= /tmp/
#log-update = /path-to-dedicated-directory/hostname
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /data/mysql-5.1.48/mysql-data/
#innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend
#innodb_log_group_home_dir = /data/mysql-5.1.48/mysql-data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_file_format=barracuda
innodb_file_format_max=barracuda
innodb_file_per_table=1
innodb_fast_shutdown=0
innodb_buffer_pool_size = 180000M
innodb_buffer_pool_instances = 4
#innodb_additional_mem_pool_size = 20M
#innodb_use_sys_malloc = 20M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 512M
#innodb_log_buffer_size = 8M
innodb_log_files_in_group = 3
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 3
innodb_rollback_on_timeout = on
innodb_flush_method=O_DIRECT
transaction-isolation=READ-COMMITTED
innodb_thread_concurrency=0
innodb_io_capacity=800
innodb_purge_threads=1
innodb_open_files=65535
#innodb_stats_update_need_lock=0
#innodb_flush_neighbor_pages=0
#innodb_aio_pending_ios_per_thread=256
#for binlog_format=row
innodb_autoinc_lock_mode=2
#innodb_fast_checksum = 1
innodb_read_io_threads = 8
innodb_write_io_threads = 12
innodb_stats_on_metadata = 0
#使用线程池处理连接
thread_handling=pool-of-threads
thread_pool_oversubscribe=30
thread_pool_size=64
thread_pool_idle_timeout=7200
thread_pool_max_threads=2000
#查询优化器开关
#optimizer_switch='index_condition_pushdown=on'
#optimizer_switch='mrr=on'
#optimizer_switch='mrr_sort_keys=on'
#optimizer_switch='mrr_cost_based=off'
#mrr_buffer_size=32M
#optimizer_switch='join_cache_incremental=on'
#optimizer_switch='join_cache_hashed=on'
#optimizer_switch='join_cache_bka=on'
#join_cache_level=4
#join_buffer_size=32M
#join_buffer_space_limit=32M
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[isamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout

作者:若有所思11
链接:https://www.jianshu.com/p/ac05107db343
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

mariadb配置文件优化参数的更多相关文章

  1. Mariadb配置文件优化参数(仅供参考)

    [client]#password= your_passwordport= 3306         socket= /tmp/mysql.sock!includedir /opt/local/mys ...

  2. Elasticsearch优化 & filebeat配置文件优化 & logstash格式配置 & grok实践

    Elasticsearch优化 & filebeat配置文件优化 & logstash格式配置 & grok实践 编码转换问题(主要就是中文乱码) (1)input 中的cod ...

  3. postgresql 配置文件优化

    postgresql 配置文件优化 配置文件 默认的配置配置文件是保存在/etc/postgresql/VERSION/main目录下的postgresql.conf文件 如果想查看参数修改是否生效, ...

  4. Nginx核心配置文件常用参数详解

    Nginx核心配置文件常用参数详解 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 关于Nginx权威文档的话童鞋们可以参考Nginx官方文档介绍:http://nginx.org/ ...

  5. MySQL-5.5.32 配置文件优化详解

    目录 MySQL-5.5.32 配置文件优化详解 一.配置文件说明 2.my-medium.cnf 3.my-large.cnf 4.my-huge.cnf 5.my-innodb-heavy-4G. ...

  6. php-fpm优化参数介绍

    1.php-fpm优化参数介绍他们分别是:pm.pm.max_children.pm.start_servers.pm.min_spare_servers.pm.max_spare_servers. ...

  7. Nginx 笔记(四)nginx 原理与优化参数配置 与 nginx 搭建高可用集群

    个人博客网:https://wushaopei.github.io/    (你想要这里多有) 一.nginx 原理与优化参数配置 ​ ​ master-workers 的机制的好处 首先,对于每个 ...

  8. (转)hadoop三个配置文件的参数含义说明

     hadoop三个配置文件的参数含义说明     1       获取默认配置 配置hadoop,主要是配置core-site.xml,hdfs-site.xml,mapred-site.xml三个配 ...

  9. (转)[Nginx] – 配置文件优化 [一 ,二]

    [Nginx] – 安全优化 – 配置文件优化 [二] 原文:https://www.abcdocker.com/abcdocker/586 [Nginx] – 性能优化 – 配置文件优化 [一] 原 ...

随机推荐

  1. 汇总下几个IP计算/转换的shell小脚本-转

    原文:http://blog.chinaunix.net/uid-20788470-id-1841646.html   1. IP转换为整数> vi ip2num.sh#!/bin/bash# ...

  2. redis键(key)

    redis键: 用于管理redis的键 command key_name > set runoodkey redis OK > del runoodkey 上面的例子中,del是一个命令, ...

  3. Mybatis编写初始化Dao代码

    第一步:创建User实体类(POJO) package com.xu.pojo; import java.util.Date; /** * * @author 徐亮亮 * Title: User * ...

  4. pycharm2018激活

    pyCharm最新2018最新激活码 选择 Activate new license with License server (用license server 激活) 在 License sever ...

  5. 请问Pycharm如何实现变量的批量重命名?

    1.点击你要改的单词,右键refactor ->rename 2. Ctrl + R 替换 Ctrl + Shift + F 全局查找 Ctrl + Shift + R 全局替换

  6. UVA11613 Acme Corproation

    UVA11613 Acme Corproation 生产销售计划 题目大意 A公司生产一种元素,给出该元素在未来M个月中每个月的单位售价,最大生产量,生产成本,最大销售量和最大存储时间,和每月存储代价 ...

  7. 唱吧基于 MaxCompute 的大数据之路

    使用 MaxCompute之前,唱吧使用自建体系来存储处理各端收集来的日志数据,包括请求访问记录.埋点数据.服务器业务数据等.初期这套基于开源组件的体系有力支撑了数据统计.业务报表.风控等业务需求.但 ...

  8. 干货来了!2019阿里云合作伙伴峰会SaaS加速器专场回顾合集:嘉宾分享、深度解读

    2019年7月26日,在上海举办的阿里云合作伙伴峰会上,阿里云正式发布SaaS生态战略,计划用阿里云的品牌.渠道.资本.方法论.技术加持伙伴,成就亿级营收独角兽. 该生态战略计划招募10家一级SaaS ...

  9. CF 500B New Year Permutation

    传送门 题目大意 给你一个数列,再给你一个矩阵,矩阵的(i,j)如果为1就表示可以将i,j位置上的数交换,问任意交换之后使原数列字典序最小并输出. 解题思路 因为如果i与j能交换,j与k能交换,那么i ...

  10. bzoj 1059 [ZJOI2007]矩阵游戏——匈牙利算法

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1059 发现不管怎么换,同一列的元素还是在同一列,同一行的元素还是在同一行. 所以必要条件是每 ...