Redisのmaxmemoryの動的変更の注意点

Overview

redis-cliconfig set で指定できるのはバイト数のみ

内容

redisのメモリ上限をあげる必要があったので対応記録です。

redis.io

In options where bytes or other quantities are specified, it is not possible to use the redis.conf abbreviated form (10k, 2gb ... and so forth), everything should be specified as a well-formed 64-bit integer, in the base unit of the configuration directive. However since Redis version 3.0 or greater, it is possible to use CONFIG SET with memory units for maxmemory, client output buffers, and replication backlog size.

設定値を更新する形式に、redis.conf省略形は利用することができない。そのため、400MB の数値は、4294967296 とバイトで指定する必要がある。

現在のメモリ最大数

$ redis-cli config get maxmemory
1) "maxmemory"
2) "209715200"

実行

$ redis-cli config set maxmemory 4294967296
OK

適用後のメモリ最大数

$ redis-cli config get maxmemory
1) "maxmemory"
2) "4294967296"

その後、redis.confも動的に変更しておしまい。