<返回更多

CentOS7安装最新版Redis6.0.9

2020-11-23    
加入收藏

前言

今天想试试最新版本的redis,于是乎发现Redis6.x版本要求多了。这里记录下教程,需要的可以查看下。

CentOS7安装最新版Redis6.0.9

 

第一步:升级Gcc

# yum -y install centos-release-scl
# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils

# scl enable devtoolset-9 bash
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAppER=/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-9/root/usr --mandir=/opt/rh/devtoolset-9/root/usr/share/man --infodir=/opt/rh/devtoolset-9/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-9.3.1-20200408/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC) 

其中上面scl命令启用只是临时的,退出shell或重新打开一个shell就会恢复原系统gcc版本,所以需要执行以下命令永久使用gcc 9。

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

# . ~/.bash_profile 

# which gcc
/opt/rh/devtoolset-9/root/usr/bin/gcc

如果没有生效环境变量,则需要重新登录再看看gcc版本。

第二步:编译

[testerzhang@VM-8-7-centos redis-6.0.9]$  mkdir -p bm/redis-6.0.9
[testerzhang@VM-8-7-centos redis-6.0.9]$  cd bm/redis-6.0.9
[testerzhang@VM-8-7-centos redis-6.0.9]$  wget https://download.redis.io/releases/redis-6.0.9.tar.gz?_ga=2.232216794.43188584.1606029760-1221876175.1606029760 -O redis-6.0.9.tar.gz
[testerzhang@VM-8-7-centos redis-6.0.9]$  tar zxf redis-6.0.9.tar.gz
[testerzhang@VM-8-7-centos redis-6.0.9]$  cd redis-6.0.9

[testerzhang@VM-8-7-centos redis-6.0.9]$ mkdir -p ~/3rd/redis-6.0.9
[testerzhang@VM-8-7-centos redis-6.0.9]$ make 
[testerzhang@VM-8-7-centos redis-6.0.9]$ make PREFIX=/home/testerzhang/3rd/redis-6.0.9 install
[testerzhang@VM-8-7-centos redis-6.0.9]$ cp redis.conf  ~/3rd/redis-6.0.9/bin/

查看编译后的文件安装目录

[testerzhang@VM-8-7-centos bin]$ pwd
/home/testerzhang/3rd/redis-6.0.9/bin
[testerzhang@VM-8-7-centos bin]$ ls
redis-benchmark  redis-check-aof  redis-check-rdb  redis-cli  redis.conf  redis-sentinel  redis-server

启动Redis

[testerzhang@VM-8-7-centos bin]$ pwd
/home/testerzhang/3rd/redis-6.0.9/bin
[testerzhang@VM-8-7-centos bin]$ vi redis.conf  
# bind 127.0.0.1 ::1
bind 127.0.0.1

#port 6379
port 16379

# requirepass foobared
requirepass testerzhang
$ ./redis-server redis.conf 

如果是后台运行,则可以加上nohup命令

$ nohup ./redis-server redis.conf & 

验证 Redis服务

[testerzhang@VM-8-7-centos bin]$ pwd
/home/testerzhang/3rd/redis-6.0.9/bin

[testerzhang@VM-8-7-centos bin]$ ./redis-cli -p 16379
127.0.0.1:16379> auth testerzhang
OK
127.0.0.1:16379> set name 123
OK
127.0.0.1:16379> get name
"123"

至此,Redis6.0.9版本安装完毕。

 

结束

主要难在gcc的编译,只要升级gcc版本成功后,其他操作都是很简单。

 

对本文有疑问的可以联系@testerzhang,喜欢的可以加个关注和点赞。

声明:本站部分内容来自互联网,如有版权侵犯或其他问题请与我们联系,我们将立即删除或处理。
▍相关推荐
更多资讯 >>>