Mysql

MySQL 變數 - innodb_flush_method 在哪裡?

  • April 12, 2013

我想調整innodb_flush_method的值以找出它對數據庫伺服器的性能影響。當我執行命令時會列出該變數SHOW VARIABLES

但我在 MySQL 伺服器的配置文件中找不到它 - my.cnf. 我將XAMPP 1.6.3與 PHP (5.2.3) 和 MySQL (5.0.45) 一起使用。它的 MySQL 配置文件路徑是**/xampp/mysql/bin/my.cnf**

我在文件中搜尋了變數,但沒有運氣。

我在哪裡可以找到它?我只是俯瞰嗎?

更新

我升級到XAMPP 1.8.1。它的配置文件路徑是**/xampp/mysql/bin/my.ini**

還是找不到那個變數。

您擁有它的唯一方法是將其添加到您的my.cnf.

在添加此選項之前,您必須確保 InnoDB 儲存引擎可用。

請執行這些命令

SHOW VARIABLES LIKE 'have_innodb';
SHOW ENGINES;

如果你看到這個:

mysql> SHOW VARIABLES LIKE 'have_innodb';
+---------------+----------+
| Variable_name | Value    |
+---------------+----------+
| have_innodb   | DISABLED |
+---------------+----------+
1 row in set (0.01 sec)

mysql> SHOW ENGINES;
+------------+----------+----------------------------------------------------------------+
| Engine     | Support  | Comment                                                        |
+------------+----------+----------------------------------------------------------------+
| MyISAM     | DEFAULT  | Default engine as of MySQL 3.23 with great performance         |
| MEMORY     | YES      | Hash based, stored in memory, useful for temporary tables      |
| InnoDB     | NO       | Supports transactions, row-level locking, and foreign keys     |
| BerkeleyDB | NO       | Supports transactions and page-level locking                   |
| BLACKHOLE  | YES      | /dev/null storage engine (anything you write to it disappears) |
| EXAMPLE    | NO       | Example storage engine                                         |
| ARCHIVE    | YES      | Archive storage engine                                         |
| CSV        | YES      | CSV storage engine                                             |
| ndbcluster | DISABLED | Clustered, fault-tolerant, memory-based tables                 |
| FEDERATED  | YES      | Federated MySQL storage engine                                 |
| MRG_MYISAM | YES      | Collection of identical MyISAM tables                          |
| ISAM       | NO       | Obsolete storage engine                                        |
+------------+----------+----------------------------------------------------------------+
12 rows in set (0.00 sec)

mysql>

那麼你skip-innodb的my.cnf中有。您應該將其註釋掉並重新啟動mysql

你想看到的是這樣的:

mysql> SHOW VARIABLES LIKE 'have_innodb';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_innodb   | YES   |
+---------------+-------+
1 row in set (0.00 sec)

mysql> SHOW ENGINES;
+------------+----------+----------------------------------------------------------------+
| Engine     | Support  | Comment                                                        |
+------------+----------+----------------------------------------------------------------+
| MyISAM     | DEFAULT  | Default engine as of MySQL 3.23 with great performance         |
| MEMORY     | YES      | Hash based, stored in memory, useful for temporary tables      |
| InnoDB     | YES      | Supports transactions, row-level locking, and foreign keys     |
| BerkeleyDB | NO       | Supports transactions and page-level locking                   |
| BLACKHOLE  | YES      | /dev/null storage engine (anything you write to it disappears) |
| EXAMPLE    | NO       | Example storage engine                                         |
| ARCHIVE    | YES      | Archive storage engine                                         |
| CSV        | YES      | CSV storage engine                                             |
| ndbcluster | DISABLED | Clustered, fault-tolerant, memory-based tables                 |
| FEDERATED  | YES      | Federated MySQL storage engine                                 |
| MRG_MYISAM | YES      | Collection of identical MyISAM tables                          |
| ISAM       | NO       | Obsolete storage engine                                        |
+------------+----------+----------------------------------------------------------------+
12 rows in set (0.00 sec)

mysql>

將該選項添加到my.cnf

[mysqld]
innodb_flush_method=O_DIRECT

然後執行

service mysql restart

之後,你應該能夠看到它,如果你執行

mysql> show variables like 'innodb_flush_method';
+---------------------+----------+
| Variable_name       | Value    |
+---------------------+----------+
| innodb_flush_method | O_DIRECT |
+---------------------+----------+
1 row in set (0.00 sec)

mysql>

更新 2013-04-12 14:25 EDT

我剛剛意識到您正在執行 Windows 版本的 MySQL。我在想什麼?

正如@yercube 的評論所指出的,innodb_flush_method不適用於Windows。這是關於它的​​ MySQL 文件:

控制用於將數據刷新到 InnoDB 數據文件和日誌文件的系統呼叫,這會影響 I/O 吞吐量。此變數僅與 Unix 和 Linux 系統相關。在 Windows 系統上,flush 方法始終是 async_unbuffered 且無法更改。

如果您需要這種性能增強,請將您的數據遷移到 MySQL 的 Linux 版本。

引用自:https://dba.stackexchange.com/questions/30333