今天安装redis出现些之前安装不曾出现错误,一并在此做个记录
一、安装redis及出现错误
首先下载redis,官方下载地址页面:https://redis.io/download
我们这里选择稳定版6.0.5版本
正常安装步骤如下:
注意redis是c编写的,所以依赖gcc环境,安装之前先yum安装gcc环境
[root@hadoop01 app]# yum install gcc
[root@hadoop01 app]# tar -zxvf redis-6.0.5.tar.gz(提前用xftp上传)
[root@hadoop01 app]# cd redis-6.0.5/
[root@hadoop01 app]# make
[root@hadoop01 redis-6.0.5]# cd src/
[root@hadoop01 redis-6.0.5]# make PREFIX=/usr/local/redis install
这里报了如下错误
[root@hadoop01 app]# make
..........
server.c:5127:29: 错误:‘struct redisServer’没有名为‘pidfile’的成员
if (background || server.pidfile) createPidFile();
^
server.c:5132:16: 错误:‘struct redisServer’没有名为‘sentinel_mode’的成员
if (!server.sentinel_mode) {
^
server.c:5142:19: 错误:‘struct redisServer’没有名为‘cluster_enabled’的成员
if (server.cluster_enabled) {
^
server.c:5150:19: 错误:‘struct redisServer’没有名为‘ipfd_count’的成员
if (server.ipfd_count > 0 || server.tlsfd_count > 0)
^
server.c:5150:44: 错误:‘struct redisServer’没有名为‘tlsfd_count’的成员
if (server.ipfd_count > 0 || server.tlsfd_count > 0)
^
server.c:5152:19: 错误:‘struct redisServer’没有名为‘sofd’的成员
if (server.sofd > 0)
^
server.c:5153:94: 错误:‘struct redisServer’没有名为‘unixsocket’的成员
serverLog(LL_NOTICE,"The server is now ready to accept connections at %s", server.unixsocket);
^
server.c:5154:19: 错误:‘struct redisServer’没有名为‘supervised_mode’的成员
if (server.supervised_mode == SUPERVISED_SYSTEMD) {
^
server.c:5155:24: 错误:‘struct redisServer’没有名为‘masterhost’的成员
if (!server.masterhost) {
^
server.c:5168:15: 错误:‘struct redisServer’没有名为‘maxmemory’的成员
if (server.maxmemory > 0 && server.maxmemory < 1024*1024) {
^
server.c:5168:39: 错误:‘struct redisServer’没有名为‘maxmemory’的成员
if (server.maxmemory > 0 && server.maxmemory < 1024*1024) {
^
server.c:5169:176: 错误:‘struct redisServer’没有名为‘maxmemory’的成员
serverLog(LL_WARNING,"WARNING: You specified a maxmemory value that is less than 1MB (current value is %llu bytes). Are you sure this is what you really want?", server.maxmemory);
^
server.c:5172:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员
redisSetCpuAffinity(server.server_cpulist);
^
server.c: 在函数‘hasActiveChildProcess’中:
server.c:1476:1: 警告:在有返回值的函数中,控制流程到达函数尾 [-Wreturn-type]
}
^
server.c: 在函数‘allPersistenceDisabled’中:
server.c:1482:1: 警告:在有返回值的函数中,控制流程到达函数尾 [-Wreturn-type]
}
^
server.c: 在函数‘writeCommandsDeniedByDiskError’中:
server.c:3790:1: 警告:在有返回值的函数中,控制流程到达函数尾 [-Wreturn-type]
}
^
server.c: 在函数‘iAmMaster’中:
server.c:4964:1: 警告:在有返回值的函数中,控制流程到达函数尾 [-Wreturn-type]
}
^
make[1]: *** [server.o] 错误 1
make[1]: 离开目录“/opt/app/redis-6.0.5/src”
make: *** [all] 错误 2
错误原因:
gcc版本老问题,新版本的redis6.0以上,不兼容。
查看gcc版本
gcc -v
[root@hadoop01 redis-6.0.5]# gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
目标:x86_64-redhat-linux
配置为:../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
线程模型:posix
gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
解决办法:升级gcc版本
[root@hadoop01 redis-6.0.5]# gcc -v # 查看gcc版本
[root@hadoop01 redis-6.0.5]# yum -y install centos-release-scl # 升级到9.1版本
[root@hadoop01 redis-6.0.5]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
[root@hadoop01 redis-6.0.5]# scl enable devtoolset-9 bash
以上为临时启用,如果要长期使用gcc 9.1的话:
[root@hadoop01 redis-6.0.5]# echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
查看升级后gcc版本
[root@hadoop01 redis-6.0.5]# 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)
再执行编译
[root@hadoop01 redis-6.0.5]# cd src/
[root@hadoop01 redis-6.0.5]# make PREFIX=/usr/local/redis install
安装成功会出现:Hint: It’s a good idea to run ‘make test’