Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
需要帮助MySQL优化mysqltuner问题_Mysql_Apache_Mysqltuner - Fatal编程技术网

需要帮助MySQL优化mysqltuner问题

需要帮助MySQL优化mysqltuner问题,mysql,apache,mysqltuner,Mysql,Apache,Mysqltuner,我正在使用MySQLTuner.pl优化我的站点/srever。。。。 虽然我不完全确定如何解决这些问题,我想知道是否有人可以帮助我 我有4GB ram的VPS,这是我的.cnf设置: [mysqld] expire_logs_days=14 sync_binlog=1 query_cache_limit=32M query_cache_size=128M slow_query_log=1 log_queries_not_using_indexes=0 thread_cache_s

我正在使用MySQLTuner.pl优化我的站点/srever。。。。 虽然我不完全确定如何解决这些问题,我想知道是否有人可以帮助我

我有4GB ram的VPS,这是我的.cnf设置:

[mysqld]    
expire_logs_days=14
sync_binlog=1

query_cache_limit=32M
query_cache_size=128M

slow_query_log=1
log_queries_not_using_indexes=0

thread_cache_size=50

max_allowed_packet=16M
max_connect_errors=1000000
max_connections=250
key_buffer_size=8M

open_files_limit=65535
tmp_table_size=256M
max_heap_table_size=256M
table_definition_cache=2048
table_open_cache=2048
default_storage_engine=InnoDB

innodb_flush_method=O_DIRECT
innodb_file_per_table=1
innodb_log_files_in_group=2
innodb_additional_mem_pool_size=40M
innodb_max_dirty_pages_pct=90
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=64M
innodb_log_file_size=256M
innodb_buffer_pool_size=1152M
以下是mysqltuner的输出:

-------- Performance Metrics -------------------------------------------------
[--] Up for: 2d 8h 36m 40s (7M q [34.897 qps], 504K conn, TX: 41B, RX: 735M)
[--] Reads / Writes: 68% / 32%
[--] Total buffers: 2.0G global + 2.8M per thread (200 max threads)
[OK] Maximum possible memory usage: 2.5G (63% of installed RAM)
[OK] Slow queries: 0% (30K/7M)
[OK] Highest usage of available connections: 20% (40/200)
[OK] Key buffer size / total MyISAM indexes: 8.0M/7.8M
[OK] Key buffer hit rate: 99.9% (1M cached / 1K reads)
[OK] Query cache efficiency: 29.3% (1M cached / 4M selects)
[!!] Query cache prunes per day: 11573
[OK] Sorts requiring temporary tables: 0% (3K temp sorts / 999K sorts)
[!!] Temporary tables created on disk: 48% (54K on disk / 112K total)
[OK] Thread cache hit rate: 99% (40 created / 504K connections)
[OK] Table cache hit rate: 33% (499 open / 1K opened)
[OK] Open file limit used: 0% (380/65K)
[OK] Table locks acquired immediately: 99% (4M immediate / 4M locks)
[OK] InnoDB buffer pool / data size: 1.1G/1001.0M
[OK] InnoDB log waits: 0
-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    Increasing the query_cache size over 128M may reduce performance
    Temporary table size is already large - reduce result set size
    Reduce your SELECT DISTINCT queries without LIMIT clauses
Variables to adjust:
    query_cache_size (> 512M) [see warning above]
我还有什么可以改进的吗

如何解决此问题:

在磁盘上创建的临时表:48%

每天查询缓存修剪数:11573

查询缓存效率:29.3%

更新:
如果您能在my.cnf中给出他们对设置的意见,我将非常高兴 因为我不是专家,设置和我在互联网上其他系统中看到的一样,可能有些不正确


谢谢你

说到优化,我相信如果不坏就不要修复。也就是说,这里有一篇关于磁盘上临时表的优秀文章


如果你不确定如何处理这些设置,那么这是一个巨大的标志,上面写着“请勿触摸”。也许你应该改变一下你的问题,告诉大家你为什么要优化数据库。是因为有东西跑得非常慢吗?是不是因为数据库占用了太多的服务器资源?没有特定目标的优化是非常危险的,优化意味着以最适合您使用它的方式调整系统,这意味着您在其他一些您不需要的领域花费了大量时间来交易性能,在您的情况下,我们不知道您不需要什么

对。一般来说,调优脚本是可怕的,因为它们会盲目推荐,并鼓励对看似不错的想法进行调整,但会产生负面后果。许多性能问题的解决方案是学习查询计划和优化器,编写更好的查询。。。没有调整。完全同意。我个人认为,95%的实际性能瓶颈将出现在查询本身上。也就是说,人们尝试优化通常有很多原因,其中很多甚至可能与优化无关,比如通过优化学习引擎/SQL,或者简单地调整统计数据,以便向他们的老板展示性能已经提高了53.21%!如果您能在my.cnf中给出他们对设置的意见,XDI将非常高兴,因为我不是专家,而且设置与我在互联网上其他系统中看到的一样,可能有些不正确。谢谢大家我的评论对评论部分来说有点太长了,我已经把它放在我的答案里了。