程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> 【mysql案例】mysql5.6.14配置my.cnf多實例,mysql_install_db初始化不讀取my.cnf配置文件

【mysql案例】mysql5.6.14配置my.cnf多實例,mysql_install_db初始化不讀取my.cnf配置文件

編輯:MySQL綜合教程

1.1.1. mysql5.6.14多實例my.cnf時,初始化不讀取my.cnf配置文件

【環境描述】

在多實例配置的/etc/my.cnf環境中,執行mysql_install_db後,啟動Mysql報錯。

【操作步驟】

/etc/my.cnf配置文件:

[mysqld3307]

innodb_data_file_path =ibdata1:1G:autoextend

初始化數據庫:

[root@test home]# mysql_install_db--datadir=/home/mysql_3307 --user=mysql --defaults-file=/etc/my.cnf

Installing MySQL system tables...2014-05-1311:07:33 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.Please use --explicit_defaults_for_timestamp server option (see documentationfor more details).

2014-05-13 11:07:33 8897 [Note] InnoDB: TheInnoDB memory heap is disabled

2014-05-13 11:07:33 8897 [Note] InnoDB:Mutexes and rw_locks use GCC atomic builtins

2014-05-13 11:07:33 8897 [Note] InnoDB:Compressed tables use zlib 1.2.3

2014-05-13 11:07:33 8897 [Note] InnoDB:Using Linux native AIO

2014-05-13 11:07:33 8897 [Note] InnoDB:Using CPU crc32 instructions

2014-05-13 11:07:34 8897 [Note] InnoDB:Initializing buffer pool, size = 128.0M

2014-05-13 11:07:34 8897 [Note] InnoDB:Completed initialization of buffer pool

2014-05-13 11:07:34 8897 [Note] InnoDB: Thefirst specified data file ./ibdata1 did not exist: a new database to becreated!

2014-05-13 11:07:34 8897 [Note] InnoDB:Setting file ./ibdata1 size to 12 MB

2014-05-13 11:07:34 8897 [Note] InnoDB:Database physically writes the file full: wait...

2014-05-13 11:07:34 8897 [Note] InnoDB:Setting log file ./ib_logfile101 size to 48 MB

2014-05-13 11:07:34 8897 [Note] InnoDB:Setting log file ./ib_logfile1 size to 48 MB

2014-05-13 11:07:35 8897 [Note] InnoDB:Renaming log file ./ib_logfile101 to ./ib_logfile0

2014-05-13 11:07:35 8897 [Warning] InnoDB:New log files created, LSN=45781

2014-05-13 11:07:35 8897 [Note] InnoDB:Doublewrite buffer not found: creating new

2014-05-13 11:07:35 8897 [Note] InnoDB:Doublewrite buffer created

啟動mysql實例時,error.log報錯:

2014-05-13 11:11:15 8989 [Note] InnoDB:Completed initialization of buffer pool

2014-05-13 11:11:15 8989 [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a differentsize 768 pages (rounded down to MB) than specified in the .cnf file: initial65536 pages, max 0 (relevant if non-zero) pages!

2014-05-13 11:11:15 8989 [ERROR] InnoDB:Could not open or create the system tablespace. If you tried to add new datafiles to the system tablespace, and it failed he

re, you should now editinnodb_data_file_path in my.cnf back to what it was, and remove the new ibdatafiles InnoDB created in this failed attempt. InnoDB only wrote

those files full of zeros, but did not yetuse them in any way. But be careful: do not remove old data files which containyour precious data!

2014-05-13 11:11:15 8989 [ERROR] Plugin'InnoDB' init function returned error.

2014-05-13 11:11:15 8989 [ERROR] Plugin'InnoDB' registration as a STORAGE ENGINE failed.

2014-05-13 11:11:15 8989 [ERROR]Unknown/unsupported storage engine: InnoDB

2014-05-13 11:11:15 8989 [ERROR] Aborting

2014-05-13 11:11:15 8989 [Note] Binlog end

2014-05-13 11:11:15 8989 [Note] Shuttingdown plugin 'partition'

2014-05-13 11:11:15 8989 [Note] Shuttingdown plugin 'ARCHIVE'

雖然執行mysql_install_db命令的時候指定了讀取/etc/my.cnf配置文件,但是進行初始化創建數據庫的時候,實際上沒有讀取:

初始化時的輸出日志:

2014-05-13 11:07:34 8897 [Note] InnoDB:Setting file ./ibdata1 size to 12 MB

查看/home/mysql_3307/ibdata1的大小:

[root@ test mysql_3307]# ls -ltrh |grep ibdata1

-rw-rw---- 1 mysql mysql 12M May 13 11:07 ibdata1

可以發現實際創建的ibdata1文件大小也是mysql默認的12M,而非配置文件中配置的1G大小,在啟動實例時遇到的報錯,也是說ibdata1文件大小跟配置文件中的不匹配。

【報錯原因】

在mysql5.6.14版本中,mysql_install_db命令讀取my.cnf配置文件時,只會讀取[mysqld]配置模塊,它不會讀取多實例中配置的[mysqldNNN],所以在本案例中,雖然my.cnf配置了ibdata大小為1G,但是mysql仍然使用默認的12M。

【解決方法】

修改my.cnf,把[mysqldNNN]依次修改為[mysqld],執行完初始化之後,在把它修改回去。

【可能的其它原因】

網上有由於datadir路徑空間不足導致的報錯,但是除非my.cnf中配置的ibdata非常大,一般在線上情況不會發生的。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved