码迷,mamicode.com
首页 > 数据库 > 详细

关于innodb_data_file_path设置

时间:2018-05-25 15:31:00      阅读:444      评论:0      收藏:0      [点我收藏+]

标签:关于innodb_data_file

关于innodb_data_file_path设置

启动Mysql时报错,无法正常启动,通过日志发有数据文件大小错误,日志如下截图:

[ERROR] InnoDB: auto-extending data file /usr/local/mysql/data/ibdata1 is of a different size 768 pages (rounded down to MB) than specified in the .cnf file: initial 65536 pages, max 0 (relevant if non-zero) pages!
2018-05-25 14:27:04 6002 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!

说明:

 innodb_data_file_path用来指定innodb tablespace文件,如果我们不在My.cnf文件中指定innodb_data_home_dir和innodb_data_file_path那么默认会在datadir目录下创建ibdata1 作为innodb tablespace。5.6.6之后 两个参数的默认值如下:

show variables like 'innodb_data%';


  1. +-----------------------+------------------------+  

  2. | Variable_name         | Value                  |  

  3. +-----------------------+------------------------+  

  4. | innodb_data_file_path | ibdata1:12M:autoextend |  

  5. | innodb_data_home_dir  |                        | >>note:虽然不指定innodb_data_home_dir和指定它为空显示是一样的,但是作用确不一样,如果不指定那么所有的innodb tablespace 文件只能存放在datadir目录下。如果显示指定为空,则可以为innodb tablespace 文件指定不同的路径  


自mysql 5.6.6开始我们可以指定多个innodb tablespace 文件(这些文件可以在相同的路径下,也可以在不同的路径下)。但是在为innodb_data_file_path 指定多个文件时还是有许多注意事项的,下面我来看一下
1. 在同一个路径下指定多个innodb tablespace 文件
1)
在my.cnf文件指定如下
[mysqld]
innodb_data_file_path = ibdata1:1G;ibdata2:12M:autoextend:max:500M
note:The autoextend and max attributes can be used only for the last data file in the innodb_data_file_path line. 
note:因为没有指定innodb_data_home_dir,所以ibdata1和ibdata2都在datadir(innodb_data_home_dir默认值为datadir)目录下创建


2)
在my.cnf文件指定如下
[mysqld]
innodb_data_home_dir = /data/mysql/mysql3306/data
innodb_data_file_path = ibdata1:1G;ibdata2:12M:autoextend:max:500M
note:可以显示的指定innodb tablespace文件的路径,如果指定innodb_data_home_dir,那么就不能为innodb tablespace不同文件指定不同路径


2. 在不同路径下指定innodb tablespace
在my.cnf文件下指定
[mysqld]
innodb_data_home_dir =
innodb_data_file_path = ibdata1:12M;/data/mysql/mysql3306/data1/ibdata2:12M:autoextend

note:如果想为innodb tablespace指定不同目录下的文件,必须指定innodb_data_home_dir =。这个例子中会在datadir下建立ibdata1,在/data/mysql/mysql3306/data1/目录下创建ibdata2

  如果我不指定innodb_data_home_dir =,只在my.cnf文件中做如下指定:

innodb_data_file_path = ibdata1:12M;/data/mysql/mysql3306/data1/ibdata2:12M:autoextend

然后使用该my.cnf文件进行数据库初始化的时候,会发现初始化失败,报错如下:


  1. 2016-03-24 16:58:34 29559 [ERROR] InnoDB: File .//data/mysql/mysql3306/data1/ibdata2: 'create' returned OS error 71. Cannot continue operation  

##所以如果想为innodb tablespace文件指定不同路径,那么必须在my.cnf文件中指定innodb_data_home_dir =

参考资料:https://blog.csdn.net/shaochenshuo/article/details/50973068

关于innodb_data_file_path设置

标签:关于innodb_data_file

原文地址:http://blog.51cto.com/xiaocao13140/2120285

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!