Linux下安裝redis執行make安裝問題

今天安裝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’
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章