Linux Centos-8 安装Redis最新版6.2.4 超全图文教程以及开机自启动

redis官网 : https://redis.io/ 

redis中文官网 : http://redis.cn/

  • redis 下载

  • 我使用的Linux系统是Centos-8

  • 下载工具包
yum install -y gcc gcc-c++
  • yum install gcc 下载下来gcc版本是8.3

  • 如果你的系统是Centos-7 则需要升级gcc

  • 升级gcc
yum install -y centos-release-scl
yum install -y devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile

  • windows下载使用ftp工具上传到linux  或者  使用wget在线下载
yum install -y wget

wget https://download.redis.io/releases/redis-6.2.4.tar.gz
  • 安装redis
tar -xf redis-6.2.4.tar.gz           解压源码包

cd redis-6.2.4                       进入源码包

将redis编译到指定目录  ( 个人喜好 ) 不想编译到指定目录  直接make即可
make PREFIX=/usr/local/redis/ install     

make install                         安装

  • redis 安装成功后同时会把可执行程序放到 /usr/local/bin 下面 
  • 这样可以在任意目录执行redis

  • 生成配置文件
cd /home/src/redis-6.2.4

cd utils/

./install_server.sh

报错: 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!

  • 解决报错 
vim  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
                                      注释掉以上内容

:wq         保存退出

  • redis服务安装
选择redis的端口号  回车是默认6379 自定义就需要自己输入
Please select the redis port for this instance: [6379]                  回车
Selecting default: 6379

配置文件路径以及名称  回车是默认路径/etc/redis/6379.conf  自定义就需要自己输入
Please select the redis config file name [/etc/redis/6379.conf] 
/usr/local/redis/redis.conf

日志文件以及名称    回车是默认路径/var/log/redis_6379.log  自定义就需要自己输入
Please select the redis log file name [/var/log/redis_6379.log] 
/usr/local/redis/log/redis.log

数据目录           回车是默认存放/var/lib/redis/6379  自定义就需要自己输入
Please select the data directory for this instance [/var/lib/redis/6379] 
/usr/local/redis/data

启动文件           回车是默认是/usr/local/bin/redis-server  自定义就需要自己输入
redis安装成功后会在/usr/loacl/bin/redis-server也生成启动文件
Please select the redis executable path [/usr/local/bin/redis-server] 
/usr/local/redis/bin/redis-server

Selected config:
Port           : 6379
Config file    : /usr/local/redis/redis.conf
Log file       : /usr/local/redis/log/redis.log
Data dir       : /usr/local/redis/data
Executable     : /usr/local/redis/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
                                                  检查没毛病就可以回车了
Is this ok? Then press ENTER to go on or Ctrl-C to abort.               回车
  • 注意事项

运行服务安装程序后会让你根据提示安装如果需要指定目录就需要自己手动输入 

不需要指定目录的话一直回车即可

手动输入需要注意 不能使用tab键   不能使用tab键   不能使用tab键  重要事情说三遍

也不能输入错误 如果出错就需要 ctrl+c 退出 重新来

我已经重来了好几遍

  • redis服务安装成功后 redis目录会多出来配置文件以及目录
  • 同时还会在 /etc/init.d/ 下面生成 redis的启动脚本 redis_6379

  • redis设置开机自启动   
  • redis_6379脚本自带了 #chkconfig注释 所以直接添加即可
chkconfig --add redis_6379  

chkconfig --list

  • 重启

  • 成功 ( 过程有点繁琐 多安装几次就简单了 而且这样安装易维护易操作 )

 

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

山山河川

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

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

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

打赏作者

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

抵扣说明:

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

余额充值