时间:2021-07-01 10:21:17 帮助过:31人阅读
一、试验
从手册的"6.4.8. How MySQL Opens and Closes Tables"可以了解到,每打开一个MyISAM表,就需要使用2个文件描述符,咱们来验证一下。
1. 重启mysqld
/etc/init.d/mysql restart
2. 看看打开了几个文件
lsof | grep /home/mysql
...
mysqld 24349 mysql 5u unix 0x000001041e8de040 4244009 /home/mysql/mysql.sock
mysqld 24349 mysql 6u REG 8,33 2048 30425188 /home/mysql/mysql/host.MYI
mysqld 24349 mysql 7u REG 8,33 0 30425189 /home/mysql/mysql/host.MYD
mysqld 24349 mysql 8u REG 8,33 2048 30425153 /home/mysql/mysql/user.MYI
mysqld 24349 mysql 9u REG 8,33 892 30425155 /home/mysql/mysql/user.MYD
mysqld 24349 mysql 10u REG 8,33 5120 30425126 /home/mysql/mysql/db.MYI
mysqld 24349 mysql 11u REG 8,33 3080 30425148 /home/mysql/mysql/db.MYD
mysqld 24349 mysql 12u REG 8,33 4096 30425154 /home/mysql/mysql/tables_priv.MYI
mysqld 24349 mysql 13u REG 8,33 0 30425157 /home/mysql/mysql/tables_priv.MYD
mysqld 24349 mysql 14u REG 8,33 4096 30425143 /home/mysql/mysql/columns_priv.MYI
mysqld 24349 mysql 15u REG 8,33 0 30425156 /home/mysql/mysql/columns_priv.MYD
mysqld 24349 mysql 16u REG 8,33 4096 30425127 /home/mysql/mysql/procs_priv.MYI
mysqld 24349 mysql 17u REG 8,33 0 30425136 /home/mysql/mysql/procs_priv.MYD
mysqld 24349 mysql 18u REG 8,33 1024 30425173 /home/mysql/mysql/servers.MYI
mysqld 24349 mysql 19u REG 8,33 0 30425174 /home/mysql/mysql/servers.MYD
mysqld 24349 mysql 20u REG 8,33 2048 30425182 /home/mysql/mysql/event.MYI
mysqld 24349 mysql 21u REG 8,33 0 30425183 /home/mysql/mysql/event.MYD
...
可以看到,总共打开了8个表,每个表分别有2个文件描述符,看来没错。
3. 再来看 status 结果
mysql>show global status like 'open_%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| Open_files | 17 |
| Open_streams | 0 |
| Open_table_definitions | 15 |
| Open_tables | 8 |
| Opened_files | 52 |
| Opened_tables | 15 |
+------------------------+-------+