Mysql参数-GDB

1,527 views

Published on

mysql

Published in: Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,527
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
30
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Mysql参数-GDB

  1. 1. 1 GDB MySQL参数 苏普 2010-10 Open-files-limit
  2. 2. 起源 > Can't open file: '.testmytable.frm' (errno: 24) shell> perror 24 OS error code 24: Too many open files 尝试修改open_files_limit 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.
  3. 3. open_files_limit in my.cnf • 配置open_files_limit = 10000 global variables like "%open_files_limit%"; +------------------+-------+ | open_files_limit | 1024 | +------------------+-------+ • 配置open_files_limit = 30000 global variables like "%open_files_limit%"; +------------------+-------+ | open_files_limit | 1024 | +------------------+-------+ 参数设置始终无效
  4. 4. Why? • 开启了一个痛苦代码追踪过程
  5. 5. gdb: watch gdb mysqld (gdb) watch open_files_limit (gdb) r Old value = 0 New value = 20000 Old value = 20000 New value = 1024 init_common_variables (...) at mysqld.cc:3355
  6. 6. Sql/mysqld.cc:3355 max_open_files= max(max(wanted_files, max_connections*5), open_files_limit); 3322 files= my_set_max_open_files(max_open_files); gdb mysqld (gdb) b mysqld.cc:3322 (gdb) r (gdb) n
  7. 7. mysys/my_file.c uint my_set_max_open_files(uint files){ ... files= set_max_open_files(min(files, OS_FILE_LIMIT));
  8. 8. mysys/my_file.c static uint set_max_open_files(uint max_file_limit){ ... if (rlimit.rlim_cur >= max_file_limit) DBUG_RETURN(rlimit.rlim_cur); rlimit.rlim_cur= rlimit.rlim_max= max_file_limit; if (setrlimit(RLIMIT_NOFILE, &rlimit)) }
  9. 9. Linux && setrlimit • man setrlimit – set resource limits
  10. 10. Almost Done • mysqld_safe if test -w / -o "$USER" = "root" then ...... if test -n "$open_files" then ulimit -n $open_files append_arg_to_args "--open-files-limit=$open_files" fi fi
  11. 11. Simple? or not? • That’s all • Who’s next
  12. 12. Q & A

×