2013-02-18 102 views
2

我在RHEL6.3上運行MySQL服務器5.1.61。 MysQL服務器運行正常,但我發現我需要調整innodb_buffer_pool_size。我認爲這個變量可以用MySQL顯示像'innodb%'這樣的變量沒有任何返回

mysql>顯示像'innodb%'這樣的變量;

但實際上,它什麼也沒有返回。它爲什麼沒有返回?我在哪裏可以看到實際的innodb_buffer_pool_size(除my.cnf文件外)。 PS:我知道我可以更改my.cnf中的innodb_buffer_pool_size並重新啓動MySQL,但爲什麼我看不到它的實際值?

回答

4

在MySQL 5.1中,有可能爲InnoDB存儲引擎無法完成初始化,如果在啓動過程中遇到錯誤。在那種情況下,它只是禁用InnoDB並繼續。 MyISAM表將被訪問,但是沒有InnoDB表。

檢查InnoDB存儲引擎是否已啓用。下面是從65年1月5日的情況下輸出:

mysql> show variables like 'have_innodb'; 
+---------------+-------+ 
| Variable_name | Value | 
+---------------+-------+ 
| have_innodb | YES | 
+---------------+-------+ 

mysql> show engines; 
+------------+---------+----------------------------------------------------------------+--------------+------+------------+ 
| Engine  | Support | Comment              | Transactions | XA | Savepoints | 
+------------+---------+----------------------------------------------------------------+--------------+------+------------+ 
| InnoDB  | YES  | Supports transactions, row-level locking, and foreign keys  | YES   | YES | YES  | 
. . . 

接下來,我模擬了InnoDB的故障,通過編輯my.cnf中設置innodb_log_file_size=256M,這是不是磁盤上的日誌文件的大小。然後我重新啓動實例。

mysql> show variables like 'have_innodb'; 
+---------------+-------+ 
| Variable_name | Value | 
+---------------+-------+ 
| have_innodb | NO | 
+---------------+-------+ 

mysql> show variables like 'innodb%'; 
Empty set (0.00 sec) 

麻煩!去哪裏看?錯誤日誌文件:

InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes 
InnoDB: than specified in the .cnf file 0 268435456 bytes! 
130218 12:50:46 [ERROR] Plugin 'InnoDB' init function returned error. 
130218 12:50:46 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 

您也可以強制MySQL如果遇到錯誤初始化InnoDB的中止其啓動,所以你永遠不會陷入這種局面再次。此項添加到在/etc/my.cnf:

[mysqld] 
innodb=force 

然後,當我嘗試啓動,我看到這個錯誤日誌:

InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes 
InnoDB: than specified in the .cnf file 0 268435456 bytes! 
130218 12:55:03 [ERROR] Plugin 'InnoDB' init function returned error. 
130218 12:55:03 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 
130218 12:55:03 [ERROR] Failed to initialize plugins. 
130218 12:55:03 [ERROR] Aborting 

130218 12:55:03 [Note] /home/billkarwin/opt/mysql/5.1.65/bin/mysqld: Shutdown complete 

在MySQL 5.5中,服務器將無法啓動如果InnoDB無法初始化。

+0

謝謝你解決這個問題!我認爲你是對的,但問題是如何解決這個ib_logfile0問題? – fanchyna 2013-02-19 02:15:11

+0

如果日誌文件大小是導致錯誤的原因,請嘗試將my.cnf更改爲具有磁盤上存在的文件大小。然後重新啓動mysql服務。 – 2013-02-19 06:46:35

+0

我標記你的答案是正確的。對不起,我在看到你的答案之前採取了行動。我所做的是移動(不刪除)ib_log文件,然後重新啓動MySQL服務器。這次,innodb啓動,但是有一些錯誤信息如下:「mysql.db的列數是錯誤的,預計22,找到20.表可能已損壞。130218 21:25:03 [錯誤] mysql.user has在位置29沒有'Event_priv'列。我想我的行爲會導致一些表被破壞。有沒有簡單的解決方法?如果沒有,我可能需要重新安裝MySQL服務器並重新導入數據。你怎麼看,比爾?謝謝。 – fanchyna 2013-02-19 15:03:21

1

嘗試SHOW VARIABLES WHERE variable_name LIKE 'innodb%'

+0

這不起作用。 – fanchyna 2013-02-19 01:38:00

相關問題