公告:魔扣目录网为广大站长提供免费收录网站服务,提交前请做好本站友链:【 网站目录:https://www.morko.net 】, 免友链快审服务(50元/站),

点击这里在线咨询客服
新站提交
  • 网站:51998
  • 待审:31
  • 小程序:12
  • 文章:1030137
  • 会员:747

前言

今天想试试最新版本的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,喜欢的可以加个关注和点赞。

分享到:
标签:Redis
用户无头像

网友整理

注册时间:

网站:5 个   小程序:0 个  文章:12 篇

  • 51998

    网站

  • 12

    小程序

  • 1030137

    文章

  • 747

    会员

赶快注册账号,推广您的网站吧!
最新入驻小程序

数独大挑战2018-06-03

数独一种数学游戏,玩家需要根据9

答题星2018-06-03

您可以通过答题星轻松地创建试卷

全阶人生考试2018-06-03

各种考试题,题库,初中,高中,大学四六

运动步数有氧达人2018-06-03

记录运动步数,积累氧气值。还可偷

每日养生app2018-06-03

每日养生,天天健康

体育训练成绩评定2018-06-03

通用课目体育训练成绩评定