GDB MySQL参数<br />Open-files-limit<br />苏普<br />2010-10<br />1<br />
起源<br />> Can't open file: '.testmytable.frm' (errno: 24)<br />shell> perror 24<br />OS error code 24: Too many open files...
open_files_limitin my.cnf<br />配置open_files_limit=10000<br />global variables like "%open_files_limit%";<br />+-----------...
Why?<br />开启了一个痛苦代码追踪过程<br />
gdb:watch<br /><ul><li>gdb mysqld
(gdb) watch open_files_limit
(gdb) r</li></ul>Old value = 0<br />New value = 20000<br />Old value = 20000<br />New value = 1024<br />init_common_variab...
Sql/mysqld.cc:3355<br />max_open_files= max(max(wanted_files, max_connections*5),<br />open_files_limit);<br />3322  files...
(gdb) b mysqld.cc:3322
(gdb) r
(gdb) n</li></li></ul><li>mysys/my_file.c<br />uint my_set_max_open_files(uint files){<br />...<br />    files= set_max_op...
mysys/my_file.c<br />static uintset_max_open_files(uintmax_file_limit){<br />...<br />if (rlimit.rlim_cur >= max_file_limi...
Upcoming SlideShare
Loading in...5
×

Mysql gdb-101022041146-phpapp01

375

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
375
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Mysql gdb-101022041146-phpapp01

  1. 1. GDB MySQL参数<br />Open-files-limit<br />苏普<br />2010-10<br />1<br />
  2. 2. 起源<br />> Can't open file: '.testmytable.frm' (errno: 24)<br />shell> perror 24<br />OS error code 24: Too many open files<br />尝试修改open_files_limit<br />Changes the number of file descriptors available to mysqld. You should try increasing the value of this option if mysqld gives you the error Too many open files. mysqld uses the option value to reserve descriptors with setrlimit(). If the requested number of file descriptors cannot be allocated, mysqld writes a warning to the error log.<br />
  3. 3. open_files_limitin my.cnf<br />配置open_files_limit=10000<br />global variables like "%open_files_limit%";<br />+------------------+-------+<br />| open_files_limit | 1024|<br />+------------------+-------+<br /><ul><li>配置open_files_limit=30000</li></ul>global variables like "%open_files_limit%";<br />+------------------+-------+<br />| open_files_limit | 1024|<br />+------------------+-------+<br />参数设置始终无效<br />
  4. 4. Why?<br />开启了一个痛苦代码追踪过程<br />
  5. 5. gdb:watch<br /><ul><li>gdb mysqld
  6. 6. (gdb) watch open_files_limit
  7. 7. (gdb) r</li></ul>Old value = 0<br />New value = 20000<br />Old value = 20000<br />New value = 1024<br />init_common_variables (...) at mysqld.cc:3355<br />
  8. 8. Sql/mysqld.cc:3355<br />max_open_files= max(max(wanted_files, max_connections*5),<br />open_files_limit);<br />3322 files= my_set_max_open_files(max_open_files);<br /><ul><li>gdb mysqld
  9. 9. (gdb) b mysqld.cc:3322
  10. 10. (gdb) r
  11. 11. (gdb) n</li></li></ul><li>mysys/my_file.c<br />uint my_set_max_open_files(uint files){<br />...<br /> files= set_max_open_files(min(files, OS_FILE_LIMIT));<br />
  12. 12. mysys/my_file.c<br />static uintset_max_open_files(uintmax_file_limit){<br />...<br />if (rlimit.rlim_cur >= max_file_limit) DBUG_RETURN(rlimit.rlim_cur);<br />rlimit.rlim_cur= rlimit.rlim_max= max_file_limit;<br />if (setrlimit(RLIMIT_NOFILE, &rlimit))<br />}<br />
  13. 13. Linux && setrlimit<br />man setrlimit<br />set resource limits<br />
  14. 14. Almost Done<br />mysqld_safe<br />if test -w / -o "$USER" = "root"<br />then<br /> ......<br /> if test -n "$open_files"<br /> then<br />ulimit -n $open_files<br />append_arg_to_args "--open-files-limit=$open_files"<br />fi<br />fi<br />
  15. 15. Simple? or not?<br />That’s all<br />Who’s next<br />
  16. 16. Good Luck<br />Q & A<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×