• 22-04-2022, 13:44:34
    #1
    Merhaba, sunucuda mysql tüm rami sömürüyor. Cache vs hepsi aktif ama düşmedi birtürlü. mysqltuner ile çıktı aldım biraz araştırma yaptım mycnf optimizasyonu yapabileceğimi öğrendim ama yaparken sunucuyu uçurmak istemiyorum. Yardımcı olabilir misiniz?

    >>  MySQLTuner 1.9.8
             * Jean-Marie Renouard <jmrenouard@gmail.com>
             * Major Hayden <major@mhtx.net>
     >>  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
    [!!] Your MySQL version 5.5.68-MariaDB is EOL software!  Upgrade soon!
    [OK] Operating on 64-bit architecture
    
    -------- Log file Recommendations ----------------------------------------------                                           --------------------
    [OK] Log file /var/log/mariadb/mariadb.log exists
    [--] Log file: /var/log/mariadb/mariadb.log(24K)
    [OK] Log file /var/log/mariadb/mariadb.log is not empty
    [OK] Log file /var/log/mariadb/mariadb.log is smaller than 32 Mb
    [OK] Log file /var/log/mariadb/mariadb.log is readable.
    [OK] /var/log/mariadb/mariadb.log doesn't contain any warning.
    [OK] /var/log/mariadb/mariadb.log doesn't contain any error.
    [--] 16 start(s) detected in /var/log/mariadb/mariadb.log
    [--] 1) 220421 18:45:04 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 2) 220421 18:16:32 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 3) 220421 16:57:29 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 4) 220421 16:27:12 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 5) 220421 16:08:50 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 6) 220421 16:06:50 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 7) 220421 15:33:30 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 8) 220421 15:17:03 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 9) 220421 15:07:59 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 10) 220421 14:49:17 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 15 shutdown(s) detected in /var/log/mariadb/mariadb.log
    [--] 1) 220421 18:44:51 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 2) 220421 18:16:19 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 3) 220421 16:57:17 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 4) 220421 16:27:00 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 5) 220421 16:08:39 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 6) 220421 16:06:39 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 7) 220421 15:33:18 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 8) 220421 15:16:53 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 9) 220421 15:07:46 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 10) 220421 14:49:05 [Note] /usr/libexec/mysqld: Shutdown complete
    
    -------- Storage Engine Statistics ---------------------------------------------                                           --------------------
    [--] Status: +ARCHIVE +Aria +BLACKHOLE +CSV +FEDERATED +InnoDB +MEMORY +MRG_MYIS                                           AM +MyISAM +PERFORMANCE_SCHEMA
    [--] Data in MyISAM tables: 163.9M (Tables: 259)
    [--] Data in InnoDB tables: 984.8M (Tables: 586)
    [OK] Total fragmented tables: 0
    
    -------- Analysis Performance Metrics --------------------------------------------------------------
    [--] innodb_stats_on_metadata: ON
    [!!] Stat are updated during querying INFORMATION_SCHEMA.
    
    -------- Views Metrics -----------------------------------------------------------------------------
    
    -------- Triggers Metrics --------------------------------------------------------------------------
    
    -------- Routines Metrics --------------------------------------------------------------------------
    
    -------- CVE Security Recommendations --------------------------------------------------------------
    [--] Skipped due to --cvefile option undefined
    
    -------- Performance Metrics -----------------------------------------------------------------------
    [--] Up for: 15h 48m 15s (22M q [394.979 qps], 201K conn, TX: 168G, RX: 21G)
    [--] Reads / Writes: 93% / 7%
    [--] Binary logging is disabled
    [--] Physical Memory     : 3.0G
    [--] Max MySQL memory    : 987.0M
    [--] Other process memory: 0B
    [--] Total buffers: 416.0M global + 3.8M per thread (151 max threads)
    [--] P_S Max memory usage: 0B
    [--] Galera GCache Max memory usage: 0B
    [OK] Maximum reached memory usage: 491.6M (16.00% of installed RAM)
    [OK] Maximum possible memory usage: 987.0M (32.13% of installed RAM)
    [OK] Overall possible memory usage with other process is compatible with memory available
    [OK] Slow queries: 0% (269/22M)
    [OK] Highest usage of available connections: 13% (20/151)
    [OK] Aborted connections: 0.00%  (1/201738)
    [!!] 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: 1% (37K temp sorts / 3M sorts)
    [!!] Joins performed without indexes: 549
    [!!] Temporary tables created on disk: 72% (1M on disk / 2M total)
    [!!] Thread cache is disabled
    [OK] Table cache hit rate: 21% (400 hits / 1K requests)
    [!!] table_definition_cache(400) is lower than number of tables(948)
    [OK] Open file limit used: 6% (66/962)
    [OK] Table locks acquired immediately: 99% (26M immediate / 26M locks)
    
    -------- Performance schema ------------------------------------------------------------------------
    [!!] Performance_schema should be activated.
    [--] Sys schema isn't installed.
    
    -------- ThreadPool Metrics ------------------------------------------------------------------------
    [--] ThreadPool stat is disabled.
    
    -------- MyISAM Metrics ----------------------------------------------------------------------------
    [!!] Key buffer used: 22.7% (29.0M used / 128.0M cache)
    [OK] Key buffer size / total MyISAM indexes: 128.0M/60.6M
    [OK] Read Key buffer hit rate: 99.9% (19M cached / 12K reads)
    [OK] Write Key buffer hit rate: 99.1% (44K cached / 43K writes)
    
    -------- InnoDB Metrics ----------------------------------------------------------------------------
    [--] InnoDB is enabled.
    [--] InnoDB Thread Concurrency: 0
    [!!] InnoDB File per table is not activated
    [!!] InnoDB buffer pool / data size: 128.0M/984.8M
    [!!] Ratio InnoDB log file size / InnoDB Buffer pool size (7.8125 %): 5.0M * 2/128.0M should be equal to 25%
    [OK] InnoDB buffer pool instances: 1
    [--] InnoDB Buffer Pool Chunk Size not used or defined in your version
    [OK] InnoDB Read buffer efficiency: 99.91% (14314330851 hits/ 14326561852 total)
    [!!] InnoDB Write Log efficiency: 62.65% (2257834 hits/ 3604134 total)
    [OK] InnoDB log waits: 0.00% (0 waits / 1346300 writes)
    
    -------- Aria Metrics ------------------------------------------------------------------------------
    [--] Aria Storage Engine is enabled.
    [OK] Aria pagecache size / total Aria indexes: 128.0M/0B
    [OK] Aria pagecache hit rate: 100.0% (3B cached / 1M 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: STATEMENT
    [--] XA support enabled: ON
    [--] Semi synchronous replication Master: Not Activated
    [--] Semi synchronous replication Slave: Not Activated
    [--] This is a standalone server
    
        MySQL was started within the last 24 hours - recommendations may be inaccurate
        Enable the slow query log to troubleshoot bad queries
        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
        Set thread_cache_size to 4 as a starting value
        Performance schema should be activated for better diagnostics
        Consider installing Sys schema from https://github.com/FromDual/mariadb-sys for MariaDB
        For MySQL 5.6.2 and lower, Max combined innodb_log_file_size should have a ceiling of (4096MB / log files in group) - 1MB.
        Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: https://bit.ly/2TcGgtU
    Variables to adjust:
        SET innodb_stats_on_metadata = OFF
        skip-name-resolve=1
        join_buffer_size (> 128.0K, or always use indexes with JOINs)
        tmp_table_size (> 16M)
        max_heap_table_size (> 16M)
        thread_cache_size (start at 4)
        table_definition_cache(400) > 948 or -1 (autosizing if supported)
        performance_schema=ON
        key_buffer_size (~ 30M)
        innodb_file_per_table=ON
        innodb_buffer_pool_size (>= 984.8M) if possible.
        innodb_log_file_size should be (=16M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.
  • 22-04-2022, 13:51:32
    #2
    my.cnf için her zaman yedekli çalışmanızı öneririm. ram kullanmasının sebebi ya yüksek miktarda yoğunluk var ya da saldırı altındasınız ya da my.cnf ayarlarınız iyi değil.
  • 22-04-2022, 13:58:03
    #3
    Zergi adlı üyeden alıntı: mesajı görüntüle
    my.cnf için her zaman yedekli çalışmanızı öneririm. ram kullanmasının sebebi ya yüksek miktarda yoğunluk var ya da saldırı altındasınız ya da my.cnf ayarlarınız iyi değil.
    ilk defa yapacağım nano lazımmış onu kurdum şimdi yedek almayı araştırıyorum hocam, vps de şuan yoğunluk yok ama mysql ram ve cpu olarak maksimumda
  • 22-04-2022, 14:03:03
    #4
    Yedek alıp düzenlerseniz, bi sıkıntı olduğunda yedeği geri yerine koyduğunuzda sıkıntı yaşamazsınız.
    Ama her ne kadar tuning yapsanızda sağlam bir query optimizasyonu yapmadığınız sürece hepsi nafile kalabilir.
    Monitoring araçları kullanarak olanı biteni anlayıp buna göre müdahale de edebilirsiniz. Mesela Newrelic diye bir araç var, normalde ücretli ama sunucuya kurup 1 ay ücretsiz monitoring yapabilirsiniz.
  • 22-04-2022, 15:06:54
    #5
    özel yazılım ise, n+1 sorgulardan kaçının. n+1 sorgular aşırı cpu kullanımına neden oluyor.
    birebir başıma geldi ordan biliyorum. bir tablodan sipariş bilgilerini çekiyordum. 1600 küsür satır.
    foreach ile dönerken siparişi veren müşteri, ürün, ürün detay, sipariş detay gibi ek sorgular gerekiyor.
    tabi foreach döndükçe x4 sorgu gidiyor. cpu %68lere vuruyordu.
    n+1 soruınunu çözünce max %5 görüyor aynı sayfa güncel olarak
  • 22-04-2022, 15:25:06
    #6
    ebasit adlı üyeden alıntı: mesajı görüntüle
    özel yazılım ise, n+1 sorgulardan kaçının. n+1 sorgular aşırı cpu kullanımına neden oluyor.
    birebir başıma geldi ordan biliyorum. bir tablodan sipariş bilgilerini çekiyordum. 1600 küsür satır.
    foreach ile dönerken siparişi veren müşteri, ürün, ürün detay, sipariş detay gibi ek sorgular gerekiyor.
    tabi foreach döndükçe x4 sorgu gidiyor. cpu %68lere vuruyordu.
    n+1 soruınunu çözünce max %5 görüyor aynı sayfa güncel olarak
    wordpress kullanıyorum hocam o şekilde ekstra bir sorguda yapmıyorum aslında site çok hızlı ama kaynak kullanımına baktığımda baya yüksek
  • 12-05-2022, 10:35:18
    #7
    rdeniz adlı üyeden alıntı: mesajı görüntüle
    wordpress kullanıyorum hocam o şekilde ekstra bir sorguda yapmıyorum aslında site çok hızlı ama kaynak kullanımına baktığımda baya yüksek
    paylaşımlı hostingten çıkıp ufak bir vps'e geçin