Linux下Redis安装步骤

Redis安装步骤

  1. 下载地址:

    https://redis.io/(英文网站)

    http://redis.cn/(中文网站)

  2. 在redis下载网站,复制下载地址,然后再linux中通过wget下载

    wget http://download.redis.io/releases/redis-6.0.6.tar.gz
    
  3. 解压

    tar -xf redis-6.0.6.tar.gz
    
  4. 进入解压后的目录

    cd redis-6.0.6
    
  5. 安装

    make
    

    如果安装失败,检查是否安装gcc,或者gcc版本是否过低

    查看gcc版本

    gcc -v
    

    未安装的话安装gcc

    yum install gcc
    

    版本过低的话升级gcc

    gcc -v      #查看gcc版本
    yum -y install centos-release-scl  # 升级到9.1版本
    yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
    scl enable devtoolset-9 bash
    echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
    

    清除之前make产生的垃圾文件

    make distclean
    

    升级完了gcc版本后,再重新make,就不会报错了,执行完成后会提示安装成功

  6. 配置环境变量

    执行安装路径

    make install PREFIX=/usr/djh/redis-6.0.6
    

    配置环境变量

     vi /etc/profile
    
    export REDIS_HOME=/usr/djh/redis-6.0.6
    export PATH=$PATH:${REDIS_HOME}/bin
    
  7. 刷新profile文件

    source /etc/profile
    
  8. 执行utis目录下的 install_server.sh

    ./install_server.sh 
    

    如果提示错误信息:

    [root@VM-0-6-centos utils]# ./install_server.sh 
    Welcome to the redis service installer
    This script will help you easily set up a running redis server
     
    This systems seems to use systemd.
    Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!
    

    那么编辑install_server.sh文件

    vi ./install_server.sh
    

    注释掉下面这段代码,然后重新执行install_server.sh

    #bail if this system is managed by systemd
    #_pid_1_exe="$(readlink -f /proc/1/exe)"
    #if [ "${_pid_1_exe##*/}" = systemd ]
    #then
    #       echo "This systems seems to use systemd."
    #       echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
    #       exit 1
    #fi
    
  9. 重新执行 ./install_server.sh(可以执行一次或多次)

    ./install_server.sh
    

    一个物理机中可以有多个redis实例,通过port区分

  10. 提示信息,直接默认

    Please select the redis config file name [/etc/redis/6379.conf] 
    Selected default - /etc/redis/6379.conf
    Please select the redis log file name [/var/log/redis_6379.log] 
    Selected default - /var/log/redis_6379.log
    Please select the data directory for this instance [/var/lib/redis/6379] 
    Selected default - /var/lib/redis/6379
    Please select the redis executable path [/usr/djh/redis-6.0.6/bin/redis-server] 
    Selected config:
    Port           : 6379
    Config file    : /etc/redis/6379.conf
    Log file       : /var/log/redis_6379.log
    Data dir       : /var/lib/redis/6379
    Executable     : /usr/djh/redis-6.0.6/bin/redis-server
    Cli Executable : /usr/djh/redis-6.0.6/bin/redis-cli
    Is this ok? Then press ENTER to go on or Ctrl-C to abort.
    Copied /tmp/6379.conf => /etc/init.d/redis_6379
    Installing service...
    Successfully added to chkconfig!
    Successfully added to runlevels 345!
    Starting Redis server...
    Installation successful!
    
  11. 默认已经启动了redis,查看redis状态

    [root@iZuf6dr78if7es8xuck0tyZ utils]# cd /etc/init.d/
    [root@iZuf6dr78if7es8xuck0tyZ init.d]# ll
    总用量 44
    -rw-r--r-- 1 root root 18281 522 2020 functions
    -rwxr-xr-x 1 root root  4569 522 2020 netconsole
    -rwxr-xr-x 1 root root  7928 522 2020 network
    -rw-r--r-- 1 root root  1160 23 2021 README
    -rwxr-xr-x 1 root root  1712 37 15:40 redis_6379
    [root@iZuf6dr78if7es8xuck0tyZ init.d]# service redis_6379 status
    cat: /var/run/redis_6379.pid: No such file or directory
    Redis is running (16924)
    

    此时redis成系统服务,可以通过 service redis_6379 start/stop/status控制redis服务

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

像鸟一样菜

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值