博客
关于我
liunx环境下的mysql数据库配置文件my.conf内的参数含义
阅读量:804 次
发布时间:2023-02-06

本文共 1723 字,大约阅读时间需要 5 分钟。

MySQL配置参数优化指南

以下是基于实际应用场景对MySQL服务器配置参数的优化建议,旨在提升数据库性能和稳定性。

1. 数据库连接配置

  • port: 3306
  • socket: /tmp/mysql.sock
  • bind-address: 0.0.0.0
  • server-id: 1

2. MySQL运行环境

  • basedir: /usr/local/mysql
  • datadir: /data/mysql
  • pid-file: /data/mysql/mysql.pid
  • user: mysql

3. 性能优化参数

  • skip-name-resolve: 禁止MySQL对外部连接进行DNS解析,提高连接效率。
  • back_log: 600
  • max_connections: 1000
  • max_connect_errors: 6000
  • open_files_limit: 65535
  • table_open_cache: 128

4. 数据存储和缓存

  • max_allowed_packet: 4M
  • binlog_cache_size: 1M
  • max_heap_table_size: 8M
  • tmp_table_size: 16M
  • read_buffer_size: 2M
  • read_rnd_buffer_size: 8M
  • sort_buffer_size: 8M
  • join_buffer_size: 8M

5. 事务和日志配置

  • transaction_isolation: REPEATABLE-READ
  • log_bin: mysql-bin
  • binlog_format: mixed
  • expire_logs_days: 30
  • log_error: /data/mysql/mysql-error.log
  • slow_query_log: 1
  • long_query_time: 1

6. InnoDB存储引擎

  • innodb_file_per_table: 1
  • innodb_open_files: 500
  • innodb_buffer_pool_size: 64M
  • innodb_write_io_threads: 4
  • innodb_read_io_threads: 4
  • innodb_thread_concurrency: 0
  • innodb_purge_threads: 1
  • innodb_flush_log_at_trx_commit: 1
  • innodb_log_buffer_size: 2M
  • innodb_log_file_size: 32M
  • innodb_log_files_in_group: 3
  • innodb_max_dirty_pages_pct: 90
  • innodb_lock_wait_timeout: 120

7. 性能调优

  • bulk_insert_buffer_size: 8M
  • myisam_sort_buffer_size: 8M
  • myisam_max_sort_file_size: 10G
  • myisam_repair_threads: 1

8. 连接管理

  • interactive_timeout: 28800
  • wait_timeout: 28800

9. 数据备份与恢复

  • performance_schema: 0

10. 其他配置

  • ft_min_word_len: 4
  • default-storage-engine: InnoDB
  • skip-external-locking: 1
  • explicit_defaults_for_timestamp: 1

11. MyISAM存储引擎

  • key_buffer_size: 4M
  • sort_buffer_size: 8M

12. 环境优化建议

  • thread_cache_size: 8
  • query_cache_size: 8M
  • query_cache_limit: 2M

通过合理设置以上参数,可以显著提升MySQL的性能表现和稳定性。在实际应用中,建议根据具体环境需求和硬件资源进行调整,并通过监控数据库状态(如SHOW STATUS LIKE 'key_read%')来优化参数配置。

转载地址:http://buufk.baihongyu.com/

你可能感兴趣的文章
nginx net::ERR_ABORTED 403 (Forbidden)
查看>>
Nginx SSL 性能调优
查看>>
Nginx SSL私有证书自签,且反代80端口
查看>>
Nginx upstream性能优化
查看>>
Nginx 中解决跨域问题
查看>>
nginx 代理解决跨域
查看>>
Nginx 做负载均衡的几种轮询策略分析
查看>>
Nginx 入门,一篇搞定!
查看>>
Nginx 利用代理转发请求示例
查看>>
Nginx 动静分离与负载均衡的实现
查看>>
Nginx 反向代理 MinIO 及 ruoyi-vue-pro 配置 MinIO 详解
查看>>
nginx 反向代理 转发请求时,有时好有时没反应,产生原因及解决
查看>>
Nginx 反向代理+负载均衡
查看>>
Nginx 反向代理解决跨域问题
查看>>
Nginx 反向代理配置去除前缀
查看>>
nginx 后端获取真实ip
查看>>
Nginx 多端口配置和访问异常问题的排查与优化
查看>>
Nginx 如何代理转发传递真实 ip 地址?
查看>>
Nginx 学习总结(16)—— 动静分离、压缩、缓存、黑白名单、性能等内容温习
查看>>
Nginx 学习总结(17)—— 8 个免费开源 Nginx 管理系统,轻松管理 Nginx 站点配置
查看>>