2017-11-20 15 views
1

16GB RAM & 코어 서버 1 대를 구입 했으므로 MY.cnf 파일을 최적화하지 않았습니다.MySQL 및 My.cnf를 16g 램 및 8 코어 CPU로 최적화 하시겠습니까? [동시 사용자 30-80 명, 최대치 200-300]

이 모든 최적화 작업은 새로운 것이므로 무엇을해야할지 모르겠습니다. 정상적인 시간에는 서버가 60-80 명의 동시 사용자를 보유하고 악의적 인 시간대에는 20-40 명의 사용자가 있으며, 때로는 다른 경우에 200-300 주위에 피크를 나타냅니다.

어떻게해야합니까?

>> MySQLTuner 1.7.4 - Major Hayden <[email protected]> 
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/ 
>> Run with '--help' for additional options and output filtering 

[--] Skipped version check for MySQLTuner script 
Please enter your MySQL administrative login: forge 
Please enter your MySQL administrative password: [OK] Currently running supporte                                        d MySQL version 5.7.20-0ubuntu0.16.04.1 
[OK] Operating on 64-bit architecture 

-------- Log file Recommendations ----------------------------------------------                                        -------------------- 
[--] Log file: /var/lib/mysql/crypto-boi.err(0B) 
[!!] Log file /var/lib/mysql/crypto-boi.err doesn't exist 
[!!] Log file /var/lib/mysql/crypto-boi.err isn't readable. 

-------- Storage Engine Statistics ---------------------------------------------                                        -------------------- 
[--] Status: +ARCHIVE +BLACKHOLE +CSV -FEDERATED +InnoDB +MEMORY +MRG_MYISAM +My                                        ISAM +PERFORMANCE_SCHEMA 
[--] Data in InnoDB tables: 514M (Tables: 66) 
[OK] Total fragmented tables: 0 

-------- Security Recommendations ----------------------------------------------                                        -------------------- 


-------- CVE Security Recommendations ------------------------------------------                                        -------------------- 
[OK] NO SECURITY CVE FOUND FOR YOUR VERSION 

-------- Performance Metrics ---------------------------------------------------                                        -------------------- 
[--] Up for: 4m 0s (49K q [205.421 qps], 286 conn, TX: 38M, RX: 7M) 
[--] Reads/Writes: 78%/22% 
[--] Binary logging is disabled 
[--] Physical Memory  : 15.7G 
[--] Max MySQL memory : 2.0G 
[--] Other process memory: 1.6G 
[--] Total buffers: 1.5G global + 2.0M per thread (214 max threads) 
[--] P_S Max memory usage: 72B 
[--] Galera GCache Max memory usage: 0B 
[OK] Maximum reached memory usage: 1.6G (9.95% of installed RAM) 
[OK] Maximum possible memory usage: 2.0G (12.54% of installed RAM) 
[OK] Overall possible memory usage with other process is compatible with memory available 
[OK] Slow queries: 0% (0/49K) 
[OK] Highest usage of available connections: 2% (6/214) 
[OK] Aborted connections: 0.35% (1/286) 
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance 
[!!] Query cache may be disabled by default due to mutex contention. 
[!!] Query cache efficiency: 0.0% (0 cached/37K selects) 
[OK] Query cache prunes per day: 0 
[OK] Sorts requiring temporary tables: 0% (0 temp sorts/283 sorts) 
[!!] Joins performed without indexes: 187 
[OK] Temporary tables created on disk: 4% (10 on disk/227 total) 
[OK] Thread cache hit rate: 97% (6 created/286 connections) 
[OK] Table cache hit rate: 75% (340 open/453 opened) 
[OK] Open file limit used: 0% (0/1K) 
[OK] Table locks acquired immediately: 100% (102 immediate/102 locks) 

-------- Performance schema ------------------------------------------------------------------------ 
[--] Memory used by P_S: 72B 
[--] Sys schema is installed. 

-------- ThreadPool Metrics ------------------------------------------------------------------------ 
[--] ThreadPool stat is disabled. 

-------- MyISAM Metrics ---------------------------------------------------------------------------- 
[!!] Key buffer used: 18.2% (48M used/268M cache) 
[OK] Key buffer size/total MyISAM indexes: 256.0M/43.0K 
[!!] Read Key buffer hit rate: 50.0% (6 cached/3 reads) 

-------- InnoDB Metrics ---------------------------------------------------------------------------- 
[--] InnoDB is enabled. 
[--] InnoDB Thread Concurrency: 0 
[OK] InnoDB File per table is activated 
[OK] InnoDB buffer pool/data size: 1.0G/514.4M 
[!!] Ratio InnoDB log file size/InnoDB Buffer pool size (9.375 %): 48.0M * 2/1.0G should be equal 25% 
[!!] InnoDB buffer pool <= 1G and Innodb_buffer_pool_instances(!=1). 
[--] Number of InnoDB Buffer Pool Chunk : 8 for 8 Buffer Pool Instance(s) 
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances 
[OK] InnoDB Read buffer efficiency: 99.82% (11564032 hits/ 11585189 total) 
[!!] InnoDB Write Log efficiency: 54.07% (3734 hits/ 6906 total) 
[OK] InnoDB log waits: 0.00% (0 waits/10640 writes) 

