my.cnfのデフォルト設定ファイル
MySQLにはデフォルトの設定ファイルが用意されていて、my.cnfにコピーして使うことができます。
場所
MySQL5.1の場合は、インストールディレクトリ配下のsupport-filesに配置されてるようです。
AIR: support-files$pwd /usr/local/mysql/support-files
ファイル名は、my-XXX.cnf
AIR: support-files$ll | grep my- -rw-r--r-- 1 root wheel 4781 2 6 2010 my-huge.cnf -rw-r--r-- 1 root wheel 20168 2 6 2010 my-innodb-heavy-4G.cnf -rw-r--r-- 1 root wheel 4755 2 6 2010 my-large.cnf -rw-r--r-- 1 root wheel 4766 2 6 2010 my-medium.cnf -rw-r--r-- 1 root wheel 2404 2 6 2010 my-small.cnf
メモリ容量によって異なる
システムの搭載メモリに応じて、最適(標準的?)な設定を選べるように、複数のデフォルト設定ファイルがあります。
各デフォルト設定ファイルを読んでみると、最初の5行に特徴が書かれているので、headコマンドを使って一覧にしてみました。
64MBのメモリ用
AIR: support-files$head -5 my-small.cnf # Example MySQL config file for small systems. # # This is for a system with little memory (<= 64M) where MySQL is only used # from time to time and it's important that the mysqld daemon # doesn't use much resources.
128MBのメモリ用
AIR: support-files$head -5 my-medium.cnf # Example MySQL config file for medium systems. # # This is for a system with little memory (32M - 64M) where MySQL plays # an important part, or systems up to 128M where MySQL is used together with # other programs (such as a web server)
512MBのメモリ用
AIR: support-files$head -5 my-large.cnf # Example MySQL config file for large systems. # # This is for a large system with memory = 512M where the system runs mainly # MySQL. #
1〜2GBのメモリ用
AIR: support-files$head -5 my-huge.cnf # Example MySQL config file for very large systems. # # This is for a large system with memory of 1G-2G where the system runs mainly # MySQL. #
4GBのメモリとInnoDBで作成されたデータベース用
AIR: support-files$head -5 my-innodb-heavy-4G.cnf #BEGIN CONFIG INFO #DESCR: 4GB RAM, InnoDB only, ACID, few connections, heavy queries #TYPE: SYSTEM #END CONFIG INFO
アテにして良いのか?
漢(オトコ)のコンピュータ道: MySQLを高速化する10の方法では、バッファの推奨値が記述されています。
また、以下のような言及もあります。
バッファは増やせば増やすほどいいかと言えばそうではない。メモリの割り当てがオーバーヘッドになるので、無駄に大きくし過ぎることは禁物である。また、バッファを増やしすぎたためにスワップが発生するとパフォーマンスが悲惨なことになるのでくれぐれも空きメモリ容量には注意しよう。
自分の開発環境はMacbookなのですが、メモリ2GBなため、my-huge.cnfをデフォルトの設定ファイルとしてコピーして使ってます。漢のコンピュータ道さんとの内容と見比べてみると、バッファ取りすぎなんだろなーという感じがします。
自分専用の開発環境なので、つまり自分しかDBにアクセスしないわけですし、どれ使っても性能に影響でないんでしょうけど、実運用の場合はデフォルト値を過信せず、メモリ使用量とにらめっこしながら設定していく必要がありそうですね。