This is the 28th day of my participation in Gwen Challenge

If the operation

Avoid the following errors

yum -y install gcc tcl
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile 
Copy the code

1. Download the Redis

Redis. IO /

Wget HTTP: / / http://download.redis.io/releases/redis-6.0.3.tar.gzCopy the code

2. Install Redis

2.1 compiling Redis

Tar -zxv -f redis-6.0.3.tar.gz -c /usr/local/cd redis-6.0.3 make MALLOC=libc make testCopy the code

Run make install in the root directory of redis. This will copy some scripts from redis/ SRC to the /usr/local/bin/ directory because /usr/local/bin/ has been configured in the path environment variable. Therefore, the purpose of executing this command is to directly start and stop Redis in any directory.

# make install 
Copy the code

Common mistakes

make[3]: cc: Command not found make[3]: *** [net.o] Error 127 make[3]: Leaving directory '/usr/local/redis-6.0.1/deps/hiredis' make[2]: *** [hiredis] Error 2 make[2]: Leaving directory '/usr/local/redis-6.0.1/deps' make[1]: [persist- Settings] Error 2 (ignored) CC adlist.o /bin/sh: CC: Command not found make[1]: *** [adlist.o] Error 127 make[1]: Leaving directory '/usr/local/redis-6.0.1/ SRC' make: *** [all] Error 2Copy the code

Install GCC :yum install GCC 2

server.c:5099:19: error: 'struct redisServer' has no member named 'ipfd_count if (for server ipfd_count > 0 | | server tlsfd_count > 0) ^ server.c:5099:44: error: 'struct redisServer' has no member named 'tlsfd_count if (for server ipfd_count > 0 | | server tlsfd_count > 0) ^ Struct redisServer 'has no member named' sofd 'if (server.sofd > 0) ^ server.c:5102:94: 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. Container == container 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' if (server. maxMemory > 0 && server. maxMemory < 1024*1024) {^ Server. c:5118:176: error: 'struct redisServer' has no member named '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: In function 'hasActiveChildProcess' : server.c:1476:1: Warning: Control reaches end of non-void function [-wreturn-type]} ^ server.c: In function 'allenceDisabled' : server.c:1482:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ server.c: In the function 'writeCommandsDeniedByDiskError: server. C: 3747:1: warning: Control reaches end of non-void function [-wreturn-type]} ^ server.c: In function 'iAmMaster' : server.c:4914:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ make[1]: *** [server.o] Error 1 make[1]: Leaving directory '/usr/local/redis-6.0.1/ SRC' make: *** [all] Error 2Copy the code

Solution: check whether the GCC version is 5.3 or later. CentOS7 has 4.8.5 installed by default. Upgrade GCC to version 5.3 or later to GCC 9

GCC -v Using built-in specs. COLLECT_GCC= GCC COLLECT_LTO_WRAPPER=/usr/libexec/ GCC/x86_64-Redhat-linux /4.8.5/lto-wrapper Target: x86_64-redhat-linux Configured with: .. /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 Thread model: Posix GCC Version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)Copy the code

In case of compilation errors, it is also possible to clear the compiled generated file without executing it

make distclean

yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils 
Copy the code

Note that the SCL command is only temporarily enabled, and exiting the shell or restarting a shell will restore the original system GCC version

scl enable devtoolset-9 bash gcc -v

Echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile ``` ``` zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory #include <jemalloc/jemalloc.h> ^ compilation terminated. make[1]: / *** [adlist.o] Error 1 make[1]: Leaving directory '/usr/local/redis-6.0.1/ SRC' make: *** [all] Error 2: ' 'make MALLOC=libc'Copy the code