首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MySQL max_connection值

MySQL max_connection值
EN

Database Administration用户
提问于 2014-03-18 06:38:45
回答 1查看 2.3K关注 0票数 0

问题

  1. 我有一台12 GB的带有apache & myqsl的机器,我可以将apache设置为150,这会导致mysql中的50 max_client出现瓶颈吗?
  2. 我应该设置什么值来平衡mysql、max_connection或apache max_client,并为我的站点优化性能?

谢谢。

请查看我的mysql配置和mysqltuner结果。

代码语言:javascript
复制
[mysqld]
innodb_file_per_table
datadir=/var/lib/mysql
tmpdir=/var/lib/mysqltmp
socket=/var/lib/mysql/mysql.sock
skip-locking
skip-name-resolve
table_cache=1024
table_definition_cache = 1024
thread_cache_size=16
back_log=100
max_connect_errors=10000
open-files-limit=20000
interactive_timeout=30
wait_timeout=60
max_connections=50
skip-name-resolve

# Slow Query Log Settings
log-slow-queries=/var/lib/mysqllogs/slow-log
long_query_time=5
log-queries-not-using-indexes

# Global, Non Engine-Specific Buffers
max_allowed_packet=16M
tmp_table_size=1768M
max_heap_table_size=1768M
query_cache_size=32M

# Per-Thread Buffers
sort_buffer_size=1M
read_buffer_size=1M
read_rnd_buffer_size=8M
join_buffer_size=32M

# MyISAM
key_buffer_size=64M
myisam_sort_buffer_size=64M

# InnoDB
innodb_log_file_size=100M
innodb_buffer_pool_size=1512M

[mysql.server]
user=mysql
#basedir=/var/lib

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
open-files-limit=65535

 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
 >>  Run with '--help' for additional options and output filtering

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

-------- Storage Engine Statistics -------------------------------------------
[--] Status: -Archive -BDB -Federated
+InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 48M (Tables: 124)
[--] Data in InnoDB tables: 2G (Tables: 179)
[!!] Total fragmented tables: 39

-------- Security Recommendations  -------------------------------------------
[OK] All database users have passwords assigned

-------- Performance Metrics -------------------------------------------------
[--] Up for: 5d 14h 27m 2s (20M q [41.828 qps], 1M conn, TX: 275B, RX:
5B)
[--] Reads / Writes: 75% / 25%
[--] Total buffers: 3.3G global + 42.2M per thread (50 max threads)
[OK] Maximum possible memory usage: 5.4G (46% of installed RAM)
[!!] Slow queries: 6% (1M/20M)
[OK] Highest usage of available connections: 74% (37/50)
[OK] Key buffer size / total MyISAM indexes: 64.0M/31.1M
[OK] Key buffer hit rate: 99.9% (11M cached / 7K reads)
[OK] Query cache efficiency: 68.1% (10M cached / 14M selects)
[!!] Query cache prunes per day: 42514
[OK] Sorts requiring temporary tables: 0% (4K temp sorts / 1M sorts)
[!!] Joins performed without indexes: 73669
[OK] Temporary tables created on disk: 6% (136K on disk / 2M total)
[OK] Thread cache hit rate: 99% (155 created / 1M connections)
[OK] Table cache hit rate: 74% (974 open / 1K opened)
[OK] Open file limit used: 0% (453/65K)
[OK] Table locks acquired immediately: 99% (18M immediate / 18M locks)
[!!] InnoDB data size / buffer pool: 2.3G/1.5G

-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    Adjust your join queries to always utilize indexes
Variables to adjust:
    query_cache_size (> 64M)
    join_buffer_size (> 32.0M, or always use indexes with joins)
    innodb_buffer_pool_size (>= 2G)
EN

回答 1

Database Administration用户

发布于 2014-03-20 11:27:23

Max_connections是MySQL服务器允许的并发连接总数。如果您正在获得Too many connections' error,这意味着您已经达到了这个极限。

此外,您应该在一段时间内观察threads_running变量值,以确定'max_connections‘的确切值。

您可以将max_connection值视为

MaxValue (Threads_running)‘+ 10 = Max_connections

票数 1
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/61130

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档