/**PageBeginHtml Block Begin **/ /***自定义返回顶部小火箭***/ /*生成博客目录的JS 开始*/ /*生成博客目录的JS 结束*/

史上最详细Centos7安装Redis教程

henry_2016:《史上最详细Centos7安装Redis教程


1、安装环境


[root@192 ~]# lsb_release -a
LSB Version:	:core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:	CentOS
Description:	CentOS Linux release 7.3.1611 (Core)
Release:	7.3.1611
Codename:	Core
[root@192 ~]# 

注意:如果执行该命令如下图请情况,请参阅此文:《CentOS 7 命令lsb_release: command not found解决方案

image

2、Redis下载

image


`进入到/usr/local/src/目录下`
[root@m src]# cd /usr/local/src/

`下载Reids`
[root@m src]# wget http://download.redis.io/releases/redis-5.0.8.tar.gz


3、安装

3.1、检查是否安装了gcc

由于 redis 是使用 C 语言开发的,在安装之前需要先确认一下是否安装了 gcc 环境,先来查看一下:

安装gcc依赖

[root@iZwz991stxdwj560bfmadtZ local]# yum install gcc


[root@192 src]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
[root@192 src]# 



如果未安装可执行如下语句:

yum -y install gcc



3.2、安装

#`进入下载目录进行解压`
[root@m src]# cd /usr/local/src/
[root@m src]# tar -zvxf redis-5.0.8.tar.gz 

[root@m src]# ls
redis-5.0.8  redis-5.0.8.tar.gz

#`进入到redis安装包中`
[root@m src]# cd redis-5.0.8/

#`进行编译`
[root@m redis-5.0.8]# make

#`安装到指定目录`
[root@m redis-5.0.8]# cd src
[root@m src]# make install prefix=/usr/local/redis



4、启动redis

4.1 启动

[root@m bin]# cd /usr/local/redis/bin
`启动redis`
[root@m bin]# ./redis-server 





4.2 后台启动

`将redis.conf复制到安装目录下`
[root@m bin]# cd /usr/local/redis/bin
[root@m bin]# cp /usr/local/src/redis-5.0.8/redis.conf ./


  • 修改redis.conf文件:
daemonize no

改为

daemonize yes
  • 启动redis
`启动redis服务端`
[root@m bin]# redis-server ./redis.conf 
10115:C 26 Mar 2020 20:59:44.525 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10115:C 26 Mar 2020 20:59:44.525 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=10115, just started
10115:C 26 Mar 2020 20:59:44.525 # Configuration loaded

`启动redis客户端`
[root@m bin]# ./redis-cli 
127.0.0.1:6379>


关闭redis





5、开机启动

5.1、开机自启动脚本

1)修改脚本































posted @ 2021-05-03 22:05  一品堂.技术学习笔记  阅读(1685)  评论(0编辑  收藏  举报