CloudBT CloudBT
  • 18-10-2018, 16:10:50
    #1
    Öncelikle ilginiz için teşekkürler.

    cloud server, 2 vCPU, 2GB ram, Centos 7 OS, Vesta Panel kurulu web servera sahibim.
    300k dan fazla db kayıta sahip, MyIsam tek tablo var. Partition ile veritabanını 100 parçaya bölümlendirmiş durumdayım. Her sorguda 3k kayıt arasından sonuç döndürüyor. Sorguları optimize ettim. Ziyaretçi anlık 5-10 arası. Her ziyarette sadece 1 adet mysql bağlantısı ve sorgusu yapılmakta.
    Ama mysqld CPU 100%-200% lerde takılı kalıyor.

    Konfigürasyon dosyası aşağıdaki gibi. MysqlTuner bilgileri de aşağıdaki gibidir.
    Nasıl bir ayar yapmalıyım konf. dosyasında tecrübeli arkadaşlar yardım ederse sevinirim.

    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    symbolic-links=0
    
    skip-external-locking
    key_buffer_size = 16K
    max_allowed_packet = 1M
    sort_buffer_size = 64K
    read_buffer_size = 256K
    read_rnd_buffer_size = 256K
    net_buffer_length = 2K
    thread_stack = 240K
    
    
    table_open_cache = 64
    thread_cache_size = 4
    
    #innodb_use_native_aio = 0
    innodb_file_per_table
    
    max_connections=10
    max_user_connections=10
    wait_timeout=10
    interactive_timeout=10
    long_query_time=5
    
    #slow_query_log=1
    #slow_query_log_file=/var/log/mysql-slow-queries.log
    
    [mysqld_safe]
    log-error=/var/log/mariadb/mariadb.log
    pid-file=/var/run/mariadb/mariadb.pid
    
    #
    # include all files from the config directory
    #
    !includedir /etc/my.cnf.d



     >>  MySQLTuner 1.7.13 - Major Hayden <major@mhtx.net>
     >>  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
    [OK] Currently running supported MySQL version 5.5.60-MariaDB
    [OK] Operating on 64-bit architecture
    
    -------- Log file Recommendations ------------------------------------------------------------------
    [--] Log file: /var/log/mariadb/mariadb.log(1M)
    [OK] Log file /var/log/mariadb/mariadb.log exists
    [OK] Log file /var/log/mariadb/mariadb.log is readable.
    [OK] Log file /var/log/mariadb/mariadb.log is not empty
    [OK] Log file /var/log/mariadb/mariadb.log is smaller than 32 Mb
    [!!] /var/log/mariadb/mariadb.log contains 66 warning(s).
    [!!] /var/log/mariadb/mariadb.log contains 18981 error(s).
    [--] 21 start(s) detected in /var/log/mariadb/mariadb.log
    [--] 1) 181018 12:14:52 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 2) 181018 12:10:22 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 3) 181018 12:07:36 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 4) 181018 10:26:02 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 5) 181018  9:38:34 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 6) 181018  9:36:58 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 7) 181018  9:27:42 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 8) 181018  9:27:31 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 9) 181018  9:13:12 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 10) 181018  9:12:36 [Note] /usr/libexec/mysqld: ready for connections.
    [--] 21 shutdown(s) detected in /var/log/mariadb/mariadb.log
    [--] 1) 181018 12:14:51 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 2) 181018 12:10:20 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 3) 181018 12:07:34 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 4) 181018 10:26:00 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 5) 181018  9:38:32 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 6) 181018  9:36:56 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 7) 181018  9:27:41 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 8) 181018  9:21:17 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 9) 181018  9:21:16 [Note] /usr/libexec/mysqld: Shutdown complete
    [--] 10) 181018  9:13:10 [Note] /usr/libexec/mysqld: Shutdown complete
    
    -------- Storage Engine Statistics -----------------------------------------------------------------
    [--] Status: +ARCHIVE +Aria +BLACKHOLE +CSV +FEDERATED +InnoDB +MEMORY +MRG_MYISAM +MyISAM +PERFORMANCE_SCHEMA
    [--] Data in MyISAM tables: 341.4M (Tables: 1)
    [--] Data in InnoDB tables: 480.0K (Tables: 15)
    [OK] Total fragmented tables: 0
    
    -------- Analysis Performance Metrics --------------------------------------------------------------
    [--] innodb_stats_on_metadata: ON
    [!!] Stat are updated during querying INFORMATION_SCHEMA.
    
    -------- Security Recommendations ------------------------------------------------------------------
    [OK] There are no anonymous accounts for any database users
    [OK] All database users have passwords assigned
    [!!] User 'admin_db2@%' does not specify hostname restrictions.
    [!!] User 'admin_db@%' does not specify hostname restrictions.
    [!!] User 'admin_default@%' does not specify hostname restrictions.
    [!!] There is no basic password file list!
    
    -------- CVE Security Recommendations --------------------------------------------------------------
    [--] Skipped due to --cvefile option undefined
    
    -------- Performance Metrics -----------------------------------------------------------------------
    [--] Up for: 40m 7s (14K q [5.946 qps], 7K conn, TX: 3M, RX: 11M)
    [--] Reads / Writes: 100% / 0%
    [--] Binary logging is disabled
    [--] Physical Memory     : 1.8G
    [--] Max MySQL memory    : 297.2M
    [--] Other process memory: 171.0M
    [--] Total buffers: 288.0M global + 944.0K per thread (10 max threads)
    [--] P_S Max memory usage: 0B
    [--] Galera GCache Max memory usage: 0B
    [OK] Maximum reached memory usage: 292.6M (15.92% of installed RAM)
    [OK] Maximum possible memory usage: 297.2M (16.17% of installed RAM)
    [OK] Overall possible memory usage with other process is compatible with memory available
    [OK] Slow queries: 0% (2/14K)
    [OK] Highest usage of available connections: 50% (5/10)
    [!!] Aborted connections: 7.18%  (550/7665)
    [!!] 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 / 6K selects)
    [OK] Query cache prunes per day: 0
    [!!] Sorts requiring temporary tables: 32% (2K temp sorts / 6K sorts)
    [OK] No joins without indexes
    [OK] Temporary tables created on disk: 0% (0 on disk / 19 total)
    [OK] Thread cache hit rate: 99% (7 created / 7K connections)
    [OK] Table cache hit rate: 750% (30 open / 4 opened)
    [OK] Open file limit used: 49% (511/1K)
    [OK] Table locks acquired immediately: 100% (674K immediate / 674K locks)
    
    -------- Performance schema ------------------------------------------------------------------------
    [--] Performance schema is disabled.
    [--] Memory used by P_S: 0B
    [--] Sys schema isn't installed.
    
    -------- ThreadPool Metrics ------------------------------------------------------------------------
    [--] ThreadPool stat is enabled.
    [--] Thread Pool Size: 2 thread(s).
    [--] Using default value is good enough for your version (5.5.60-MariaDB)
    
    -------- MyISAM Metrics ----------------------------------------------------------------------------
    [!!] Key buffer used: 18.8% (3K used / 16K cache)
    [!!] Key buffer size / total MyISAM indexes: 16.0K/197.0K
    
    -------- InnoDB Metrics ----------------------------------------------------------------------------
    [--] InnoDB is enabled.
    [--] InnoDB Thread Concurrency: 0
    [OK] InnoDB File per table is activated
    [OK] InnoDB buffer pool / data size: 128.0M/480.0K
    [!!] Ratio InnoDB log file size / InnoDB Buffer pool size (7.8125 %): 5.0M * 2/128.0M should be equal 25%
    [OK] InnoDB buffer pool instances: 1
    [--] InnoDB Buffer Pool Chunk Size not used or defined in your version
    [!!] InnoDB Read buffer efficiency: 70.30% (381 hits/ 542 total)
    [!!] InnoDB Write Log efficiency: 0% (1 hits/ 0 total)
    [OK] InnoDB log waits: 0.00% (0 waits / 1 writes)
    
    -------- AriaDB Metrics ----------------------------------------------------------------------------
    [--] AriaDB is enabled.
    [OK] Aria pagecache size / total Aria indexes: 128.0M/1B
    
    -------- 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
    
    -------- Recommendations ---------------------------------------------------------------------------
    General recommendations:
        Control warning line(s) into /var/log/mariadb/mariadb.log file
        Control error line(s) into /var/log/mariadb/mariadb.log file
        Restrict Host for user@% to user@SpecificDNSorIp
        MySQL was started within the last 24 hours - recommendations may be inaccurate
        Enable the slow query log to troubleshoot bad queries
        Reduce or eliminate unclosed connections and network issues
        Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
        Consider installing Sys schema from https://github.com/mysql/mysql-sys
        Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: http://bit.ly/2wgkDvS
    Variables to adjust:
        SET innodb_stats_on_metadata = OFF
        query_cache_size (=0)
        query_cache_type (=0)
        query_cache_limit (> 1M, or use smaller result sets)
        sort_buffer_size (> 64K)
        read_rnd_buffer_size (> 256K)
        key_buffer_size (> 197.0K)
        innodb_log_file_size should be (=16M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.
  • 30-10-2018, 11:07:55
    #2
    Selamlar,

    Veritabanına gönderilen sorguyu da ekler misiniz.

    Sorgu rapor sorgusu gibi matematiksel işlemler yapıyor ise yüksek CPU kullanımı normal bir durum. Cache'in yaparak kullanıcılara önden hesaplanmış verileri sunabilirsiniz her istekte yeniden hesaplamak yerine.

    İyi çalışmalar.