【发布时间】:2019-04-30 18:54:00
【问题描述】:
我有问题。 我的网站很慢 我认为是mysql。 最大用户连接即时 100 个用户。 大多数情况下为 30-40 人。
我的服务器:
英特尔至强 E3-1230v3
16 GB DDR3 内存
240 GB OCZ SSD 磁盘
Centos 7 WHM-cPanel MariaDB
...
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
12496 mysql 20 0 14.1g 1.3g 12228 S 576.1 8.2 116:38.62
/usr/sbin/mysqld
/etc/my.cnf:
port = 1905
socket = /var/lib/mysql/mysql.sock
# The MySQL Safe server
[mysqld_safe]
open_files_limit = 58000
# The MySQL server
[mysqld]
max_connections = 300
local-infile = 0
socket = /var/lib/mysql/mysql.sock
skip-external-locking
key_buffer_size = 1024M
table_open_cache = 4096
open_files_limit = 40960
max_allowed_packet=1073741824
sort_buffer_size = 4M
read_buffer_size = 4M
join_buffer_size = 4M
sort_buffer_size = 4M
read_rnd_buffer_size = 128M
myisam_sort_buffer_size = 128M
thread_cache_size = 16
#query_cache_size= 32M
tmp_table_size = 64M
max_heap_table_size = 64M
#table_cache = 1024
#Slowly log
slow-query-log = 1
slow-query-log-file = /var/lib/mysql/mysql-slow.log
long_query_time = 1
# Uncomment the following if you are using InnoDB tables
innodb_file_per_table= 1
#innodb_data_home_dir = /var/lib/mysql
#innodb_data_file_path = ibdata1:50M:autoextend
#innodb_log_group_home_dir = /var/lib/mysql
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 8096M
#innodb_additional_mem_pool_size = 64M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 64M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
# Connection Settings
wait_timeout = 60
skip-external-locking
[mysqldump]
quick
max_allowed_packet = 64M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 256M
read_buffer = 8M
write_buffer = 8M
# Query Cache Settings
query_cache_type = 1
query_cache_limit = 256K
query_cache_min_res_unit = 2k
query_cache_size = 80M
skip-external-locking
[mysqlhotcopy]
interactive-timeout
我该如何解决这个问题?
谢谢。
【问题讨论】:
-
高 CPU 几乎总是来自慢查询。由于您已经开启了慢日志,请digest it and show us what you find。 那么我们应该能够快速帮助您。 (Wilson 请求的
SHOWs可能也很有用。) -
8.3% 内存没有意义;请检查。
-
我放入了 pastebin,链接:pastebin.com/6ACte0ib
-
@WilsonHauck 谢谢,我已经准备好了他们的遗愿,他们在这里:pastebin.com/M6c8LetR 抱歉,我没有使用 Skype :(
-
@RickJames 你怎么看这一切?我已将所有请求上传到 pastebin..