Redis管理
Redis setup hints
1.Make sure to set the Linux kernel overcommit memory setting to 1. Add vm.overcommit_memory = 1
to /etc/sysctl.conf
and then reboot or run the command sysctl vm.overcommit_memory=1
for this to take effect immediately.
确保设置Linux内核内存过量使用设置为1.在/etc/sysctl.conf中添加vm.overcommit_memory=1然后重启或者执行sysctl vm.overcommit_memory=1立即生效
2.Make sure to disable Linux kernel feature transparent huge pages, it will affect greatly both memory usage and latency in a negative way. This is accomplished with the following command: echo never > /sys/kernel/mm/transparent_hugepage/enabled
.
确保关闭Linux内核的传输大页面的功能,它将很大程度上对内存使用和延迟产生巨大的负面影响。通过执行echo never>/sys/kernel/mm/transparent_hugepage/enabled命令可以实现
3.Make sure to setup some swap in your system (we suggest as much as swap as memory). If Linux does not have swap and your Redis instance accidentally consumes too much memory, either Redis will crash for out of memory or the Linux kernel OOM killer will kill the Redis process.
确保系统中设定一些交换空间
4.Set an explicit maxmemory
option limit in your instance in order to make sure that the instance will report errors instead of failing when the system memory limit is near to be reached.
在实例中为maxmemory选项设定一个明确的值,目的是为了确保实例在系统内存即将到达极限时会报告错误而不是崩溃
5.If you are using Redis in a very write-heavy application, while saving an RDB file on disk or rewriting the AOF log Redis may use up to 2 times the memory normally used. The additional memory used is proportional to the number of memory pages modified by writes during the saving process, so it is often proportional to the number of keys (or aggregate types items) touched during this time. Make sure to size your memory accordingly.
如果将redis使用在一个频繁执行写操作的应用中,同时保存一个RDB文件到磁盘中或者重写AOF日志文件,Redis可能会使用正常内存使用的两倍。额外的内存被很大一部分被用于在保存RDB文件或者修改AOF日志文件时的内存页面修改,
6.If you are using replication, make sure that either your master has persistence enabled, or that it does not automatically restarts on crashes: slaves will try to be an exact copy of the master, so if a master restarts with an empty data set, slaves will be wiped as well.
若使用Redis的复制功能, 确保主数据库开启持久化,或者没有在崩溃时自动重启:从数据库将试图成为主数据库的完整拷贝,所以如果主数据库以空数据集重启,从数据库将被清空。