2012-08-24 21 views
16

my.cnfファイルにメモリ制限を設定する方法。私はmemory_limit = 64Mで試しました。しかし、MYSQLサーバーを再起動している間にエラーが表示されます。助けてくださいいずれか...my.cnfファイルにメモリ制限を設定する方法

のmy.cnf MySQLのmy.cnfファイルにmemory_limitのようなそのような変数がありません

[mysqld] 
datadir=/home/mysql/ 
tmpdir=/home/mysqltmp 
#max_connections = 175 #was 175 
max_connections = 80 
#max_connect_errors = 350 #was 250 
max_connect_errors = 250 
safe-show-database 
skip-locking 
key_buffer = 1024M # was 128M 
max_allowed_packet = 6M 
myisam_sort_buffer_size = 64M 

#old settings, for 900 ish max maxconn 
#sort_buffer_size = 32M 
#read_buffer_size = 32M 
#read_rnd_buffer_size = 32M 

sort_buffer_size = 5M 
read_buffer_size = 5M 
read_rnd_buffer_size = 5M 

query_cache_size= 1024M 
query_cache_limit= 16M 
max_heap_table_size = 128M 
tmp_table_size = 128M 
thread_concurrency = 16 
wait_timeout = 10 
innodb_file_per_table 
innodb_log_file_size = 10485760 
open_files_limit = 8192 
low_priority_updates = 1 
#log_slow_queries = /var/log/mysql_slow.log 
#log_queries_not_using_indexes = 1 
#slow_queries_log_file = /var/log/mysql_slow.log 
memory_limit = 64M 
# who set these? these are NOT memory settings, but rather integer settings. 
#table_cache = 1024M 
#thread_cache_size = 8M 

table_cache = 512 
thread_cache_size = 8 

[mysqldump] 
quick 
max_allowed_packet = 16M 

[mysql] 
no-auto-rehash 

[isamchk] 
key_buffer = 128M 
sort_buffer_size = 128M 
read_buffer = 2M 
write_buffer = 2M 

[myisamchk] 
key_buffer = 128M 
sort_buffer_size = 128M 
read_buffer = 2M 
write_buffer = 2M 
+2

あなたはどんなエラーを出していますか? –

+0

多分私は間違っていますが、PHP構成の 'memory_limit'ではありませんか?詳細: 'my.cnf'はSQLサーバーではなくMySqlについてです。 – Marco

+0

@Aaron Hathaway私はこの' mysqlが失敗したようになっています。結果は "mysqlが実行されていません")。 – Juice

答えて

23

。変数はMySQL server system variablesからのみ追加できます。これをお読みくださいHow Mysql uses memory

これは、MySQLサーバのRAMサイズによって異なります。

key_buffer_size + (read_buffer_size + sort_buffer_size) * max_connections = K bytes of memory 

あなたはこれらの基本的なパラメータを設定する必要があるかもしれません:あなたはそれに応じてMySQLのメモリ要件計算の基本式を以下に基づいてmy.cnfファイルを設定することができます。 my.cnfのファイルから

サンプル変数:

#MyISAM 
key_buffer_size = 8G 
sort_buffer_size = 1M 
read_buffer_size = 1M 
read_rnd_buffer_size = 2M 
myisam_sort_buffer_size = 2M 
join_buffer_size = 2M 

#Innodb 
innodb_buffer_pool_size = 16G 
innodb_additional_mem_pool_size = 2G 
innodb_log_file_size = 1G 
innodb_log_buffer_size = 8M 
innodb_flush_log_at_trx_commit = 1 
innodb_lock_wait_timeout = 30 
innodb_file_format=barracuda 
+0

あなたのサーバは16G以上のRAMを持っていますか? –

1

のMySQLに設定なしのmemory_limit制限はありません。 MySQLのメモリ使用量を管理または制限する唯一の方法は、キャッシュ、バッファ、およびプールサイズの設定を低くすることです(実際の設定名は使用しているストレージエンジンによって異なります)。 MyISAMエンジンに適用される設定エンジン)である:あなたが持っているInnoDBのために

table_cache=1024 
record_buffer=1M 
sort_buffer_size=2M 
read_buffer_size=2M 
read_rnd_buffer_size=2M 
myisam_sort_buffer_size=64M 
thread_cache_size=128 
query_cache_limit=1M 
query_cache_size=64M 
query_cache_type=1 

innodb_buffer_pool_size = 256M 
innodb_additional_mem_pool_size = 20M 
innodb_log_file_size = 64M 
innodb_log_buffer_size = 8M 

あなたはPHPのメモリ制限を変更するために探している場合は、その行(のmemory_limit = 64M)はphp.iniファイルである必要があり、 MySQLの設定ファイルであるmy.cnfはありません。

関連する問題