redis-server除了启动Redis外,还有一个–test-memory选项。redis-server –test-memory可以用来检测当前操作系统能否稳定地分配指定容量的内存给Redis,通过这种检测可以有效避免因为内存问题造成Redis崩溃,例如下面操作检测当前操作系统能否提供1G的内存给Redis:
[root@vmzq1l0l ~]# redis-server --test-memory 1024
整个内存检测的时间比较长。当输出passed this test时说明内存检测完毕,最后会提示–test-memory只是简单检测,如果有质疑可以使用更加专业的内存检测工具:
.
.
.
======================================================================================================================================================================.....................................................................................................Please keep the test running several minutes per GB of memory.
Also check http://www.memtest86.com/ and http://pyropus.ca/software/memtester/
Your memory passed this test.
Please if you are still in doubt use the following two tools:
1) memtest86: http://www.memtest86.com/
2) memtester: http://pyropus.ca/software/memtester/
通常无需每次开启Redis实例时都执行–test-memory选项,该功能更偏向于调试和测试,例如,想快速占满机器内存做一些极端条件的测试,这个功能是一个不错的选择。