高分求解。。mysql 的最大连接数始终为200

zhouheng123456 2013-04-18 03:40:52
linux debian 6

nginx + fpm + mysql

测试工具webbench

当my.cnf 中的max_connetcions为50时,webbench 并发500 个带数据库操作的php页面。从命令show processlist来看. 数量为50

当my.cnf中的max_connetcions为300或更多时,webbench 并发500个带数据库操作的php页面。从命令show processlist来看. 最大数量为203

也就是无论怎么设置还是并发数为203, 首先php-fpm和nginx我已经测试过了并发1000以上没有任何问题,只不过响应时间要长几秒而以。。。。求解为什么我只mysql只能有203个connections???

my.cnf
---------------------------------

[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock

# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
thread_concurrency = 8
max_connections=2000
log-bin=mysql-bin
server-id = 1

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout


linux 系统参数

ulimit -n 65536

* soft 65536
* hard 65536

/etc/sysctl.conf
---------------------------
# Controls IP packet forwarding
net.ipv4.ip_forward = 0

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1

# Controls the use of TCP syncookies
#net.ipv4.tcp_syncookies = 1
#net.ipv4.tcp_tw_reuse = 1
#net.ipv4.tcp_tw_recycle = 1
#net.ipv4.tcp_fin_timeout = 30

# Disable netfilter on bridges.
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0

# Controls the default maxmimum size of a mesage queue
kernel.msgmnb = 65536

# Controls the maximum size of a message, in bytes
kernel.msgmax = 65536

# Controls the maximum shared segment size, in bytes
kernel.shmmax = 4294967295

# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 268435456

net.ipv4.tcp_max_syn_backlog = 4096
net.core.netdev_max_backlog = 4096
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 32768 65000
net.ipv4.tcp_keepalive_time = 12000
net.ipv4.tcp_max_tw_buckets = 12000
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_wmem = 8192 436600 873200
net.ipv4.tcp_rmem = 32768 436600 873200
net.ipv4.tcp_mem = 786432 1048576 1572864
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_fin_timeout = 30
...全文
296 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouheng123456 2013-04-20
  • 打赏
  • 举报
回复
引用 8 楼 xuboke 的回复:
你测试是同一MYSQL账号? mysql> show variables like"max_user%"; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | max_user_connections | 0 ……
我设置的是 0
欢乐的尼美 2013-04-18
  • 打赏
  • 举报
回复
你测试是同一MYSQL账号? mysql> show variables like"max_user%"; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | max_user_connections | 0 | +----------------------+-------+ 这个值是每个mysql账号的最大连接数。0是不限制
zhouheng123456 2013-04-18
  • 打赏
  • 举报
回复
最大tcp 和一数内核参数我已经调整过了
ACMAIN_CHM 2013-04-18
  • 打赏
  • 举报
回复
直接登录在数据库所有服务器测试。 有些时候操作系统会有最大 TCP 连接数限制。
zhouheng123456 2013-04-18
  • 打赏
  • 举报
回复
另外,我用两台不同的机器 分别使用 webbench来测试一个web地址。。但连接数还是没改变
zhouheng123456 2013-04-18
  • 打赏
  • 举报
回复
navicat mysql 建立了两个 连接。分别指和同一个DB 只打开一个的情况下 show processlist 为 204 此时打开另一个连接情况下为205.. 这是否说有我用 webbench测试只能达到最多204个连接,与数据库性能无关
rucypli 2013-04-18
  • 打赏
  • 举报
回复
用mysql客户端连进去试试 用户就用程序的用户名 看看连接能涨上去不 如果能 则是程序问题
zhouheng123456 2013-04-18
  • 打赏
  • 举报
回复
引用 1 楼 wwwwb 的回复:
max_user_connections=0试试
改过了,还是最高只能到203
wwwwb 2013-04-18
  • 打赏
  • 举报
回复
max_user_connections=0试试

56,803

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