|
我100个用户做查询操作时候,数据库服务器的cpu平均达到72.5,求助吧帮忙看看数据库的参数可以怎么优化下。
系统:cent os 6.5
4 CPU
2 核
我的mysql配置文件如下
my.cnf
[mysql]
# CLIENT #
port = 3306
socket = /tmp/mysql.sock
#character_set_server = utf8
[mysqld]
# GENERAL #
user = mysql
default-storage-engine = InnoDB
datadir =/mysql/data
socket = /tmp/mysql.sock
pid-file = /mysql/data/mysql.pid
enforce_gtid_consistency = true
gtid_mode=on
character_set_server = utf8
# MyISAM #
key_buffer_size = 32M
#myisam_recover = FORCE,BACKUP
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 8M
myisam_repair_threads = 1
myisam_recover
#add 11.12 11:20
read_buffer_size = 2M
read_rnd_buffer_size = 4M
bulk_insert_buffer_size = 8M
# SAFETY #
max_allowed_packet = 16M
max_connect_errors = 10
innodb = FORCE
# DATA STORAGE #
datadir = /mysql/data
# BINARY LOGGING #
log-bin = /mysql/data/mysql-bin
expire-logs-days = 14
sync-binlog = 1
server-id = 184388
binlog_format = statement
log_slave_updates = 1
binlog_cache_size = 1M
log_bin_trust_function_creators = 1
skip-name-resolve
slow_query_log=on
# REPLICATION #
log-slave-updates = 1
relay-log = /mysql/data/relay-bin
slave-net-timeout = 60
# CACHES AND LIMITS #
tmp_table_size = 128M
max_heap_table_size = 128M
sort_buffer_size = 8M
join_buffer_size = 8M
query_cache_type = 1
query_cache_size = 512M
query_cache_limit = 2M
max_connections = 1500
thread_cache_size = 100
open_files_limit = 65535
table_definition_cache = 2048
table_open_cache = 2048
thread_concurrency = 16
thread_cache_size = 64
thread_stack = 192K
transaction_isolation = REPEATABLE-READ
# INNODB #
innodb_flush_method = O_DIRECT
innodb_log_files_in_group = 3
innodb_log_buffer_size = 8M
innodb_log_file_size = 64M
innodb_log_files_in_group = 3
innodb_flush_log_at_trx_commit = 2
innodb_file_per_table = 1
#innodb_buffer_pool_size = 4G
innodb_buffer_pool_size = 4G
innodb_data_file_path = ibdata1:100M:autoextend
innodb_data_home_dir = /mysql/innodb
innodb_lock_wait_timeout = 15
innodb_thread_concurrency = 16
innodb_file_format = barracuda
innodb_strict_mode = 1
innodb_file_io_threads = 4
innodb_max_dirty_pages_pct = 75
# LOGGING #
log-error = /mysql/data/mysql-error.log
log-queries-not-using-indexes = 1
slow-query-log = 1
slow-query-log-file = /mysql/data/mysql-slow.log
|
|