-------- AriaDB Metrics ---------------------------------------------------------------------------- 
[--] AriaDB is disabled. 

-------- TokuDB Metrics ---------------------------------------------------------------------------- 
[--] TokuDB is disabled. 

-------- XtraDB Metrics ---------------------------------------------------------------------------- 
[--] XtraDB is disabled. 

-------- RocksDB Metrics --------------------------------------------------------------------------- 
[--] RocksDB is disabled. 

-------- Spider Metrics ---------------------------------------------------------------------------- 
[--] Spider is disabled. 

-------- Connect Metrics --------------------------------------------------------------------------- 
[--] Connect is disabled. 

-------- Galera Metrics ---------------------------------------------------------------------------- 
[--] Galera is disabled. 

-------- Replication Metrics ----------------------------------------------------------------------- 
[--] Galera Synchronous replication: NO 
[--] No replication slave(s) for this server. 
[--] This is a standalone server. 

-------- Recommendations --------------------------------------------------------------------------- 
General recommendations: 
    Set up a Password for user with the following SQL statement (SET PASSWORD FOR 'user'@'SpecificDNSorIp' = PASSWORD('secure_password');) 
    Restrict Host for [email protected]% to [email protected] 
    MySQL started within last 24 hours - recommendations may be inaccurate 
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1 
    Adjust your join queries to always utilize indexes 
    Read this before changing innodb_log_file_size and/or innodb_log_files_in_group: 
Variables to adjust: 
    query_cache_size (=0) 
    query_cache_type (=0) 
    query_cache_limit (> 1M, or use smaller result sets) 
    join_buffer_size (> 256.0K, or always use indexes with joins) 
    innodb_log_file_size should be (=128M) if possible, so InnoDB total log files size equals to 25% of buffer pool size. 
    innodb_buffer_pool_instances (=1) 

가 여기에 내가 MySQL 데이터베이스 엔진은 InnoDB의 생각 내 my.cnf의

[mysqld_safe] 
socket   = /var/run/mysqld/mysqld.sock 
nice   = 0 

[mysqld] 
user   = mysql 
pid-file  = /var/run/mysqld/mysqld.pid 
socket   = /var/run/mysqld/mysqld.sock 
port   = 3306 
basedir   = /usr 
datadir   = /var/lib/mysql 
tmpdir   = /tmp 
lc-messages-dir = /usr/share/mysql 
skip-external-locking 
bind-address = * 
# 
max_connections   = 300 
key_buffer_size   = 256M 
read_buffer_size = 1M 
table_open_cache = 15000 
thread_cache_size = 384 
connect_timeout = 10 
interactive_timeout = 7000 
tmp_table_size = 256M 
max_heap_table_size = 256M 
query_cache_size = 0 
query_cache_type = 0 
innodb_buffer_pool_size = 1G 

# This replaces the startup script and checks MyISAM tables if needed 
# the first time they are touched 
myisam-recover-options = BACKUP 
#max_connections  = 100 
#table_cache   = 64 
#thread_concurrency  = 10 
# 
# * Query Cache Configuration 
# 
query_cache_limit  = 1M 
query_cache_size  = 32M 
# 
# 
expire_logs_days  = 10 
max_binlog_size = 100M 
default_password_lifetime = 0 
+0

16GB RAM입니까, 1GB입니까? –

+0

@RickJames 16GB – Edwin

답변

0

입니다 :

여기 내 mysqltuner.pl입니다. 내 경험에 비추어 볼 때, innodb_buffer_pool_size를 늘리면 mysql 성능이 훨씬 향상 될 것이고, 특히 16G 램을 사용하게 될 것이다. 서버가 MySQL을 위해 최선을 다하고 있습니다 경우

12G

까지이 값을 설정할 수 있습니다 여기에 당신은 InnoDB의 데이터 514M를 나는 종종 https://www.percona.com/blog/2013/09/20/innodb-performance-optimization-basics-updated/

+0

안녕하세요, 귀하의 답변을 주셔서 감사합니다, 서버는 MySQL에 전념하지 않습니다, 그러나이 일을하는 것이 좋습니다 무엇입니까? – Edwin

+0

db가 innodb 인 경우 innodb_buffer_pool_size를 더 큰 값으로 늘려야합니다. –

+0

buffer_pool은 이미 데이터 크기의 두 배입니다. 따라서 성능을 더 높이 지 않으면 성능이 향상되지 않습니다. InnoDB 버퍼 풀/데이터 크기 : 1.0G/514.4M을 참조하십시오. 그러나 데이터가 증가하면 buffer_pool을 _available_ RAM의 70 %까지 늘리십시오. –

0

에 따라 몇 가지 유용한 최적화 가이드 라인입니다. innodb 스토리지 요구 사항이 증가 할 때까지 그대로 두십시오.

#read_buffer_size=1M # disabled to allow default to serve your needs 
thread_cache_size=100 # from 384 to avoid OOM per V8 CAP at 100 threads_cached. 

종료/재시작 :

귀하의 my.cnf

는/INI로 변경해야합니다.

당신이 적어도 24 시간 동안 바쁘다면 현재 MySQLTuner 보고서를 다시 게시하십시오.

4 분 안에 귀하의 정보는 우리가 하루 종일 또는 일주일 후에 볼 수있는 것과 비교가되지 않습니다.