Mysql
 sql >> डेटाबेस >  >> RDS >> Mysql

MySQLTunner टूल के साथ MySQL/MariaDB प्रदर्शन को ऑप्टिमाइज़ करें

MySQLTunner एक पर्ल टूल है जिसकी मदद से आप अपने MariaDB/MySQL डेटाबेस सर्वर को ट्यून करने में मदद करेंगे। यह सर्वर के कई मापदंडों की जांच करता है, उपयोगकर्ता पासवर्ड की पुष्टि करता है, अनाम उपयोगकर्ताओं के लिए जांच करता है, असुरक्षित पासवर्ड (जहां उदाहरण के लिए पासवर्ड उपयोगकर्ता नाम है), ज्ञात सीवीई कमजोरियों आदि की जांच करता है।

टूल को चलाने का पहला चरण आधिकारिक वेबसाइट https://github.com/major/MySQLTuner-perl

से स्क्रिप्ट फ़ाइल डाउनलोड करना है।
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
wget https://github.com/major/MySQLTuner-perl/raw/master/vulnerabilities.csv

स्क्रिप्ट चलाने के लिए मूल कमांड है:

perl mysqltuner.pl

कमजोरियों की जांच करने के लिए, आपको भेद्यता.सीएसवी फ़ाइल डाउनलोड करनी होगी और कमांड निष्पादित करनी होगी:

perl mysqltuner.pl --cvefile=vulnerabilities.csv

परीक्षण सर्वर से आउटपुट का एक उदाहरण:

[root@web /]# perl mysqltuner.pl --cvefile=vulnerabilities.csv

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

[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 10.6.5-MariaDB
[OK] Operating on 64-bit architecture

-------- Log file Recommendations ------------------------------------------------------------------
[OK] Log file /var/log/mysqld.log exists
[--] Log file: /var/log/mysqld.log(69K)
[OK] Log file /var/log/mysqld.log is not empty
[OK] Log file /var/log/mysqld.log is smaller than 32 Mb
[OK] Log file /var/log/mysqld.log is readable.
[!!] /var/log/mysqld.log contains 394 warning(s).
[!!] /var/log/mysqld.log contains 49 error(s).
[--] 22 start(s) detected in /var/log/mysqld.log
[--] 1) 2022-01-08 16:04:41 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 2) 2022-01-04 12:20:12 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 3) 2021-12-27 17:21:20 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 4) 2021-12-11 15:39:01 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 5) 2021-12-11 14:47:28 0 [Note] /usr/sbin/mysqld: ready for connections.
[--] 6) 2021-12-11 14:47:22 0 [Note] /usr/sbin/mysqld: ready for connections.
-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE
[--] Data in Aria tables: 32.0K (Tables: 1)
[--] Data in MEMORY tables: 0B (Tables: 40)
[--] Data in MyISAM tables: 1.3G (Tables: 34)
[--] Data in InnoDB tables: 217.2M (Tables: 31)
[OK] Total fragmented tables: 0

-------- Analysis Performance Metrics --------------------------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.

-------- Views Metrics -----------------------------------------------------------------------------

-------- Triggers Metrics --------------------------------------------------------------------------

-------- Routines Metrics --------------------------------------------------------------------------

