Centos 7, WHM High Mysql&MariaDB CPU 사용량 %600
문제가 있어요.제 웹사이트는 매우 느려서 mysql인 것 같습니다.최대 사용자 연결 즉시 100명의 사용자. 대부분의 경우 30-40명.
내 서버:
Intel Xeon E3-1230v3
16GB DDR3 RAM
240GB OCZ SSD 디스크
센토스 7 WHM-c 패널 마리아DB
...
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
어떻게 하면 이 문제를 해결할 수 있습니까?
감사해요.
결론:인덱스를 몇 개 추가하면 다음과 같은 이점이 있습니다.
INDEX(islemkey)
INDEX(site, durum, islem_baslangic)
INDEX(durum, site, site_durum, id)
세부 사항
UPDATE odemeler SET step='odeme_kontrol' WHERE islemkey = '78TNgyacgjwt'
필요합니다INDEX(islemkey)에odemeler.
`expire` varchar(255) DEFAULT NULL,
AND islem_baslangic LIKE '2018-11-29%'
한다면expire이다.DATE또는DATETIME그런 다음 그렇게 선언해야 합니다.표준이 아닌 날짜 형식일 경우 변환이 필요합니다.할 수 있는 일islem_baslangic및 날짜가 들어 있는 다른 열.
SELECT * FROM odemeler WHERE site = '71' AND durum = '1'
odemeler이 합성물이 필요합니다.INDEX(site, durum)선택적으로 반대 순서로 나열할 수 있습니다.
SELECT id,tcno, miktar,durum,islem_baslangic,site,site_durum
FROM odemeler
WHERE site = '74' AND durum = '1' AND site_durum = '0'
ORDER BY id DESC LIMIT 20
필요.
INDEX(site, durum, site_durum, -- in any order
id) -- last
이유
사용 가능한 인덱스가 없으면 대부분의 쿼리가PROCESSLIST전체 테이블을 스캔해야 합니다.이것은 많은 CPU를 필요로 합니다. 그리고 각각의 쿼리 속도를 늦춥니다.그런 다음 쿼리가 쌓입니다. (그것은 많은 쿼리였습니다.)PROCESSLIST즉시.)
사용 가능한 인덱스를 사용하면 각 쿼리가 훨씬 더 빨리 오고 가고 CPU를 훨씬 적게 사용합니다.그것이 인덱스의 목적입니다!
루트 사용자와 함께 WHM에 로그인합니다. 멀티 PHP 관리자에서 웹 사이트를 해당 웹 사이트에 대해 PHP 7.1 활성화 php-fpm으로 전환합니다.
두 번째로 mysql 튜너 스크립트를 다운로드하여 최적의 mysql 성능을 위해 /etc/my.cnf 설정을 조정할 수 있습니다.
이러한 모든 변경 후에도 작동하지 않으면 mysql 데이터베이스를 최적화해야 합니다.
초당 속도=RPS 성능 향상을 위해 my.cnf [mysqld] 섹션에서 고려해야 할 제안 사항,
read_rnd_buffer_size=256K # from 128M to reduce handler_read_rnd_next RPS from 6 million +
innodb_io_capacity=1900 # from 200 to enable more of your SSD io capacity
thread_cache_size=100 # from 16 to reduce threads_created count of 24,136 in 8 hrs
aria_pagecache_buffer_size=64M # from 128M to conserve RAM, only 2 blocks used in 8 hrs
key_buffer_size=128M # from 1G to conserve RAM, 15M used was the High Water Mark
Aras와 Furkan, Rick James가 제안한 인덱스가 아직 생성되지 않은 경우 인덱스 관리를 통한 성능 향상을 위해 이 요청에 대한 도움이 필요하다는 의견을 게시하십시오.
언급URL : https://stackoverflow.com/questions/53526673/centos-7-whm-high-mysqlmariadb-cpu-usage-600
'source' 카테고리의 다른 글
| jQuery's ajaxSetup - GET 요청에 대해서만 기본 데이터를 추가하려고 합니다. (0) | 2023.08.25 |
|---|---|
| Powershell: 콘텐츠 가져오기 파이프라인에 대한 인코딩 설정 (0) | 2023.08.25 |
| Nodemon으로 시작 스크립트를 실행하는 방법 (0) | 2023.08.25 |
| 기본값 롤백 방법 Git (0) | 2023.08.20 |
| Swift에서 술어 사용 (0) | 2023.08.20 |