5

Redisinfoコマンドを使用して、redisサーバーのすべての統計を取得できます。使用済みメモリメトリックも取得できます。

Redisインスタンスに割り当てられた合計メモリを取得して、使用されたメモリの割合を取得するにはどうすればよいですか?

4

2 に答える 2

8

あなたは次のようなことをすることができます:

$ ps aux -m | grep redis-server | head -n1 |  awk '{printf "VSZ: %dMB, RSS: %dMB\n", $5/1024, $6/1024}'

これにより、redis-serverプロセスの丸められた仮想メモリサイズと実メモリサイズがMB単位で表示されます(実際の数値を確認するには/1024、両方のパラメーターからを削除します)。

于 2013-02-19T11:55:11.583 に答える
4

Redisはデフォルトで、使用可能なすべてのメモリを取得します(必要なだけ、使用可能なすべての物理メモリまで)。maxmemoryただし、ファイル内のパラメータを使用して、Redisに割り当てられるメモリの量を制限できredis.confます。

これはファイルからの抜粋です:

# Don't use more memory than the specified amount of bytes.
# When the memory limit is reached Redis will try to remove keys with an
# EXPIRE set. It will try to start freeing keys that are going to expire
# in little time and preserve keys with a longer time to live.
# Redis will also try to remove objects from free lists if possible.
#
# If all this fails, Redis will start to reply with errors to commands
# that will use more memory, like SET, LPUSH, and so on, and will continue
# to reply to most read-only commands like GET.
#
# WARNING: maxmemory can be a good idea mainly if you want to use Redis as a
# 'state' server or cache, not as a real DB. When Redis is used as a real
# database the memory usage will grow over the weeks, it will be obvious if
# it is going to use too much memory in the long run, and you'll have the time
# to upgrade. With maxmemory after the limit is reached you'll start to get
# errors for write operations, and this may even lead to DB inconsistency.
#
# maxmemory <bytes>
于 2012-07-04T03:42:38.733 に答える