Redis在Ubuntu 14.04上

Lou*_*ieV 3 redis ubuntu-14.04

我从ppa安装了redis 2.8.12,但无法启动.查看日志这是我得到的:

[4886 | signal handler] (1405388991) Received SIGTERM, scheduling shutdown...
[4886] 14 Jul 20:49:51.561 # User requested shutdown...
[4886] 14 Jul 20:49:51.561 * Saving the final RDB snapshot before exiting.
[4886] 14 Jul 20:49:51.566 * DB saved on disk
[4886] 14 Jul 20:49:51.566 * Removing the pid file.
[4886] 14 Jul 20:49:51.566 # Redis is now ready to exit, bye bye...
[6726] 14 Jul 20:56:04.063 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[6726] 14 Jul 20:56:04.063 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[6726] 14 Jul 20:56:04.063 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 2.8.12 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in stand alone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 6726
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

[6726] 14 Jul 20:56:04.064 # Server started, Redis version 2.8.12
[6726] 14 Jul 20:56:04.064 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue 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.
[6726] 14 Jul 20:56:04.064 * The server is now ready to accept connections on port 6379
Run Code Online (Sandbox Code Playgroud)

我确实运行了命令sysctl vm.overcommit_memory=1并按照建议重新启动但没有工作.我不知道该怎么做这一点.有人有想法吗?

Did*_*zia 7

当您收到过度使用警告时,服务器已启动并正在运行.但是,当它将分叉另一个进程来保存数据库(RDB)或压缩AOF时,如果内存不考虑写时复制开销,则可能会出错.

这就是Redis坚持将过度使用模式设置为1的原因.

现在,当您使用sysctl更改内核参数时,它们仅在运行时更改.由于机器已重新启动,您刚刚丢失了此更改.如果您希望定义是永久性的,则还需要将其添加到文件/etc/sysctl.conf中

请注意,除了过度使用内存问题之外,您还遇到有关文件描述符数量的问题.这可以通过调整/etc/security/limits.conf文件(nofile参数)或在某些情况下调整会话的ulimit设置来增加.