下载源码安装包 wget http://download.redis.io/releases/redis-6.0.8.tar.gz tar xf redis-6.0.8.tar.gz -C /data/ make 编译错误解决办法: 安装gcc:yum install gcc server.c:5099:19: error: ‘struct redisServer’ has no member named ‘ipfd_count’ if (server.ipfd_count > 0 || server.tlsfd_count > 0) ^server.c:5099:44: error: ‘struct redisServer’ has no member named ‘tlsfd_count’ if (server.ipfd_count > 0 || server.tlsfd_count > 0) ^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 < 10241024) { ^server.c:5117:39: error: ‘struct redisServer’ has no member named ‘maxmemory’ if (server.maxmemory > 0 && server.maxmemory < 10241024) { 解决办法: 查看gcc版本是否在5.3以上,CentOS7默认安装4.8.5。 升级gcc到5.3以上版本,升级到gcc 9 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)
#编译出错时,清除编译生成的文件 不执行也可以make distclean
yum -y install centos-release-scl yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
#需要注意的是scl命令启用只是临时的,退出shell或重新打开一个shell就会恢复原系统gcc版本 scl enable devtoolset-9 bash
#执行以下命令永久使用 echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile #注:执行完此命令后,其它的shell窗口需要关闭重新打开才生效。# 重新打开shell窗口,再次编译 重新编译安装 make make install
创建数据目录 创建集群目录及相应目录 mkdir -p /data/{10001,10002} mkdir -p /data/{10003,10004} mkdir -p /data/{10005,10006}
修改配置 cat /data/10001/redis.conf |grep -v '#' |grep -v '^$' bind 10.168.104.206 protected-mode yes port 10001 tcp-backlog 511 timeout 900 tcp-keepalive 300 daemonize yes supervised no pidfile /data/10001/redis.pid loglevel notice logfile stdout logfile /data/10001/redis.log databases 16 always-show-logo yes save "" save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression no rdbchecksum no rdb-del-sync-files no dir /data/10001/ replica-serve-stale-data yes replica-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-diskless-load disabled repl-disable-tcp-nodelay no replica-priority 100 acllog-max-len 128 maxmemory 4gb maxmemory-policy volatile-lru lazyfree-lazy-eviction no lazyfree-lazy-expire no lazyfree-lazy-server-del no replica-lazy-flush no lazyfree-lazy-user-del no oom-score-adj no oom-score-adj-values 0 200 800 appendonly yes appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes aof-use-rdb-preamble yes lua-time-limit 5000 cluster-enabled yes cluster-config-file /data/10001/nodes.conf cluster-node-timeout 15000 cluster-replica-validity-factor 10 cluster-migration-barrier 1 cluster-require-full-coverage no cluster-replica-no-failover no cluster-allow-reads-when-down no slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 100 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-size -2 list-compress-depth 0 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 stream-node-max-bytes 4096 stream-node-max-entries 100 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit replica 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 dynamic-hz yes aof-rewrite-incremental-fsync yes rdb-save-incremental-fsync yes jemalloc-bg-thread yes io-threads 4 io-threads-do-reads yes
启动 /data/redis-6.0.8/src/redis-server /data/10001/redis.conf
创建redis集群 redis-cli --cluster create 10.168.104.206:10001 10.168.104.206:10002 10.168.104.205:10003 10.168.104.205:10004 10.168.104.204:10005 10.168.104.204:10006 --cluster-replicas 1