在linux上安装redis-5.0.8,依赖安装以及三个警告解决方案

安装

使用默认centOS7.0,安装前拷贝redis.5.0.8到系统路径下

[root@ aaa redis]# tar -zxvf redis-5.0.8
[root@ aaa redis]# cd redis-5.0.8
[root@ aaa redis-5.0.8]# make test

上面一步会出错的话,根据提示安装依赖包即可:gcc和tcl

[root@ aaa redis-5.0.8]# yum install gcc-c++
[root@ aaa redis-5.0.8]# yum install tcl
fatal error: jemalloc/jemalloc.h: No such file or directory #include <jemalloc/jemalloc.h>
分配器allocator, 如果有MALLOC  这个 环境变量, 会有用这个环境变量的 去建立Redis。

而且libc 并不是默认的 分配器, 默认的是 jemalloc, 因为 jemalloc 被证明 有更少的 fragmentation problems 比libc。

但是如果你又没有jemalloc 而只有 libc 当然 make 出错。 所以加这么一个参数,运行如下命令:

make MALLOC=libc

然后安装

[root@ aaa redis-5.0.8]# make install
cd src && make install
make[1]: Entering directory `/root/redis/redis-5.0.8/src'

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/root/redis/redis-5.0.8/src'

出现以上提示即成功

启动

[root@ aaa redis-5.0.8]# cd src
[root@ aaa src]# redis-server 
95739:C 12 Jun 2020 14:02:41.290 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
95739:C 12 Jun 2020 14:02:41.290 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=95739, just started
95739:C 12 Jun 2020 14:02:41.290 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.8 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 95739
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

95739:M 12 Jun 2020 14:02:41.292 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
95739:M 12 Jun 2020 14:02:41.292 # Server initialized
95739:M 12 Jun 2020 14:02:41.292 # 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.
95739:M 12 Jun 2020 14:02:41.292 # 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.
95739:M 12 Jun 2020 14:02:41.292 * DB loaded from disk: 0.000 seconds
95739:M 12 Jun 2020 14:02:41.292 * Ready to accept connections
^C95739:signal-handler (1591941775) Received SIGINT scheduling shutdown...
95739:M 12 Jun 2020 14:02:55.214 # User requested shutdown...
95739:M 12 Jun 2020 14:02:55.214 * Saving the final RDB snapshot before exiting.
95739:M 12 Jun 2020 14:02:55.216 * DB saved on disk
95739:M 12 Jun 2020 14:02:55.216 # Redis is now ready to exit, bye bye...

此时报出三个警告,解决方案:

執行:vi /etc/sysctl.conf
在下方添加兩行,保存並退出
net.core.somaxconn = 2048 #此值根据你的内存自己写定义,大于511即可
vm.overcommit_memory = 1

執行:sysctl vm.overcommit_memory=1
執行:cd /etc/default/
執行:cp grub grub.bak(備份)
執行:vi grub
在GRUB_CMDLINE_LINUX行的值後面增加transparent_hugepage=never保存並退出
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet transparent_hugepage=never"

執行:grub2-mkconfig -o /boot/grub2/grub.cfg
執行:init 6(重啟OS)

对上方不理解可以参考:https://article.itxueyuan.com/qJAP7

指定配置文件启动

将原配置文件备份一份,做好配置文件后放到redis解压目录下。即redis-5.0.8目录下,当然你放在src目录下也是一样的。

[root@ aaa src]# redis-server ../redis.conf

一般conf改动的位置是bind 127.0.0.1注释掉(去除IP绑定)
protectMode 改为no(关闭保护模式)
daemonize 改为yes(后台运行)
即可使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值