Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
优化Mysql&;My.cnf至16g Ram&;8核CPU?[30-80个并发用户,峰值为200-300]_Mysql_Optimization_Laravel Forge - Fatal编程技术网

优化Mysql&;My.cnf至16g Ram&;8核CPU?[30-80个并发用户,峰值为200-300]

优化Mysql&;My.cnf至16g Ram&;8核CPU?[30-80个并发用户,峰值为200-300],mysql,optimization,laravel-forge,Mysql,Optimization,Laravel Forge,自从我购买了16GB ram&1核心服务器后,我还没有优化我的my.cnf文件 我不知道该怎么做,因为所有这些优化的东西对我来说都是新的。 服务器在正常时间大约有60-80个并发用户,在非正常时间大约有20-40个并发用户,有时在不同的情况下会达到200-300个左右的峰值 我该怎么办 这是我的mysqltuner.pl: >> MySQLTuner 1.7.4 - Major Hayden <major@mhtx.net> >> Bug report

自从我购买了16GB ram&1核心服务器后,我还没有优化我的my.cnf文件

我不知道该怎么做,因为所有这些优化的东西对我来说都是新的。 服务器在正常时间大约有60-80个并发用户,在非正常时间大约有20-40个并发用户,有时在不同的情况下会达到200-300个左右的峰值

我该怎么办

这是我的mysqltuner.pl:

 >>  MySQLTuner 1.7.4 - 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
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 user@% to user@SpecificDNSorIp
    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。根据我的经验,增加innodb_buffer_pool_的大小将极大地提高mysql的性能,特别是在您有16G Ram的情况下。如果您的服务器专用于mysql,则可以将此值设置为12G


以下是我经常遵循的一些有用的优化准则

您拥有514M的innodb数据。在您的innodb存储需求增长之前,不要使用它

您的my.cnf/ini应更改为:

#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.
关闭/重新启动

当您忙了至少24小时后,重新发布当前MySQLTuner报告


在4分钟内,您的信息与我们在一个完整的工作日或一周后看到的信息相比根本算不上什么。

嘿,谢谢您的回答,服务器并不是专用于MySQL的,建议您这样做吗?我的建议是,如果您的数据库是innodb,则应将innodb_buffer_pool_大小增加到更大的值。buffer_pool已经是数据大小的两倍。因此,进一步增加它不会提高性能。请参见
InnoDB缓冲池/数据大小:1.0G/514.4M
。但是,如果数据增加,请将缓冲池增加到可用RAM的70%。“非专用”-在设置缓冲池之前,请查看有多少可用空间。避免过度提交RAM,这将导致交换,这对MySQL性能非常不利。是16GB的RAM还是1GB的?@RickJames 16GB您有两种不同的
query\u cache\u size
分配:一种用于
0
,另一种用于
32M
。你用哪一种?
#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.