免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5087 | 回复: 6
打印 上一主题 下一主题

mysql5.0 max_threads 超过12个 就报错! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-09-28 17:39 |只看该作者 |倒序浏览
数据库服务器环境:
系统CentOS release 5.2 (Final

CPU: Xeon(R) E5405  @ 2.00GHz双 四核

MEM:4G

mysql:Ver 5.0.51b-log


my.cnf 配置

# The MySQL server
[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-locking
skip-name-resolve
back_log = 500
key_buffer = 384M
max_allowed_packet = 8M
thread_stack = 256K
table_cache = 1024
tmp_table_size = 128M
max_heap_table_size = 128M
sort_buffer_size = 4M
read_buffer_size = 6M
join_buffer_size = 8M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 64
query_cache_size = 32M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
set-variable=max_connections=800
max_connect_errors = 5000
wait_timeout = 10

long_query_time = 2
log-slow-queries = /tmp/mysql_slow.log
log-queries-not-using-indexes


[isamchk]
key_buffer = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

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


# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 77824
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) 5000
open files                      (-n) 65535
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 20
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

# cat  /etc/security/limits.conf   内容:

#* hard nofile 65535
#* soft nofile 65535

mysql> show variables like "%open%";
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| have_openssl      | NO    |
| innodb_open_files | 300   |
| open_files_limit  | 4906  |
+-------------------+-------+
3 rows in set (0.00 sec)

状况:每当服务器流量高的时候 连接不上数据库,并在本地登录时候业报同样的错误:

FATAL: error 1135: Can't create a new thread (errno 11); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug

使用 sysbac 测试:每次 --num-threads=12  值超过 12 个就报上面的错

# sysbench --debug=off --test=oltp --mysql-host=localhost --mysql-user=test --mysql-password=test --oltp-table-size=1000000 --mysql-db=test --oltp-table-name=stest --num-threads=13 --max-requests=10 --oltp-auto-inc=off --mysql-engine-trx=yes run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
FATAL: unable to connect to MySQL server, aborting...
FATAL: error 1135: Can't create a new thread (errno 11); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug
FATAL: failed to connect to database server!
FATAL: thread#10: failed to connect to database server, aborting...


请高手帮忙 这问题

[ 本帖最后由 gron 于 2009-9-28 17:42 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2009-09-28 17:45 |只看该作者
sort_buffer_size = 4M
read_buffer_size = 6M
join_buffer_size = 8M
read_rnd_buffer_size = 8M

上面这几个参数设置的不好,减少到现在值的四分之一

论坛徽章:
0
3 [报告]
发表于 2009-09-28 17:54 |只看该作者

回复 #2 raid_fifa 的帖子

顶~
sort_buffer_size = 4M
read_buffer_size = 6M
这两参数貌似是指一个线程占用的值。

论坛徽章:
0
4 [报告]
发表于 2009-09-28 18:00 |只看该作者
还有你这个sysbench测试OLTP,为什么没指定表类型呢?
印象中应该要用--mysql-table-engine这个参数指定的,
Innodb跟myisam测出来的结果应该不太一样。。。

论坛徽章:
0
5 [报告]
发表于 2009-09-29 13:12 |只看该作者

回复 #1 gron 的帖子

谢谢,朋友们的帮助。我调整看看!不过我找到问题的原因了!!是系统内核限制线程的最大数 而导致的。

[ 本帖最后由 gron 于 2009-9-29 13:16 编辑 ]

论坛徽章:
0
6 [报告]
发表于 2009-09-29 13:13 |只看该作者

回复 #4 mysqlkiki 的帖子

我的是mysisam 表,sysbech 默认是 这个类型的所以没指定了!!

论坛徽章:
0
7 [报告]
发表于 2009-09-29 15:46 |只看该作者
FATAL: error 1135: Can't create a new thread (errno 11); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug

这个错误很明显是没内存分配了。
那么回到my.cnf上看,你的全局的内存分配也不是太大,但你的Session级的内存分配太大了。
sort_buffer_size = 512K
read_buffer_size = 512K
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP