MariaDB 성능
저는 센토스 7과 10.1.8-MariaDB와 함께 일하고 있습니다.시스템이 느리다는 느낌을 받을 때도 있습니다.오늘 느린 쿼리를 확인하면서 업데이트 쿼리가 3~4초 이상 걸리는 단계보다 정말 얇거나 보통 빠른 것을 보았습니다.
데이터베이스가 설치된 전용 서버에서만 실행되고 있습니다.4GB 램을 탑재했습니다.
여기 메모리가 있습니다.
cat /proc/meminfo
MemTotal: 3883016 kB
MemFree: 156380 kB
MemAvailable: 293708 kB
Buffers: 0 kB
Cached: 288140 kB
SwapCached: 171352 kB
Active: 2546636 kB
Inactive: 1023020 kB
Active(anon): 2391628 kB
Inactive(anon): 905344 kB
Active(file): 155008 kB
Inactive(file): 117676 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 2113532 kB
SwapFree: 1334248 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 3241692 kB
Mapped: 20172 kB
Shmem: 15456 kB
Slab: 87216 kB
SReclaimable: 67176 kB
SUnreclaim: 20040 kB
KernelStack: 3200 kB
PageTables: 12088 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 4055040 kB
Committed_AS: 4645884 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 160244 kB
VmallocChunk: 34359568380 kB
HardwareCorrupted: 0 kB
AnonHugePages: 2045952 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 59328 kB
DirectMap2M: 4134912 kB
제 .cnf입니다.
my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[mysqld]
bind-address = 0.0.0.0
#tmp per carregar:
wait_timeout=108000
max_allowed_packet=40960M
[client-server]
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[mysqld]
# 20151031
# charset
# init_connect=.SET collation_connection = utf8_unicode_ci.
# init_connect=.SET NAMES utf8.
character-set-server=utf8
collation-server=utf8_unicode_ci
open_files_limit = 8192
max_connections = 200
slow-query-log = 1
slow-query-log-file = /var/log/mariadb/mysql-slow.log
long_query_time = 1
#performance
# innodb_buffer_pool_size default: 134217728 (128MB) - 60 o 70% memoria
# 2048MB - 70% = 6012954214 (5734MB)
innodb_buffer_pool_size=3GB
innodb_buffer_pool_instances=3
thread_cache_size=200
#query_cache_size
query_cache_type = 1
query_cache_limit = 1M
query_cache_min_res_unit = 2k
query_cache_size = 80M
#LOGS
#log-error
log_warnings = 3
log-error = /var/log/mariadb/mariadb.log
느린 쿼리 로그:
# User@Host: swb[swb] @ [192.168.50.65]
# Thread_id: 23002274 Schema: swb QC_hit: No
# Query_time: 2.000710 Lock_time: 0.000209 Rows_sent: 0 Rows_examined: 1
# Rows_affected: 1
SET timestamp=1474793382;
UPDATE instalaciones
SET
fSincro = now(),
tHotspot='ACTIVO'
WHERE tRouterSerial = '558104409B1B';
# User@Host: swb[swb] @ [192.168.50.65]
# Thread_id: 22499243 Schema: swb QC_hit: No
# Query_time: 1.909591 Lock_time: 0.000041 Rows_sent: 0 Rows_examined: 0
# Rows_affected: 1
SET timestamp=1474636304;
INSERT INTO redirect(tRedirect,fFecha) VALUES ('ff0005a8c8f2c409a1a5a58fab6d16b455d09258',now());
테이블 정의:
CREATE TABLE `instalaciones` (
`idInstalacion` int(10) unsigned NOT NULL AUTO_INCREMENT,
`idCliente` int(10) unsigned DEFAULT NULL,
`tRouterSerial` varchar(50) DEFAULT NULL,
`tFacebookPage` varchar(256) DEFAULT NULL,
`tidFacebook` varchar(64) DEFAULT NULL,
`tNombre` varchar(128) DEFAULT NULL,
`tMensaje` varchar(128) DEFAULT NULL,
`tWebPage` varchar(128) DEFAULT NULL,
`tDireccion` varchar(128) DEFAULT NULL,
`tPoblacion` varchar(128) DEFAULT NULL,
`tProvincia` varchar(64) DEFAULT NULL,
`tCodigoPosta` varchar(8) DEFAULT NULL,
`tLatitud` decimal(15,12) DEFAULT NULL,
`tLongitud` decimal(15,12) DEFAULT NULL,
`tSSID1` varchar(40) DEFAULT NULL,
`tSSID2` varchar(40) DEFAULT NULL,
`tSSID2_Pass` varchar(40) DEFAULT NULL,
`fSincro` datetime DEFAULT NULL,
`tEstado` varchar(10) DEFAULT NULL,
`tHotspot` varchar(10) DEFAULT NULL,
`fAlta` datetime DEFAULT NULL,
PRIMARY KEY (`idInstalacion`),
UNIQUE KEY `tRouterSerial` (`tRouterSerial`),
KEY `idInstalacion` (`idInstalacion`),
KEY `idCliente` (`idCliente`)
) ENGINE=InnoDB AUTO_INCREMENT=1611 DEFAULT CHARSET=utf8;
CREATE TABLE `redirect` (
`tRedirect` varchar(80) DEFAULT NULL,
`fFecha` datetime DEFAULT NULL,
KEY `itRedirect` (`tRedirect`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
이것은 설명입니다.
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE instalaciones range tRouterSerial tRouterSerial 153 NULL 1 "Using where"
id select_type table type possible_keys key key_len ref rows Extra
1 INSERT redirect ALL NULL NULL NULL NULL NULL NULL
이는 표 상태를 보여줍니다.
Name,Engine,Version,Row_format,Rows,Avg_row_length,Data_length,Max_data_length,Index_length,Data_free,Auto_increment,Create_time,Update_time,Check_time,Collation,Checksum,Create_options,Comment
instalaciones,InnoDB,10,Compact,1401,339,475136,0,131072,0,1611,"2016-06-28 22:20:45",NULL,NULL,utf8_general_ci,NULL,,
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
redirect InnoDB 10 Compact 30766 102 3162112 0 3162112 13631488 NULL "2016-02-22 09:57:20" NULL NULL utf8_general_ci NULL
이 느린 쿼리를 도와줄 수 있는 사람?
정말 고마워.
업데이트됨:
오늘 쿼리 양식이 느립니다.
# User@Host: swb[swb] @ [192.168.50.65]
# Thread_id: 23552588 Schema: swb QC_hit: No
# Query_time: 1.279738 Lock_time: 0.000115 Rows_sent: 0 Rows_examined: 1
# Rows_affected: 1
SET timestamp=1474975258;
UPDATE instalaciones
SET
fSincro = now(),
tHotspot='ACTIVO'
WHERE tRouterSerial = '558104B41762';
# Time: 160927 18:40:30
어제의 mariadb.log입니다. (오늘은 없음)
2016-09-26 12:53:49 140053608847104 [Warning] Aborted connection 23132533 to db: 'unconnected' user: 'SWB_BDA' host: '192.168.50.65' (Unknown error)
2016-09-26 12:53:49 140053608249088 [Warning] Aborted connection 23132521 to db: 'swb' user: 'SWB_BDA' host: '192.168.50.65' (Unknown error)
아마도 스와핑 때문에 부진한 것 같습니다.사용 가능한 RAM을 오버플로할 위험이 있습니다.어쨌든...
의 경우 3GBinnodb_buffer_pool_size
4GB 서버에는 들어가지 않습니다.다음을 변경할 것을 권장합니다.
max_allowed_packet=40960M --> 50M
innodb_buffer_pool_size=3GB --> 1500M
innodb_buffer_pool_instances=3 --> 1
thread_cache_size=200 --> 10
query_cache_size = 80M --> 40M
데이터베이스의 크기가 얼마나 됩니까?데이터베이스 서버용 4G mem은 매우 작게 들립니다.오류 로그를 확인했습니까?vmstat 또는 이와 유사한 기능을 통해 쿼리 속도가 느릴 때 어떤 일이 일어나고 있는지 확인할 수 있습니다.제공된 예는 다른 일이 없을 경우 속도가 느려서는 안 됩니다.
언급URL : https://stackoverflow.com/questions/39690644/mariadb-performance
'programing' 카테고리의 다른 글
C89 표준과 함께 M_PI 사용 (0) | 2023.09.21 |
---|---|
말로크는 C에서 얼마나 클 수 있습니까? (0) | 2023.09.21 |
MySQL 보기가 일반 쿼리보다 빠릅니까? (0) | 2023.09.21 |
XML 파일을 다른 XML 파일로 가져올 수 있습니까? (0) | 2023.09.16 |
jquery로 클릭한 링크의 href를 얻는 방법? (0) | 2023.09.16 |