innodb_data_home_dir参数:
mysql> show variables like 'innodb_data_home_dir'; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | innodb_data_home_dir | | +----------------------+-------+
默认为空,默认值为MySQL data目录。如果将值显示在配置文件中指定为空字符串,则可以为innodb_data_file_path指定绝对文件路径。
测试过程:
1.查看当前文件大小
[root@node03 data]# ls -lh ibdata1 -rw-r-----. 1 mysql mysql 74M Mar 12 00:18 ibdata1
2.查看配置文件
innodb_data_file_path = ibdata1:10M:autoextend
3.修改配置文件
innodb_data_file_path = ibdata1:10M;/data/mysql/ibdata2:20M:autoextend
4.启动数据库
报错1:
2020-03-11T16:13:11.550214Z 0 [Note] InnoDB: Need to create a new innodb_system data file '/data/mysql/ibdata2'. 2020-03-11T16:13:11.550274Z 0 [ERROR] InnoDB: The innodb_system data file './ibdata1' is of a different size 4736 pages (rounded down to MB) than the 640 pages specified in the .cnf file! 2020-03-11T16:13:11.550283Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 2020-03-11T16:13:12.157961Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 2020-03-11T16:13:12.158003Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 2020-03-11T16:13:12.158009Z 0 [ERROR] Failed to initialize builtin plugins. 2020-03-11T16:13:12.158019Z 0 [ERROR] Aborting ./ibdata1现在共有4736 pages ,修改配置文件中10M部分为实际文件大小74M,即: innodb_data_file_path = ibdata1:74M;/data/mysql/ibdata2:20M:autoextend
报错2:
2020-03-11T16:15:59.037570Z 0 [ERROR] InnoDB: Operating system error number 2 in a file operation. 2020-03-11T16:15:59.037578Z 0 [ERROR] InnoDB: The error means the system cannot find the path specified. 2020-03-11T16:15:59.037583Z 0 [ERROR] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them. 2020-03-11T16:15:59.037590Z 0 [ERROR] InnoDB: File .//data/mysql/mysql_3306/ibdata2: 'create' returned OS error 71. Cannot continue operation 2020-03-11T16:15:59.037595Z 0 [ERROR] InnoDB: Cannot continue operation. ibdata放置在不同的位置时需要设置“innodb_data_home_dir =”参数,指定innodb_data_home_dir为空,否则指定的位置不能生效。
增加innodb_data_home_dir配置:
2020-03-11T16:18:43.410089Z 0 [Note] InnoDB: Need to create a new innodb_system data file 'ibdata2'. 2020-03-11T16:18:43.410278Z 0 [Note] InnoDB: Setting file './/data/mysql/ibdata2' size to 20 MB. Physically writing the file full; Please wait ... 2020-03-11T16:18:43.447316Z 0 [Note] InnoDB: File './ibdata2' size is now 20 MB.