mysql调谐器-优化表和cnf

时间:2019-05-05 19:58:29

标签: mysql sql mysqltuner

我想优化数据库并决定通过运行mysqltuner进行启动,但是它显示了很多错误,我不知道该怎么办,我不建议根据服务器设置指定什么配置< / p>

  • 我在Linode上的目标是:

       4    GB RAM
       2    CPU Cores
       80   GB SSD Storage
       4    TB Transfer
       40   Gbps Network In
       4000 Mbps Network Out
    

我启动我的mysql调谐器:

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

-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: /var/log/mysql/mysqld.log(0B)
[OK] Log file /var/log/mysql/mysqld.log exists
[OK] Log file /var/log/mysql/mysqld.log is readable.
[!!] Log file /var/log/mysql/mysqld.log is empty
[OK] Log file /var/log/mysql/mysqld.log is smaller than 32 Mb
[OK] /var/log/mysql/mysqld.log doesn't contain any warning.
[OK] /var/log/mysql/mysqld.log doesn't contain any error.
[--] 0 start(s) detected in /var/log/mysql/mysqld.log
[--] 0 shutdown(s) detected in /var/log/mysql/mysqld.log

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

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

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] There is no basic password file list!

-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 34d 20h 2m 32s (117M q [38.983 qps], 1M conn, TX: 1265G, RX: 20G)
[--] Reads / Writes: 99% / 1%
[--] Binary logging is disabled
[--] Physical Memory     : 3.9G
[--] Max MySQL memory    : 4.1G
[--] Other process memory: 150.6M
[--] Total buffers: 3.5G global + 1.1M per thread (151 max threads)
[--] P_S Max memory usage: 403M
[--] Galera GCache Max memory usage: 0B
[!!] Maximum reached memory usage: 4.0G (104.78% of installed RAM)
[!!] Maximum possible memory usage: 4.1G (106.26% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (8K/117M)
[OK] Highest usage of available connections: 65% (99/151)
[OK] Aborted connections: 0.04%  (465/1327070)
[!!] 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.
[OK] Query cache efficiency: 49.1% (54M cached / 110M selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (9 temp sorts / 3M sorts)
[!!] Joins performed without indexes: 122027
[OK] Temporary tables created on disk: 16% (9M on disk / 57M total)
[OK] Thread cache hit rate: 99% (6K created / 1M connections)
[OK] Table cache hit rate: 73% (366 open / 499 opened)
[OK] Open file limit used: 0% (47/10K)
[OK] Table locks acquired immediately: 100% (23M immediate / 23M locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Memory used by P_S: 403.9M
[--] Sys schema isn't installed.

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

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.3% (1M used / 8M cache)
[OK] Key buffer size / total MyISAM indexes: 8.0M/101.0K
[OK] Read Key buffer hit rate: 100.0% (77M cached / 4 reads)
[!!] Write Key buffer hit rate: 0.0% (41M cached / 30 writes)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 1.0G/766.8M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (50 %): 256.0M * 2/1.0G should be equal 25%
[!!] InnoDB buffer pool <= 1G and Innodb_buffer_pool_instances(!=1).
[--] InnoDB Buffer Pool Chunk Size not used or defined in your version
[OK] InnoDB Read buffer efficiency: 100.00% (27261013604 hits/ 27261058993 total)
[!!] InnoDB Write Log efficiency: 81.25% (48468 hits/ 59653 total)
[OK] InnoDB log waits: 0.00% (0 waits / 108121 writes)


-------- 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:
    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
    Adjust your join queries to always utilize indexes
    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: 
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    query_cache_size (=0)
    query_cache_type (=0)
    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)

还有my.cnf

 datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    bind-address = 127.0.0.1
    ignore-db-dir = lost+found
    explicit_defaults_for_timestamp = 1
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0

    # Recommended in standard MySQL setup
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

    query_cache_limit       = 1048576
    query_cache_size        = 2684354560
    query_cache_type        = 1

    innodb_flush_method     = O_DIRECT
    innodb_file_per_table   = 1
    innodb_buffer_pool_size = 1024M
    innodb_log_file_size = 256M
    innodb_flush_log_at_trx_commit = 2

    long_query_time=5
    slow_query_log=1
    slow_query_log_file= /var/log/mysql/log-slow-queries.log

    # Set unicode by default
    character-set-server  = utf8mb4
    collation-server      = utf8mb4_general_ci

    [mysqld_safe]
    log-error=/var/log/mysql/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid

如何根据此信息优化文件?

为什么要问,因为所有表都有索引,但是请求的处理速度很慢,这会影响网站的访问和可用性

0 个答案:

没有答案