在MySQL数据库中,我们需要根据数据库的状态调整一些系统参数,下面为您介绍的是MySQL表锁情况和文件打开数的调整方法,供您参考。
文件打开数(open_files)
- mysql> show global status like 'open_files';
- +---------------+-------+
- | Variable_name | Value |
- +---------------+-------+
- | Open_files | 1410 |
- +---------------+-------+
- mysql> show variables like 'open_files_limit';
- +------------------+-------+
- | Variable_name | Value |
- +------------------+-------+
- | open_files_limit | 4590 |
- +------------------+-------+
- 比较合适的设置:Open_files / open_files_limit * 100%
MySQL表锁情况
- mysql> show global status like 'table_locks%';
- +-----------------------+-----------+
- | Variable_name | Value |
- +-----------------------+-----------+
- | Table_locks_immediate | 490206328 |
- | Table_locks_waited | 2084912 |
- +-----------------------+-----------+
Table_locks_immediate表示立即释放MySQL表锁数,Table_locks_waited表示需要等待的MySQL表锁数,如果Table_locks_immediate / Table_locks_waited > 5000,最好采用InnoDB引擎,因为InnoDB是行锁而MyISAM是MySQL表锁,对于高并发写入的应用InnoDB效果会好些。示例中的服务器Table_locks_immediate / Table_locks_waited = 235,MyISAM就足够了。
【编辑推荐】