mysql - 如何配置mysql服务器(提高速度)
问题描述
我的数据库大小为 13.4Gb。服务器有 32 GB 的 RAM。
但是查询类型选择仍然很慢。
我启动了 mysqltuner,他发出以下消息:
-------- Performance Metrics -------------------------------------------------
[--] Up for: 5s (9 q [1.800 qps], 7 conn, TX: 17K, RX: 1K)
[--] Reads / Writes: 100% / 0%
[--] Binary logging is disabled
[--] Total buffers: 24.5G global + 392.4M per thread (64 max threads)
[OK] Maximum reached memory usage: 24.9G (79.27% of installed RAM)
[!!] Maximum possible memory usage: 49.0G (156.10% of installed RAM)
[OK] Slow queries: 0% (0/9)
[OK] Highest usage of available connections: 1% (1/64)
[!!] Aborted connections: 14.29% (1/7)
[!!] Query cache efficiency: 0.0% (0 cached / 4 selects)
[OK] Query cache prunes per day: 0
[OK] Temporary tables created on disk: 0% (0 on disk / 2 total)
[OK] Thread cache hit rate: 85% (1 created / 7 connections)
[OK] Table cache hit rate: 93% (100 open / 107 opened)
[OK] Open file limit used: 0% (15/1M)
[OK] Table locks acquired immediately: 100% (100 immediate / 100 locks)
-------- InnoDB Metrics -----------------------------------------------------
[--] InnoDB is enabled.
[OK] InnoDB buffer pool / data size: 23.4G/13.4G
[!!] InnoDB buffer pool instances: 24
[!!] InnoDB Used buffer: 0.03% (414 used/ 1535976 total)
[!!] InnoDB Read buffer efficiency: 79.34% (1463 hits/ 1844 total)
[!!] InnoDB Write buffer efficiency: 0.00% (0 hits/ 1 total)
[OK] InnoDB log waits: 0.00% (0 waits / 2 writes)
我有以下服务器mysql配置:
key_buffer_size = 1024M
sort_buffer_size = 256M
max_allowed_packet = 1024M
read_buffer_size = 8M
read_rnd_buffer_size = 128M
thread_stack = 128K
query_cache_limit = 1M
query_cache_size = 8M
query_cache_type = 1
thread_cache_size = 16
max_heap_table_size = 128M
tmp_table_size = 64M
net_read_timeout = 3600
net_write_timeout = 3600
wait_timeout = 120
interactive_timeout = 120
table_open_cache = 1024M
#join_buffer_size=2048M
max_connections = 64
innodb_open_files = 4096
innodb_file_per_table = 1
innodb_flush_method=O_DIRECT
innodb_flush_log_at_trx_commit=2
innodb_log_file_size = 512M
innodb_log_buffer_size = 16M
innodb_buffer_pool_size=24000M
innodb_buffer_pool_instances=24
innodb_buffer_pool_chunk_size = 500M
#innodb_additional_mem_pool_size = 20M
#innodb_thread_concurrency = 16
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_stats_on_metadata = 0
#innodb_io_capacity=2000
innodb_data_file_path=ibdata1:10M:autoextend
您能否告诉我如何正确纠正以下错误并提高从数据库中采样的速度?
[!!] InnoDB buffer pool instances: 24
[!!] InnoDB Used buffer: 0.03% (414 used/ 1535976 total)
[!!] InnoDB Read buffer efficiency: 79.34% (1463 hits/ 1844 total)
[!!] InnoDB Write buffer efficiency: 0.00% (0 hits/ 1 total)
[!!] Maximum possible memory usage: 49.0G (156.10% of installed RAM)
[!!] Aborted connections: 14.29% (1/7)
PS 我不使用索引,因为它增加了查询超时并增加了数据库的大小。
解决方案
我可能会在这里留下所有帮助我解决这个问题的有用答案。
- 始终验证指定的服务器配置值是否正确
如果你需要快速类型的请求——select,你需要牺牲磁盘的大小。
正确的数据库结构将避免复杂的查询并提高性能。
- 有必要尝试执行不大且不合逻辑的小型逻辑查询。
- 如果请求不正确,服务器的配置对请求的速度影响不大。
- 理想情况下,应该使用哈希,而不是索引)
- 在新版的肌肉中,尽量多使用——WITH table as (SELECT)
- 阅读一本书 - Dan Tow 的“SQL 调优”,ISBN 0-596-00573-3
我不能挑出一条对我有帮助的特别建议,因为它们都很好。
推荐阅读
- ajax - 在 AJAX 调用中显示和隐藏 Spinner 时出现问题
- azure-devops - 在哪里可以找到新导航下的每人冲刺能力栏?
- updates - 当您有多个服务器版本时,如何构建自动更新桌面应用程序,并且每个服务器版本之间存在重大更改?
- ios - 归档构建时预期的“语言”、“定义的_in”或“生成的声明”
- macos - MacOS - 屏幕解锁时切换 wifi
- c# - XML-Warnings 不会在带有 ReSharper 18.2 的 Studio 17 中显示
- php - 比较键上的两个数组,如果键不匹配,则创建多个数组集值
- dart - Flutter:具有多个小部件的自定义抽屉
- java - 从Android(JAVA)的Json(序列化形式)中检索数据
- sensors - 有哪些很好的资源可以了解 IMU 的传感器漂移校正?