Redis Server installation FAQs

ε祈祈猫儿з 提交于 2021-01-12 04:20:35

OS: CentOS 7 Minimal

 

(0) open files

Q: Increased maximum number of open files to 10032 (it was originally set to 1024).
A:

$ulimit -a
$vi /etc/systemd/system/redis.service

 

    In the "[Service]" unit, add the following:

LimitNOFILE=10032

 

(1) somaxconn
Q: WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

A:
$vi /etc/sysctl.conf

net.core.somaxconn=1024

 


(2) overcommit_memory
Q: 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.

A:

$echo "vm.overcommit_memory=1" > /etc/sysctl.conf
$reboot
$echo 1 > /proc/sys/vm/overcommit_memory

 


(3) thp disable
Q: WARNING you have Transparent Huge Pages (THP) support enabled in your kernel.
This will create latency and memory usage issues with Redis.
To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root,
and add it to your /etc/rc.local in order to retain the setting after a reboot.
Redis must be restarted after THP is disabled.

A:

    reference: https://www.centos.org/forums/viewtopic.php?t=49428

$vi /etc/rc.d/rc.local

echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

$chmod +x /etc/rc.d/rc.local

 

redis.log

980:M 02 Sep 05:35:36.921 # User requested shutdown...
980:M 02 Sep 05:35:36.921 * Saving the final RDB snapshot before exiting.
980:M 02 Sep 05:35:36.927 * DB saved on disk
980:M 02 Sep 05:35:36.927 * Removing the pid file.
980:M 02 Sep 05:35:36.928 # Redis is now ready to exit, bye bye...
975:C 02 Sep 05:36:07.493 # systemd supervision requested, but NOTIFY_SOCKET not found
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.12 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 981
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

981:M 02 Sep 05:36:07.544 # Server started, Redis version 3.2.12
981:M 02 Sep 05:36:07.545 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
981:M 02 Sep 05:36:07.550 * DB loaded from disk: 0.005 seconds
981:M 02 Sep 05:36:07.550 * The server is now ready to accept connections on port 6379
981:M 02 Sep 05:38:47.949 # User requested shutdown...
981:M 02 Sep 05:38:47.949 * Saving the final RDB snapshot before exiting.
981:M 02 Sep 05:38:47.964 * DB saved on disk
981:M 02 Sep 05:38:47.964 * Removing the pid file.
981:M 02 Sep 05:38:47.965 # Redis is now ready to exit, bye bye...
969:C 02 Sep 05:39:18.272 # systemd supervision requested, but NOTIFY_SOCKET not found
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.12 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 978
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

978:M 02 Sep 05:39:18.340 # Server started, Redis version 3.2.12
978:M 02 Sep 05:39:18.361 * DB loaded from disk: 0.007 seconds
978:M 02 Sep 05:39:18.361 * The server is now ready to accept connections on port 6379
/var/log/redis.log

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!