CentOS 1810 安装 Redis 5.0.3

  1. 更新CentOS系统:
    yum -y update
  2. 安装wget vim:
    yum -y install wget vim
  3. 下载 Redis 5.0.3:
    wget http://download.redis.io/releases/redis-5.0.3.tar.gz
  4. 解压:
    tar -zxvf redis-5.0.3.tar.gz
  5. 进入 redis-5.0.3 文件夹:
    cd redis-5.0.3
  6. 编译前安装编译软件:
    yum -y install gcc
     
    1. 编译前安装编译软件: 如果没有安装过gcc,可能会出现如下问题:
      /bin/sh: cc: command not found
  7. 编译:
    make
     
    1. 编译时如果出现:
      zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
       #include <jemalloc/jemalloc.h>
      
      使用以下命令编译:
      make MALLOC=libc
  8. 编译完成,测试安装:
    make test
     
    1. 编译时,如果出现:
      You need tcl 8.5 or newer in order to run the Redis test
      

      则需要安装 tcl,命令:
       

      yum -y install tcl

      然后重新测试安装:

      make test
  9. 测试安装没有问题后,进行编译安装:
    make install
  10. 编译安装完成,进入 utils文件夹:

    cd utils/
  11. 执行 install_server.sh 文件,配置数据库(端口、开机启动等):

    ./install_server.sh
    1. 设置端口:

      Welcome to the redis service installer
      This script will help you easily set up a running redis server
      
      Please select the redis port for this instance: [6379] 

      中文翻译:

      欢迎使用redis服务安装程序
      此脚本将帮助您轻松设置正在运行的redis服务器
      
      请为此实例选择redis端口:[6379]

      如果默认,点击回车,否则输入自定义redis端口。

    2. 设置完端口后,设置配置文件:

      Please select the redis config file name [/etc/redis/6379.conf]

      中文翻译:

      请选择redis配置文件名[/etc/redis/6379.conf]

      如果默认,点击回车,否则输入自定义redis配置文件目录及文件名。

    3. 设置完配置文件后,设置日志配置:

      Please select the redis log file name [/var/log/redis_6379.log] 

      中文翻译:

      请选择redis日志文件名[/var/log/redis_6379.log]

      如果默认,点击回车,否则输入自定义redis日志文件目录及文件名。

    4. 设置完日志配置后,设置数据配置:

      Please select the data directory for this instance [/var/lib/redis/6379] 

      中文翻译:

      请为此实例选择数据目录[/var/lib/redis/6379]

      如果默认,点击回车,否则输入自定义redis数据目录。

    5. 设置完数据配置后,设置执行文件目录:

      Please select the redis executable path [/usr/local/bin/redis-server] 

      中文翻译:

      请选择redis可执行路径[/usr/local/bin/redis-server]

      如果默认,点击回车,否则输入自定义redis可执行文件目录。

    6. 提示:

      Is this ok? Then press ENTER to go on or Ctrl-C to abort.

      中文翻译:

      这个可以吗? 然后按ENTER继续,或按Ctrl-C中止。

      设置完成,点击回车,终止设置,按 Ctrl+C,重新设置需要重新运行。

  12. 常用命令:

    1. 列出服务:

      chkconfig --list
    2. 列出Redis服务:

      chkconfig --list redis_6379
    3. 删除Redis服务:

      chkconfig --del redis_6379
    4. 添加Redis服务:

      chkconfig --add redis_6379
    5. 停止Redis服务:

      /etc/init.d/redis_6379 stop
    6. 启动 Redis服务:

      /etc/init.d/redis_6379 start
    7. 重启Redis服务:

      /etc/init.d/redis_6379 restart
    8. 查看Redis状态:

      /etc/init.d/redis_6379 status

猜你喜欢

转载自blog.csdn.net/qq_32596527/article/details/88080515