Linux版Redis(5.0.8)环境搭建

585 阅读2分钟

一、下载

Redis官网

5.0.8源码 download.redis.io/releases/re…

二、安装

将 redis-5.0.8.tar.gz 上传至服务器 /usr/local/redis 目录下。

由于是源码安装,需要准备gcc环境,gcc环境可以自己百度下。 我这里的版本如下:

[root@vm ~]# gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilthreads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --n,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-mclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC) 

1.解压

tar -zxvf redis-5.0.8.tar.gz

[root@vm redis]# tar -zxvf redis-5.0.8.tar.gz
...
redis-5.0.8/utils/releasetools/01_create_tarball.sh
redis-5.0.8/utils/releasetools/02_upload_tarball.sh
redis-5.0.8/utils/releasetools/03_test_release.sh
redis-5.0.8/utils/releasetools/04_release_hash.sh
redis-5.0.8/utils/releasetools/changelog.tcl
redis-5.0.8/utils/speed-regression.tcl
redis-5.0.8/utils/whatisdoing.sh
[root@vm redis]# ll
total 3660
-rw-r--r-- 1 root root 1755956 Jul 14 15:30 redis-4.0.14.tar.gz
drwxrwxr-x 6 root root    4096 Mar 12 23:07 redis-5.0.8
-rw-r--r-- 1 root root 1985757 Jul 21 09:18 redis-5.0.8.tar.gz

2.编译

  1. 进入解压目录 redis-5.0.8。

cd redis-5.0.8

  1. 执行 make,等待编译,需要花点时间等待一下。
[root@vm redis-5.0.8]# make
...
    LINK redis-cli
    CC redis-benchmark.o
    LINK redis-benchmark
    INSTALL redis-check-rdb
    INSTALL redis-check-aof

Hint: It's a good idea to run 'make test' ;)

make[1]: Leaving directory `/usr/local/redis/redis-5.0.8/src'
[root@vm redis-5.0.8]# 
  1. 安装到指定目录 make PREFIX=/usr/local/redis install
[root@vm redis-5.0.8]# make PREFIX=/usr/local/redis install
cd src && make install
make[1]: Entering directory `/usr/local/redis/redis-5.0.8/src'
    CC Makefile.dep
make[1]: Leaving directory `/usr/local/redis/redis-5.0.8/src'
make[1]: Entering directory `/usr/local/redis/redis-5.0.8/src'

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/usr/local/redis/redis-5.0.8/src'
[root@vm redis-5.0.8]# 

三、配置

进入 cd /usr/local/redis 目录,创建 mkdir conf 目录。从源码目录中拷贝 redis.conf 文件。

cp /usr/local/redis/redis-5.0.8/redis.conf /usr/local/redis/conf

[修改配置文件]

cd /usr/local/redis/conf

  • daemonize 是否在后台执行 ,yes:后台运行;no:不是后台运行
  • bind 绑定ip,默认本机
  • requirepass 访问密码,默认无密码
...
daemonize yes
...
bind 192.168.10.203
...
requirepass abc#@!
...

四、运行

cd /usr/local/redis

[root@vm redis]# ./bin/redis-server ./conf/redis.conf 
3908:C 21 Jul 2020 10:00:52.775 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
3908:C 21 Jul 2020 10:00:52.775 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=3908, just started
3908:C 21 Jul 2020 10:00:52.775 # Configuration loaded
[root@vm redis]# ps -ef | grep redis
root      3909     1  0 10:00 ?        00:00:00 ./bin/redis-server 192.168.10.203:6379
root      3939 32031  0 10:01 pts/1    00:00:00 grep redis
[root@vm redis]# 

Redis 5.0 正式版发布了,19 个新特性!
CentOS 7之Redis4.0.14安装
CentOS7.5中安装redis5.0(实践踩坑版)
redis最全配置讲解