vlambda博客
学习文章列表

Linux安装Redis遇到的问题及解决方案-记录

1.可能会因为服务器中gcc版本的问题报错,如遇到报错就更新


  
    
    
  
  1. make[1]: *** [server.o] 错误 1

  2. make[1]: 离开目录“/usr/redis-6.0.1/src”

  3. make: *** [all] 错误 2

  4. server.c:2402:11: 错误:‘struct redisServer’没有名为‘assert_file’的成员

  5. server.assert_file = "<no file>";

  6. ^

  7. server.c:2403:11: 错误:‘struct redisServer’没有名为‘assert_line’的成员

  8. server.assert_line = 0;

  9. ^

  10. server.c:2404:11: 错误:‘struct redisServer’没有名为‘bug_report_start’的成员

  11. server.bug_report_start = 0;

  12. ^

  13. server.c:2405:11: 错误:‘struct redisServer’没有名为‘watchdog_period’的成员

  14. server.watchdog_period = 0;

  15. ^

  16. server.c:2411:11: 错误:‘struct redisServer’没有名为‘lua_always_replicate_commands’的成员

  17. server.lua_always_replicate_commands = 1;


解决方案 


  
    
    
  
  1. [root@hadoop-master redis-6.0.5]# gcc -v # 查看gcc版本

  2. [root@hadoop-master redis-6.0.5]# yum -y install centos-release-scl # 升级到9.1版本

  3. [root@hadoop-master redis-6.0.5]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils

  4. [root@hadoop-master redis-6.0.5]# scl enable devtoolset-9 bash

  5. 以上为临时启用,如果要长期使用gcc 9.1的话:

  6. [root@hadoop-master redis-6.0.5]# echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile

再次执行

   


   
     
     
   
  1. #指定安装的位置

  2. [root@hadoop-master redis-6.0.5]# make install PREFIX=/mnt/redis

成功提示 

 2.执行make test出错解决方案


  
    
    
  
  1. [root@localhost redis-6.0.5]# yum install tcl

  2. [root@localhost redis-6.0.5]# make test

3.启动redis


  
    
    
  
  1. [root@hadoop-master redis]# cd /mnt/redis/bin/


  2. #指定配置文件

  3. [root@hadoop-master bin]# ./redis-server ../redis-6.0.5/redis.conf


可能遇到的遇到的警告提示


  
    
    
  
  1. # 启动server出现的问题

  2. src/redis-server


  3. # warning 1 > 提示修改 linux内核参数

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

  5. echo 1024 >/proc/sys/net/core/somaxconn


  6. # warn 2 > 提示如下

  7. # 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.

  8. echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf


  9. sysctl vm.overcommit_memory=1


  10. # warning 3

  11. # 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

  12. echo never > /sys/kernel/mm/transparent_hugepage/enabled

  13. # 云服务器要注意ip要写对,端口要开放

  14. # 虚拟机要注意防火墙要关闭 systemctl stop firewalld.service

正常启动画面