redis-6版本之后报错server.c:xxxx:xx: error: ‘xxxxxxxx’ has no member named ‘xxxxx’

出现此原因的错误是版本不一致的问题,centos7默认gcc版本是4.8.5,但是这个版本只适用于redis6以前的版本,redis6之后就会报错:

server.c:5101:19: error: ‘struct redisServer’ has no member named ‘sofd’
         if (server.sofd > 0)
                   ^
server.c:5102:94: error: ‘struct redisServer’ has no member named ‘unixsocket’
             serverLog(LL_NOTICE,"The server is now ready to accept connections at %s", server.unixsocket);
                                                                                              ^
server.c:5103:19: error: ‘struct redisServer’ has no member named ‘supervised_mode’
         if (server.supervised_mode == SUPERVISED_SYSTEMD) {
     
                   ^
server.c:5104:24: error: ‘struct redisServer’ has no member named ‘masterhost’
             if (!server.masterhost) {
     
                        ^
server.c:5117:15: error: ‘struct redisServer’ has no member named ‘maxmemory’
     if (server.maxmemory > 0 && server.maxmemory < 1024*1024) {
     
               ^
server.c:5117:39: error: ‘struct redisServer’ has no member named ‘maxmemory

升级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

注意:scl命令启用只是临时的,推出xshell或者重启就会恢复到原来的gcc版本。
如果要长期生效的话,执行如下:

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

大功告成
参考:安装redis-6.0.1报错server.c:xxxx:xx: error: ‘xxxxxxxx’ has no member named ‘xxxxx’

你可能感兴趣的:(踩坑,linux)