网站首页> 文章专栏> Centos7 安装Redis过程
Centos7 安装Redis过程
日期:2020-08-23 21:25:23 作者:jzlnice 浏览量:2211

参考链接:https://www.miboxapp.com/article/detail/1146659339214393344


1、安装gcc

   Redis安装需依赖gcc,所以需先安装gcc

   命令 yum install gcc

 

2、下载Redis

前往 Redis 官网下载安装包,下载地址:https://redis.io/download

3、下载完后,通过winscp将安装包 上传到服务器 /home 目录

4、解压

   cd /home (切换到home目录)

   tar -zxvf redis-6.0.6.tar.gz

   

5、编译安装

   cd /home/redis-6.0.6

   make

   make install PREFIX=/usr/local/redis

   cp redis.conf /usr/local/redis/bin

   修改redis配置文件

   vi /usr/local/redis/bin/redis.conf

   找到 daemonize i 进入编辑模式 把no 改成 yes 并保存退出

(按ESC +:wq保存退出)

 

   我按上述命令编译时,直接报错

   

   后查明 redis6.0 以上编译,gcc版本需要5.3以上,而centos 7 默认版本是4.8.5

   gcc -v 查询gcc版本

   

   解决方案

#升级到 5.3及以上版本 

yum -y install centos-release-scl

yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils scl enable devtoolset-9 bash

注意:scl命令启用只是临时的,推出xshell或者重启就会恢复到原来的gcc版本。
如果要长期生效的话,执行如下:

echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile

注:执行完此命令后,重新打开xshell窗口就是新版的gcc了。
以下其他版本同理,修改devtoolset版本号即可。


升级完gcc 版本,再编译安装 redis



6、开机启动Redis 配置

  在系统服务目录里创建redis.service文件

  vi /etc/systemd/system/redis.service

  在配置文件中写入以下内容

 

Unit]

Description=redis-sever

After=network.target

 

[Service]

Type=forking

ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf

PrivateTmp=true

 

[Install]

WantedBy=multi-user.target

 

7、启用Redis 服务并设置开机启动

   执行下面命令启动Redis服务

Systemctl start redis.service

Systemctl enable redis.service

 

8、查看Redis 运行状态

systemctl status redis.service


来说两句吧
最新评论
    热门文章
      随便看看