您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Innodb优化之修改页大小

2024/11/18 23:39:09发布29次查看
mysql在使用innodb引擎的时候页大小默认是16k,这个大小对于很多应用来说太大了,很多在其他数据如oracle运行良好的应用迁移到innodb后发现io压力偏大,mysql本
mysql在使用innodb引擎的时候页大小默认是16k,美国服务器,这个大小对于很多应用来说太大了,很多在其他数据如oracle运行良好的应用迁移到innodb后发现io压力偏大,mysql本身没有提供修改页大小的参数,但是我们可以通过修改源码重新编译mysql来实现,下面来做个测试,做测试的数据库版本为mysql-5.5.25:
 先查看当前的页大小:
mysql> show global status like 'innodb_page_size';
+------------------+-------+
| variable_name    | value |
+------------------+-------+
| innodb_page_size | 16384 |
+------------------+-------+
1 row in set (0.00 sec)
mysql>
可以看到默认情况下mysql的页大小为16k,下面修改页面大小相关的源码
vim /mysql-5.5.25/storage/innobase/include/univ.i
#define univ_word_alignment     univ_word_size
/*
                        database version control
                        ========================
*/
/* the 2-logarithm of univ_page_size: */
#define univ_page_size_shift    14                           ------------这个变量是修改为13
/* the universal page size of the database */
#define univ_page_size          (1
修改完成后代码应该是:
#define univ_word_alignment     univ_word_size
/*
                        database version control
                        ========================
*/
/* the 2-logarithm of univ_page_size: */
#define univ_page_size_shift    13                          
/* the universal page size of the database */
#define univ_page_size          (1
对于mysql 5.1的版本代码和5.5的修改方式稍微不同,下面的5.1版本代码的修改方式:
/*
   database version control
   ========================
*/
/* the universal page size of the database */
#define univ_page_size          (2 * 8192) /* note! currently, this has to be a ------修改为(2*4096)     
power of 2 */
/* the 2-logarithm of univ_page_size: */
#define univ_page_size_shift 14   ------修改为13(该值是2的多少次方为univ_page_size)
/* maximum number of parallel threads in a parallelized operation */
#define univ_max_parallelism 32
     修改红色部分即可,记住univ_page_size大小只能是2的次方,如8k,16k,32k,univ_page_size_shift 该值是2的多少次方为univ_page_size。
修改完成保存退出然后重新编译安装mysql数据库,虚拟主机,过程就不写了。编译安装完成后再次查看页大小:
mysql>
mysql> show global status like 'innodb_page_size';
+------------------+-------+
| variable_name    | value |
+------------------+-------+
| innodb_page_size | 8192  |
+------------------+-------+
1 row in set (0.00 sec)
mysql>
可以看到页大小已经修改为8k。
,香港空间
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product