CentOS7安装最新版Redis6.0.9

前言今天想试试最新版本的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 -vUsing built-in specs.COLLECT_GCC=gccCOLLECT_LTO_WRAppER=/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapperTarget: x86_64-redhat-linuxConfigured 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-linuxThread model: posixgcc 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]$ lsredis-benchmarkredis-check-aofredis-check-rdbredis-cliredis.confredis-sentinelredis-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 ::1bind 127.0.0.1#port 6379port 16379# requirepass foobaredrequirepass 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 16379127.0.0.1:16379> auth testerzhangOK127.0.0.1:16379> set name 123OK127.0.0.1:16379> get name"123"至此,Redis6.0.9版本安装完毕 。
 
结束主要难在gcc的编译,只要升级gcc版本成功后,其他操作都是很简单 。
 
对本文有疑问的可以联系@testerzhang,喜欢的可以加个关注和点赞 。

【CentOS7安装最新版Redis6.0.9】


    推荐阅读