优化我的MySQL服务器

我刚刚更新到一个8GB的专用服务器从3GB的VPS,不能再处理我的网站。 我build立了一个使用狮身人面像全文search引擎的search引擎,每天接收100k到200k的查询,其中很多都是googlebot等。

无论如何,我需要帮助configurationMySQL到一个非常大量的数据库驱动的网站。 数据库大约10个演出,数据不断被查询和插入。 任何人都可以推荐一些设置,以帮助我在这个新的8GB服务器上获得最好的性能,我可以从MySQL? 我真的很感谢帮助。

我正在使用MyISAM表。

这是我的my.cnf文件。 谁能告诉我我应该做什么或者你会做什么?

服务器的规格是:

  • 四核至强X3220
  • 8 GB DDR2
  • 2个500 GB SATA2
[client] port = 3306 socket = /var/run/mysqld/mysqld.sock [mysqld_safe] socket = /var/run/mysqld/mysqld.sock nice = 0 [mysqld] user = mysql socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp skip-external-locking #bind-address = 127.0.0.1 # # * Fine Tuning # key_buffer = 256M max_allowed_packet = 16M sort_buffer_size = 32M #mysiam_sort_buffer_size = 32M tmp_table_size = 128M thread_stack = 192K thread_cache_size = 8 # This replaces the startup script and checks MyISAM tables if needed # the first time they are touched myisam-recover = BACKUP max_connections = 500 table_cache = 64 #thread_concurrency = 10 # # * Query Cache Configuration # query_cache_limit = 1M query_cache_size = 1M # # * Logging and Replication # # Both location gets rotated by the cronjob. # Be aware that this log type is a performance killer. # As of 5.1 you can enable the log at runtime! #general_log_file = /var/log/mysql/mysql.log #general_log = 1 log_error = /var/log/mysql/error.log # Here you can see queries with especially long duration #log_slow_queries = /var/log/mysql/mysql-slow.log #long_query_time = 2 #log-queries-not-using-indexes # # The following can be used as easy to replay backup logs or for replication. # note: if you are setting up a replication slave, see README.Debian about # other settings you may need to change. #server-id = 1 #log_bin = /var/log/mysql/mysql-bin.log expire_logs_days = 10 max_binlog_size = 100M #binlog_do_db = include_database_name #binlog_ignore_db = include_database_name # # * InnoDB # # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. # Read the manual for more InnoDB related options. There are many! # # * Security Features # # Read the manual, too, if you want chroot! # chroot = /var/lib/mysql/ # # For generating SSL certificates I recommend the OpenSSL GUI "tinyca". # # ssl-ca=/etc/mysql/cacert.pem # ssl-cert=/etc/mysql/server-cert.pem # ssl-key=/etc/mysql/server-key.pem [mysqldump] quick quote-names max_allowed_packet = 16M [mysql] #no-auto-rehash # faster start of mysql but no tab completition [isamchk] key_buffer = 16M # # * IMPORTANT: Additional settings that can override those from this file! # The files must end with '.cnf', otherwise they'll be ignored. # !includedir /etc/mysql/conf.d/ 

http://mysqltuner.pl/mysqltuner.pl是一个很好的脚本,可以识别任何潜在的问题。

一旦MySQL运行至less一个小时左右,最好运行它。 如果你刚刚重新启动MySQL,那么它没有很多的统计数据。

wget http://mysqltuner.pl/mysqltuner.pl && perl mysqltuner.pl

在这里你可以find几个可以用来调整你的MySQL服务器的脚本

http://www.serveradminblog.com/2011/03/tuning-mysql-performance-howto-part-1/