最近mysql cpu常常負載,因為網頁是請人家寫的。
只能先從my.cnf 設定下手。
[mysqld_safe]
log_error=/var/log/mysql/mysql_error.log
[mysqld]
log_error=/var/log/mysql_error.log
general_log_file="/var/log/mysql-general.log"
general_log=0
slow-query-log = 1
slow_query_log_file=/var/log/mysql_slow.log
long_query_time = 1
character-set-server=utf8
collation-server=utf8_unicode_ci
character-set-server=utf8
collation-server=utf8_unicode_ci
character-set-filesystem=utf8
default-storage-engine=MyISAM
innodb_file_per_table=1
performance-schema=1
max_allowed_packet=268435456
open_files_limit=40000
innodb_buffer_pool_size=2G
innodb_log_file_size = 2G
innodb_flush_log_at_trx_commit = 1
innodb_flush_method = O_DIRECT
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
key_buffer_size=100M
tmp_table_size=157M
sort_buffer_size=512K
join_buffer_size=1M
max_heap_table_size=157M
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
CPU:E3-1270v5 3.6GHz
RMA:16G
HDD
每日訪問量 12290
請問這樣設定是否正確?是否還有優化的空間。!
感謝!