mysql gdb-101022041146-phpapp01
TRANSCRIPT
![Page 1: Mysql gdb-101022041146-phpapp01](https://reader036.vdocuments.site/reader036/viewer/2022062319/556a140ad8b42af0198b4ef9/html5/thumbnails/1.jpg)
1
GDB MySQL参数
苏普
2010-10
Open-files-limit
![Page 2: Mysql gdb-101022041146-phpapp01](https://reader036.vdocuments.site/reader036/viewer/2022062319/556a140ad8b42af0198b4ef9/html5/thumbnails/2.jpg)
起源> Can't open file: '.\test\mytable.frm' (errno: 24)shell> perror 24OS 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.
![Page 3: Mysql gdb-101022041146-phpapp01](https://reader036.vdocuments.site/reader036/viewer/2022062319/556a140ad8b42af0198b4ef9/html5/thumbnails/3.jpg)
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 |+------------------+-------+
参数设置始终无效
![Page 4: Mysql gdb-101022041146-phpapp01](https://reader036.vdocuments.site/reader036/viewer/2022062319/556a140ad8b42af0198b4ef9/html5/thumbnails/4.jpg)
Why?
• 开启了一个痛苦代码追踪过程
![Page 5: Mysql gdb-101022041146-phpapp01](https://reader036.vdocuments.site/reader036/viewer/2022062319/556a140ad8b42af0198b4ef9/html5/thumbnails/5.jpg)
gdb: watch
gdb mysqld(gdb) watch open_files_limit(gdb) r
Old value = 0New value = 20000
Old value = 20000New value = 1024init_common_variables (...) at mysqld.cc:3355
![Page 6: Mysql gdb-101022041146-phpapp01](https://reader036.vdocuments.site/reader036/viewer/2022062319/556a140ad8b42af0198b4ef9/html5/thumbnails/6.jpg)
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
![Page 7: Mysql gdb-101022041146-phpapp01](https://reader036.vdocuments.site/reader036/viewer/2022062319/556a140ad8b42af0198b4ef9/html5/thumbnails/7.jpg)
mysys/my_file.c
uint my_set_max_open_files(uint files){... files= set_max_open_files(min(files, OS_FILE_LIMIT));
![Page 8: Mysql gdb-101022041146-phpapp01](https://reader036.vdocuments.site/reader036/viewer/2022062319/556a140ad8b42af0198b4ef9/html5/thumbnails/8.jpg)
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))
}
![Page 9: Mysql gdb-101022041146-phpapp01](https://reader036.vdocuments.site/reader036/viewer/2022062319/556a140ad8b42af0198b4ef9/html5/thumbnails/9.jpg)
Linux && setrlimit
• man setrlimit– set resource limits
![Page 10: Mysql gdb-101022041146-phpapp01](https://reader036.vdocuments.site/reader036/viewer/2022062319/556a140ad8b42af0198b4ef9/html5/thumbnails/10.jpg)
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" fifi
![Page 11: Mysql gdb-101022041146-phpapp01](https://reader036.vdocuments.site/reader036/viewer/2022062319/556a140ad8b42af0198b4ef9/html5/thumbnails/11.jpg)
Simple? or not?• That’s all
• Who’s next
![Page 12: Mysql gdb-101022041146-phpapp01](https://reader036.vdocuments.site/reader036/viewer/2022062319/556a140ad8b42af0198b4ef9/html5/thumbnails/12.jpg)
Good Luck
Q & A