web-dev-qa-db-ja.com

Linuxメモリ管理でswappinessを構成する方法は?

Swappinessパラメータは、物理メモリからスワップディスクにプロセスを移動するカーネルの傾向を制御します。デフォルト設定とは何ですか全体的なパフォーマンスを向上させるために設定する方法

11
GAD3R

Linuxカーネルは、スワップを制御する調整可能な設定を提供します

$ cat /proc/sys/vm/swappiness
60  

開いた /etc/sysctl.confをルートとして。次に、次の行を変更するか、ファイルに追加します。

vm.swappiness = 10

swappiness値を一時的に変更するには、次のコマンドを試してください:

$ echo 50 > /proc/sys/vm/swappiness
10
Mongrel

から Swappiness、Wikipedia

この値は、virtualファイルで設定できます/proc/sys/vm/swappiness上記の値は、スワップスペースの使用方法を決定します。以下に値を示します。彼らの意図で。

vm.swappiness = 0   # Swap is disabled. In earlier versions, this meant that the kernel would swap only to avoid an out of memory condition, but in later versions this is achieved by setting to 1.
vm.swappiness = 1   # Kernel version 3.5 and over, as well as kernel version 2.6.32-303 and over: Minimum amount of swapping without disabling it entirely.
vm.swappiness = 10  # This value is sometimes recommended to improve performance when sufficient memory exists in a system, this value *10* could be considered for the performance being expected. 
vm.swappiness = 60  # The default value.
vm.swappiness = 100 # The kernel will swap aggressively.

実際には必要性にも依存しますが、利用可能な物理メモリが十分である場合、スワップ領域の大きな必要性はないかもしれません。Laymanの用語では、60のデフォルト値を変更する必要はありません。

11
Keyshov Borate

RedHat/CentOSでは、デフォルト値は60です。
「パフォーマンスを向上させるために」は非常に広い用語です。どのようなパフォーマンスを改善しようとしていますか?

メモリ不足の問題がありますか?
空きメモリ/キャッシュされたメモリがまだある場合、システムはスワップしますか?

Linuxでは、空きメモリRAM =無駄なRAMであるため、ほとんどすべての空きメモリがディスクキャッシュに使用されます。
swappiness = 60の場合、未割り当てのRAMに関係なく、メモリ内のページが長時間アクセスされなかった場合にSWAPに移動されることがあります。
一部のメモリページをSWAPに移動することは、必ずしも悪いことではありません。

より詳細な回答を得るには、問題をさらに詳しく説明してください。

2
fireto