-------- Security Recommendations ------------------------------------------------------------------
[OK] All database users have passwords assigned
-------- CVE Security Recommendations --------------------------------------------------------------
[OK] NO SECURITY CVE FOUND FOR YOUR VERSION

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 4d 19h 31m 2s (18M q [45.289 qps], 550K conn, TX: 53G, RX: 3G)
[--] Reads / Writes: 90% / 10%
[--] Binary logging is disabled
[--] Physical Memory     : 4.0G
[--] Max MySQL memory    : 38.3G
[--] Other process memory: 0B
[--] Total buffers: 305.0M global + 259.7M per thread (150 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Slow queries: 0% (33/18M)
[OK] Highest usage of available connections: 76% (114/150)
[OK] Aborted connections: 0.02%  (86/550353)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[OK] Query cache is disabled by default due to mutex contention on multiprocessor machines.
[OK] Sorts requiring temporary tables: 0% (227 temp sorts / 3M sorts)
[!!] Joins performed without indexes: 197183
[!!] Temporary tables created on disk: 56% (990K on disk / 1M total)
[OK] Thread cache hit rate: 99% (645 created / 550K connections)
[OK] Table cache hit rate: 95% (22M hits / 24M requests)
[OK] Open file limit used: 8% (1K/16K)
[OK] Table locks acquired immediately: 99% (17M immediate / 17M locks)

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

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is enabled.
[--] Thread Pool Size: 2 thread(s).
[--] Using default value is good enough for your version (10.6.5-MariaDB)

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 61.8% (9.9M used / 16.0M cache)
[OK] Key buffer size / total MyISAM indexes: 16.0M/152.4M
[OK] Read Key buffer hit rate: 100.0% (768M cached / 379K reads)
[!!] Write Key buffer hit rate: 54.4% (3M cached / 1M writes)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[OK] InnoDB File per table is activated
[!!] InnoDB buffer pool / data size: 128.0M/217.2M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (75 %): 96.0M * 1/128.0M should be equal to 25%
[--] Number of InnoDB Buffer Pool Chunk : 1 for 1 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.98% (499634018 hits/ 499732161 total)
[!!] InnoDB Write Log efficiency: 270.94% (232636 hits/ 85863 total)
[OK] InnoDB log waits: 0.00% (0 waits / 318499 writes)

-------- Aria Metrics ------------------------------------------------------------------------------
[--] Aria Storage Engine is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/712.0K
[OK] Aria pagecache hit rate: 95.4% (18M cached / 860K reads)

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

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

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

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: MIXED
[--] XA support enabled: ON
[--] Semi synchronous replication Master: OFF
[--] Semi synchronous replication Slave: OFF
[--] This is a standalone server

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Check warning line(s) in /var/log/mysqld.log file
    Check error line(s) in /var/log/mysqld.log file
    Reduce your overall MySQL memory footprint for system stability
    Dedicate this server to your database for highest performance.
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
    We will suggest raising the 'join_buffer_size' until JOINs not using indexes are found.
             See https://dev.mysql.com/doc/internals/en/join-buffer-size.html
             (specially the conclusions at the bottom of the page).
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries which have no LIMIT clause
    Performance schema should be activated for better diagnostics
    Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: https://bit.ly/2TcGgtU
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    join_buffer_size (> 1.0M, or always use indexes with JOINs)
    tmp_table_size (> 16M)
    max_heap_table_size (> 16M)
    performance_schema = ON enable PFS
    key_buffer_size (~ 10M)

सुझावों . को ध्यान से देखें अनुभाग और आवश्यक कार्रवाई करें। MySQL/MariaDB विकल्प /etc/my.cnf फ़ाइल में संग्रहीत हैं। आप इस फ़ाइल को vi या nano जैसे संपादक से संपादित कर सकते हैं:

nano /etc/my.cnf

अंत में, फ़ाइल को सहेजें और MySQL सर्वर को पुनरारंभ करें:

service mysqld restart

  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. MySQL को --स्किप-अनुदान-तालिकाओं के साथ कैसे प्रारंभ करें?

  2. मैं MySQL में चालू माह के पहले दिन और वर्तमान दिन के बीच कैसे चयन करूं?

  3. MySQL में UNION का उपयोग करते समय "ERROR 1250 (42000):किसी एक चयन से तालिका '...' को वैश्विक ORDER खंड में उपयोग नहीं किया जा सकता है" ठीक करें

  4. MySQL में FIELD () और FIND_IN_SET () के बीच अंतर

  5. 9 वास्तव में उपयोगी MySQL दिनांक फ़ंक्शन जो याद रखने में आसान हैं