なぜ私のサーバーは3GBのメモリしか使用しないのか

なぜ私のサーバーは3GBのメモリしか使用しないのか

サーバーには 24 GB のメモリと 4 つのクアッドコア CPU が搭載されています。Apache/MySQL/php でビジーな Web サイトを実行しており、サーバーの負荷が高すぎるというメッセージが表示されることがあります。ログを見ると、3 GB を超えるメモリが使用されることはなく、奇妙に感じます。これは MySQL または Apache の設定の可能性があります。

ここにいくつかのデータがあります

uname -a
Linux s2274 2.6.32-32-server #62-Ubuntu SMP Wed Apr 20 22:07:43 UTC 2011 x86_64 GNU/Linux


free -m
             total       used       free     shared    buffers     cached
Mem:         24153      20951       3201          0        125      17719
-/+ buffers/cache:       3106      21046
Swap:        11240         14      11226

ご覧のとおり、使用中は 20 GB です。しかし、top/htop を見ると、使用率は 3092 を超えることはありません。プロセッサは実際にはアクティブではなく、平均負荷は 0.9 です。Apache や MySQL が使用するメモリを何らかの方法で増やして、すべてのメモリを使用できるかどうか確認することはできますか?


申し訳ありませんが、しばらく離れていました。以下は、mysqld コマンドからの出力です。

120108  8:48:21 [Note] Plugin 'FEDERATED' is disabled.
  --binlog_cache_size=#
  --bulk_insert_buffer_size=#
  --delayed_queue_size=#
  --join_buffer_size=#
  --key_buffer_size=# The size of the buffer used for index blocks for MyISAM
  --key_cache_block_size=#
  --max_binlog_cache_size=#
  --max_binlog_size=# Binary log will be rotated automatically when the size
                      max_relay_log_size is 0. The minimum value for this
  --max_heap_table_size=#
  --max_join_size=#   Joins that are probably going to read more than
                      max_join_size records return an error.
  --max_relay_log_size=#
                      the size exceeds max_binlog_size. 0 excepted, the minimum
  --myisam_block_size=#
  --myisam_data_pointer_size=#
  --myisam_max_extra_sort_file_size=#
  --myisam_max_sort_file_size=#
  --myisam_sort_buffer_size=#
  --preload_buffer_size=#
  --profiling_history_size=#
  --query_alloc_block_size=#
  --query_cache_size=#
  --query_prealloc_size=#
  --range_alloc_block_size=#
  --read_buffer_size=#
  --read_rnd_buffer_size=#
  --record_buffer=#   Alias for read_buffer_size
  --sort_buffer_size=#
  --thread_cache_size=#
  --tmp_table_size=#  If an internal in-memory temporary table exceeds this
  --transaction_alloc_block_size=#
--transaction_prealloc_size=#
binlog_cache_size                 32768
bulk_insert_buffer_size           8388608
delayed_queue_size                1000
join_buffer_size                  12582912
key_buffer_size                   805306368
key_cache_block_size              1024
max_binlog_cache_size             18446744073709547520
max_binlog_size                   104857600
max_heap_table_size               805306368
max_join_size                     18446744073709551615
max_relay_log_size                0
myisam_block_size                 1024
myisam_data_pointer_size          6
myisam_max_extra_sort_file_size   2147483648
myisam_max_sort_file_size         9223372036853727232
myisam_sort_buffer_size           25165824
preload_buffer_size               32768
profiling_history_size            15
query_alloc_block_size            8192
query_cache_size                  805306368
query_prealloc_size               8192
range_alloc_block_size            4096
read_buffer_size                  25165824
read_rnd_buffer_size              25165824
sort_buffer_size                  25165824
thread_cache_size                 256
tmp_table_size                    805306368
transaction_alloc_block_size      8192
transaction_prealloc_size         4096

PHPのメモリ制限は128Mです

3 GB の制限は、いくつかの状況で見られます。Fi Htop、top、およびサーバー ステータスで Webmin にログインしたときです。(はい、私は iPad から多くの管理を行うので、Webmin を使用しています ;))

ここにスクリーンショットを追加してみます...

答え1

24153 のうち 20951 を使用しています。アプリケーションは 3092 を超えるメモリを要求していないため、カーネルは残りをキャッシュとバッファに使用しています。アプリケーションでより多くのメモリが必要になると、カーネルは新しいアプリケーション要件に対応するためにキャッシュを削減します。

最適なパフォーマンスを得るために MySQL と Apache の設定を調整する方法は、アプリケーションによって異なります。静的 Web サイトなどの場合、大きなファイルシステム キャッシュは効果的です。ただし、データベースとのやり取りが頻繁に行われる動的サイトでは、デフォルトの MySQL 設定を少し変更すると効果的です。

Percona には、MySQL 設定を開始するための優れたツールがあります。http://tools.percona.com/wizard基礎ができたら、アプリケーションの詳細に合わせてさらに調整することができます。

Apache の設定は、トラフィックの量とリクエストのサイズによって異なります。何も知らなければ、デフォルト以外の設定を推奨することは困難です。

答え2

私の推測が正しければ、32ビットサーバーを実行していることになります

32 ビットは、pae イメージを使用しない限り、4 GB のメモリに制限されます。

32 ビット コンピュータのワード サイズは 32 ビットで、理論上メモリは 4 GB に制限されます。この制限は、「物理アドレス拡張」(PAE) の使用によって拡張され、制限は 64 GB まで増加しましたが、4 GB を超えるメモリ アクセスは若干遅くなります。

カーネル イメージに PAE が含まれているかどうかがわかりません。

apt-get install linux-image-generic-pae を試してください。

そうであれば、再起動してメモリの使用量が増加するかどうかを確認してください。

それ以外の場合は、64ビットサーバーのインストールを検討してください

関連情報