修改ibdata1大小的验证以及如何使用mysqld

修改ibdata1大小的验证

ibdata是共享表空间,在MySQL初始化的时候就生成了。

但很多童鞋会看到网上各种大神的调优建议,在MySQL已经初始化的情况下,修改配置文件中innodb_data_file_path=ibdata1:12M:autoextend。导致MySQL启动的时候报错。

下面来模拟一下:

原来的ibdata1大小为12M

# ll -h /sales3306/mysql/data/ibdata1 -rw-rw----. 1 mysql mysql 12M Mar 31 21:09 /sales3306/mysql/data/ibdata1

修改配置文件中的innodb_data_file_path参数,调整其大小

innodb_data_file_path=ibdata1:20M:autoextend

重启数据库服务

启动数据库的过程中没有报错,但就是没有起来,查看日志信息

[ERROR] InnoDB: auto-extending data file /sales3306/mysql/data/ibdata1 is of a different size 768 pages (rounded down to MB) than specified in the .cnf file: initial 1280 pages, max 0 (relevant if non-zero) pages!

报错信息其实很明显,ibdata1实际大小和配置文件中指定的大小不一致。

遇到这种问题,如何修复呢?

其实,只需将该参数设置为等于或者小于其实际大小。

关于等于,其实不难理解,毕竟要吻合,那小于又为什么可以呢?关键在于该参数后面的autoextend选项,所以实际值比初始值大很正常。当然小于的情况只适用于带有autoextend选项的表空间,MySQL可指定多个表空间,但只有最后一个才能指定该选项。

获取其实际大小,有两种方式,

一是通过ls -l查看其具体大小,可直接写12582912(12M)

二是通过错误日志的报错信息,譬如上面很容易算出其实际大小为768*16/1024=12M

当然,如果默认的共享表空间体积太大了,可新增一个表空间

innodb_data_file_path=ibdata1:12M;ibdata2:20M:autoextend

注意:共享表空间,即便把数据清理掉后,也不会回收空间,只能迁移数据,重新初始化。

mysqld_multi的使用

1. 在执行mysqld_multi时报以下错误:

/usr/local/mysql/bin/mysqld_multi --defaults-file=/root/multi.cnf report WARNING: my_print_defaults command not found. Please make sure you have this command available and in your path. The command is available from the latest MySQL distribution. ABORT: Can't find command 'my_print_defaults'. This command is available from the latest MySQL distribution. Please make sure you have the command in your PATH.

解决方法:

在/etc/profile中添加如下内容:

export PATH=$PATH:/usr/local/mysql/bin/

并使其生效 source /etc/profile

2. 启动失败,通过查看mysqld_multi的错误日志/usr/local/mysql/multi.log 

有如下报错信息:

Starting MySQL servers 160116 20:25:22 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'. touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory chmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory chown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory 160116 20:25:22 mysqld_safe Logging to '/sales3307/mysql/log/.err'. 160116 20:25:22 mysqld_safe Starting mysqld daemon with databases from /sales3306/mysql/data /usr/local/mysql/bin/mysqld_safe: line 129: /var/log/mariadb/mariadb.log: No such file or directory /usr/local/mysql/bin/mysqld_safe: line 166: /var/log/mariadb/mariadb.log: No such file or directory touch: cannot touch ‘/var/log/mariadb/mariadb.log’: No such file or directory chown: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory chmod: cannot access ‘/var/log/mariadb/mariadb.log’: No such file or directory 160116 20:25:22 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended /usr/local/mysql/bin/mysqld_safe: line 129: /var/log/mariadb/mariadb.log: No such file or directory 160116 20:25:22 mysqld_safe Starting mysqld daemon with databases from /sales3307/mysql/data 160116 20:25:23 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended mysqld_multi log file version 2.16; run: Sat Jan 16 20:25:24 2016

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/6471cb32856ab0ba98a30482beb1d96c.html