Skip to content

CentOS7源码安装Redis6.2.14

1. 下载并校验文件散列值

在这个页面 https://github.com/redis/redis-hashes/ 可以看到redis各版本版本对应的散列值:

sh
hash redis-6.2.14.tar.gz sha256 34e74856cbd66fdb3a684fb349d93961d8c7aa668b06f81fd93ff267d09bc277 http://download.redis.io/releases/redis-6.2.14.tar.gz

https://redis.io/downloads/https://download.redis.io/releases/redis-6.2.14.tar.gz 下载Redis源码文件。

然后上传到远程主机上。

sh
# 远程主机操作系统信息
[root@redis-server ~]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)

校验sha256值:

sh
[root@redis-server ~]# ls -lah redis-6.2.14.tar.gz
-rw-r--r-- 1 root root 2.4M Jun 10 17:23 redis-6.2.14.tar.gz
[root@redis-server ~]# sha256sum redis-6.2.14.tar.gz |grep 34e74856cbd66fdb3a684fb349d93961d8c7aa668b06f81fd93ff267d09bc277
34e74856cbd66fdb3a684fb349d93961d8c7aa668b06f81fd93ff267d09bc277  redis-6.2.14.tar.gz
[root@redis-server ~]#

可以看到sha256散列值校验正常。

2. 解压

sh
[root@redis-server ~]# tar -zxvf redis-6.2.14.tar.gz
redis-6.2.14/
redis-6.2.14/.github/
redis-6.2.14/.github/ISSUE_TEMPLATE/
redis-6.2.14/.github/ISSUE_TEMPLATE/bug_report.md
redis-6.2.14/.github/ISSUE_TEMPLATE/crash_report.md
redis-6.2.14/.github/ISSUE_TEMPLATE/feature_request.md
redis-6.2.14/.github/ISSUE_TEMPLATE/other_stuff.md
redis-6.2.14/.github/ISSUE_TEMPLATE/question.md
redis-6.2.14/.github/workflows/
redis-6.2.14/.github/workflows/ci.yml
redis-6.2.14/.github/workflows/daily.yml
redis-6.2.14/.gitignore
redis-6.2.14/00-RELEASENOTES
redis-6.2.14/BUGS
redis-6.2.14/CONDUCT
redis-6.2.14/CONTRIBUTING
redis-6.2.14/COPYING
redis-6.2.14/INSTALL
redis-6.2.14/MANIFESTO
redis-6.2.14/Makefile
redis-6.2.14/README.md
redis-6.2.14/TLS.md
redis-6.2.14/deps/
redis-6.2.14/deps/Makefile
redis-6.2.14/deps/README.md
... 省略
redis-6.2.14/utils/install_server.sh
redis-6.2.14/utils/lru/
redis-6.2.14/utils/lru/README
redis-6.2.14/utils/lru/lfu-simulation.c
redis-6.2.14/utils/lru/test-lru.rb
redis-6.2.14/utils/redis-copy.rb
redis-6.2.14/utils/redis-sha1.rb
redis-6.2.14/utils/redis_init_script
redis-6.2.14/utils/redis_init_script.tpl
redis-6.2.14/utils/releasetools/
redis-6.2.14/utils/releasetools/01_create_tarball.sh
redis-6.2.14/utils/releasetools/02_upload_tarball.sh
redis-6.2.14/utils/releasetools/03_test_release.sh
redis-6.2.14/utils/releasetools/04_release_hash.sh
redis-6.2.14/utils/releasetools/changelog.tcl
redis-6.2.14/utils/speed-regression.tcl
redis-6.2.14/utils/srandmember/
redis-6.2.14/utils/srandmember/README.md
redis-6.2.14/utils/srandmember/showdist.rb
redis-6.2.14/utils/srandmember/showfreq.rb
redis-6.2.14/utils/systemd-redis_multiple_servers@.service
redis-6.2.14/utils/systemd-redis_server.service
redis-6.2.14/utils/tracking_collisions.c
redis-6.2.14/utils/whatisdoing.sh
[root@redis-server ~]# echo $?
0
[root@redis-server ~]#

解压成功。

3. 编译

编译前,需要确保系统已经正常安装gcc包。

sh
[root@redis-server ~]# rpm -qa|grep gcc
libgcc-4.8.5-44.el7.x86_64
gcc-4.8.5-44.el7.x86_64
[root@redis-server ~]#

如果没有的话,使用yum install -y gcc安装一下。

切换到redis-6.2.14目录:

sh
[root@redis-server ~]# cd redis-6.2.14
[root@redis-server redis-6.2.14]# ls
00-RELEASENOTES  BUGS  CONDUCT  CONTRIBUTING  COPYING  deps  INSTALL  Makefile  MANIFESTO  README.md  redis.conf  runtest  runtest-cluster  runtest-moduleapi  runtest-sentinel  sentinel.conf  src  tests  TLS.md  utils
[root@redis-server redis-6.2.14]#

使用make命令编译:

sh
[root@redis-server redis-6.2.14]# make
cd src && make all
make[1]: Entering directory `/root/redis-6.2.14/src'
    CC Makefile.dep
make[1]: Leaving directory `/root/redis-6.2.14/src'
make[1]: Entering directory `/root/redis-6.2.14/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep
rm -f adlist.d quicklist.d ae.d anet.d dict.d server.d sds.d zmalloc.d lzf_c.d lzf_d.d pqsort.d zipmap.d sha1.d ziplist.d release.d networking.d util.d object.d db.d replication.d rdb.d t_string.d t_list.d t_set.d t_zset.d t_hash.d config.d aof.d pubsub.d multi.d debug.d sort.d intset.d syncio.d cluster.d crc16.d endianconv.d slowlog.d scripting.d bio.d rio.d rand.d memtest.d crcspeed.d crc64.d bitops.d sentinel.d notify.d setproctitle.d blocked.d hyperloglog.d latency.d sparkline.d redis-check-rdb.d redis-check-aof.d geo.d lazyfree.d module.d evict.d expire.d geohash.d geohash_helper.d childinfo.d defrag.d siphash.d rax.d t_stream.d listpack.d localtime.d lolwut.d lolwut5.d lolwut6.d acl.d gopher.d tracking.d connection.d tls.d sha256.d timeout.d setcpuaffinity.d monotonic.d mt19937-64.d anet.d adlist.d dict.d redis-cli.d zmalloc.d release.d ae.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d ae.d anet.d redis-benchmark.d adlist.d dict.d zmalloc.d release.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d
(cd ../deps && make distclean)
make[2]: Entering directory `/root/redis-6.2.14/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(cd hdr_histogram && make clean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/root/redis-6.2.14/deps'
(cd modules && make clean)
make[2]: Entering directory `/root/redis-6.2.14/src/modules'
rm -rf *.xo *.so
make[2]: Leaving directory `/root/redis-6.2.14/src/modules'
(cd ../tests/modules && make clean)
make[2]: Entering directory `/root/redis-6.2.14/tests/modules'
rm -f commandfilter.so basics.so testrdb.so fork.so infotest.so propagate.so misc.so hooks.so blockonkeys.so blockonbackground.so scan.so datatype.so auth.so keyspace_events.so blockedclient.so getkeys.so test_lazyfree.so timer.so defragtest.so hash.so zset.so stream.so commandfilter.xo basics.xo testrdb.xo fork.xo infotest.xo propagate.xo misc.xo hooks.xo blockonkeys.xo blockonbackground.xo scan.xo datatype.xo auth.xo keyspace_events.xo blockedclient.xo getkeys.xo test_lazyfree.xo timer.xo defragtest.xo hash.xo zset.xo stream.xo
make[2]: Leaving directory `/root/redis-6.2.14/tests/modules'
(rm -f .make-*)
echo STD=-pedantic -DREDIS_STATIC='' -std=c99 >> .make-settings
echo WARN=-Wall -W -Wno-missing-field-initializers >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo BUILD_TLS= >> .make-settings
echo USE_SYSTEMD= >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-pedantic -DREDIS_STATIC='' -std=c99 -Wall -W -Wno-missing-field-initializers -O2 -g -ggdb   -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_FINAL_LDFLAGS=  -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua hdr_histogram jemalloc)
make[2]: Entering directory `/root/redis-6.2.14/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(cd hdr_histogram && make clean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-cflags)
(echo "" > .make-ldflags)
MAKE hiredis
cd hiredis && make static
make[3]: Entering directory `/root/redis-6.2.14/deps/hiredis'
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb alloc.c
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb net.c
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb hiredis.c
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb sds.c
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb async.c
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb read.c
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb sockcompat.c
ar rcs libhiredis.a alloc.o net.o hiredis.o sds.o async.o read.o sockcompat.o
make[3]: Leaving directory `/root/redis-6.2.14/deps/hiredis'
MAKE linenoise
cd linenoise && make
make[3]: Entering directory `/root/redis-6.2.14/deps/linenoise'
cc  -Wall -Os -g  -c linenoise.c
make[3]: Leaving directory `/root/redis-6.2.14/deps/linenoise'
MAKE lua
cd lua/src && make all CFLAGS="-O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP " MYLDFLAGS="" AR="ar rc"
make[3]: Entering directory `/root/redis-6.2.14/deps/lua/src'
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lapi.o lapi.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lcode.o lcode.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o ldebug.o ldebug.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o ldo.o ldo.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o ldump.o ldump.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lfunc.o lfunc.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lgc.o lgc.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o llex.o llex.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lmem.o lmem.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lobject.o lobject.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lopcodes.o lopcodes.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lparser.o lparser.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lstate.o lstate.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lstring.o lstring.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o ltable.o ltable.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o ltm.o ltm.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lundump.o lundump.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lvm.o lvm.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lzio.o lzio.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o strbuf.o strbuf.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o fpconv.o fpconv.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lauxlib.o lauxlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lbaselib.o lbaselib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o ldblib.o ldblib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o liolib.o liolib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lmathlib.o lmathlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o loslib.o loslib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o ltablib.o ltablib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lstrlib.o lstrlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o loadlib.o loadlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o linit.o linit.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lua_cjson.o lua_cjson.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lua_struct.o lua_struct.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lua_cmsgpack.o lua_cmsgpack.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lua_bit.o lua_bit.c
ar rc liblua.a lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o strbuf.o fpconv.o lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o lua_cjson.o lua_struct.o lua_cmsgpack.o lua_bit.o # DLL needs all object files
ranlib liblua.a
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lua.o lua.c
cc -o lua  lua.o liblua.a -lm
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o luac.o luac.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o print.o print.c
cc -o luac  luac.o print.o liblua.a -lm
make[3]: Leaving directory `/root/redis-6.2.14/deps/lua/src'
MAKE hdr_histogram
cd hdr_histogram && make
make[3]: Entering directory `/root/redis-6.2.14/deps/hdr_histogram'
cc  -Wall -Os -g  -c  hdr_histogram.c
make[3]: Leaving directory `/root/redis-6.2.14/deps/hdr_histogram'
MAKE jemalloc
cd jemalloc && ./configure --with-version=5.1.0-0-g0 --with-lg-quantum=3 --with-jemalloc-prefix=je_ CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS=""
checking for xsltproc... /usr/bin/xsltproc
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether compiler is cray... no
checking whether compiler supports -std=gnu11... yes
checking whether compiler supports -Wall... yes
checking whether compiler supports -Wshorten-64-to-32... no
checking whether compiler supports -Wsign-compare... yes
checking whether compiler supports -Wundef... yes
checking whether compiler supports -Wno-format-zero-length... yes
checking whether compiler supports -pipe... yes
checking whether compiler supports -g3... yes
checking how to run the C preprocessor... gcc -E
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking whether g++ supports C++14 features by default... no
checking whether g++ supports C++14 features with -std=c++14... no
checking whether g++ supports C++14 features with -std=c++0x... no
checking whether g++ supports C++14 features with +std=c++14... no
checking whether g++ supports C++14 features with -h std=c++14... no
configure: No compiler with C++14 support was found
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking size of void *... 8
checking size of int... 4
checking size of long... 8
checking size of long long... 8
checking size of intmax_t... 8
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking whether pause instruction is compilable... yes
checking number of significant virtual address bits... 48
checking for ar... ar
checking for nm... nm
checking for gawk... gawk
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking whether malloc_usable_size definition can use const argument... no
checking for library containing log... -lm
checking whether __attribute__ syntax is compilable... yes
checking whether compiler supports -fvisibility=hidden... yes
checking whether compiler supports -fvisibility=hidden... no
checking whether compiler supports -Werror... yes
checking whether compiler supports -herror_on_warning... no
checking whether tls_model attribute is compilable... yes
checking whether compiler supports -Werror... yes
checking whether compiler supports -herror_on_warning... no
checking whether alloc_size attribute is compilable... yes
checking whether compiler supports -Werror... yes
checking whether compiler supports -herror_on_warning... no
checking whether format(gnu_printf, ...) attribute is compilable... yes
checking whether compiler supports -Werror... yes
checking whether compiler supports -herror_on_warning... no
checking whether format(printf, ...) attribute is compilable... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for ranlib... ranlib
checking for ld... /usr/bin/ld
checking for autoconf... false
checking for memalign... yes
checking for valloc... yes
checking whether compiler supports -O3... yes
checking whether compiler supports -O3... no
checking whether compiler supports -funroll-loops... yes
checking configured backtracing method... N/A
checking for sbrk... yes
checking whether utrace(2) is compilable... no
checking whether a program using __builtin_unreachable is compilable... yes
checking whether a program using __builtin_ffsl is compilable... yes
checking LG_PAGE... 12
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for pthread_create in -lpthread... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for dlsym... no
checking for dlsym in -ldl... yes
checking whether pthread_atfork(3) is compilable... yes
checking whether pthread_setname_np(3) is compilable... yes
checking for library containing clock_gettime... none required
checking whether clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is compilable... yes
checking whether clock_gettime(CLOCK_MONOTONIC, ...) is compilable... yes
checking whether mach_absolute_time() is compilable... no
checking whether compiler supports -Werror... yes
checking whether syscall(2) is compilable... yes
checking for secure_getenv... yes
checking for sched_getcpu... yes
checking for sched_setaffinity... yes
checking for issetugid... no
checking for _malloc_thread_cleanup... no
checking for _pthread_mutex_init_calloc_cb... no
checking for TLS... yes
checking whether C11 atomics is compilable... no
checking whether GCC __atomic atomics is compilable... yes
checking whether GCC __sync atomics is compilable... yes
checking whether Darwin OSAtomic*() is compilable... no
checking whether madvise(2) is compilable... yes
checking whether madvise(..., MADV_FREE) is compilable... no
checking whether madvise(..., MADV_DONTNEED) is compilable... yes
checking whether madvise(..., MADV_DO[NT]DUMP) is compilable... yes
checking whether madvise(..., MADV_[NO]HUGEPAGE) is compilable... yes
checking whether to force 32-bit __sync_{add,sub}_and_fetch()... no
checking whether to force 64-bit __sync_{add,sub}_and_fetch()... no
checking for __builtin_clz... yes
checking whether Darwin os_unfair_lock_*() is compilable... no
checking whether Darwin OSSpin*() is compilable... no
checking whether glibc malloc hook is compilable... yes
checking whether glibc memalign hook is compilable... yes
checking whether pthreads adaptive mutexes is compilable... yes
checking whether compiler supports -D_GNU_SOURCE... yes
checking whether compiler supports -Werror... yes
checking whether compiler supports -herror_on_warning... no
checking whether strerror_r returns char with gnu source is compilable... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating jemalloc.pc
config.status: creating doc/html.xsl
config.status: creating doc/manpages.xsl
config.status: creating doc/jemalloc.xml
config.status: creating include/jemalloc/jemalloc_macros.h
config.status: creating include/jemalloc/jemalloc_protos.h
config.status: creating include/jemalloc/jemalloc_typedefs.h
config.status: creating include/jemalloc/internal/jemalloc_preamble.h
config.status: creating test/test.sh
config.status: creating test/include/test/jemalloc_test.h
config.status: creating config.stamp
config.status: creating bin/jemalloc-config
config.status: creating bin/jemalloc.sh
config.status: creating bin/jeprof
config.status: creating include/jemalloc/jemalloc_defs.h
config.status: creating include/jemalloc/internal/jemalloc_internal_defs.h
config.status: creating test/include/test/jemalloc_test_defs.h
config.status: executing include/jemalloc/internal/public_symbols.txt commands
config.status: executing include/jemalloc/internal/private_symbols.awk commands
config.status: executing include/jemalloc/internal/private_symbols_jet.awk commands
config.status: executing include/jemalloc/internal/public_namespace.h commands
config.status: executing include/jemalloc/internal/public_unnamespace.h commands
config.status: executing include/jemalloc/internal/size_classes.h commands
config.status: executing include/jemalloc/jemalloc_protos_jet.h commands
config.status: executing include/jemalloc/jemalloc_rename.h commands
config.status: executing include/jemalloc/jemalloc_mangle.h commands
config.status: executing include/jemalloc/jemalloc_mangle_jet.h commands
config.status: executing include/jemalloc/jemalloc.h commands
===============================================================================
jemalloc version   : 5.1.0-0-g0
library revision   : 2

CONFIG             : --with-version=5.1.0-0-g0 --with-lg-quantum=3 --with-jemalloc-prefix=je_ 'CFLAGS=-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops ' LDFLAGS=
CC                 : gcc
CONFIGURE_CFLAGS   : -std=gnu11 -Wall -Wsign-compare -Wundef -Wno-format-zero-length -pipe -g3 -fvisibility=hidden -O3 -funroll-loops
SPECIFIED_CFLAGS   : -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops
EXTRA_CFLAGS       :
CPPFLAGS           : -D_GNU_SOURCE -D_REENTRANT
CXX                : g++
CONFIGURE_CXXFLAGS :
SPECIFIED_CXXFLAGS :
EXTRA_CXXFLAGS     :
LDFLAGS            :
EXTRA_LDFLAGS      :
DSO_LDFLAGS        : -shared -Wl,-soname,$(@F)
LIBS               : -lm  -lpthread -ldl
RPATH_EXTRA        :

XSLTPROC           : /usr/bin/xsltproc
XSLROOT            :

PREFIX             : /usr/local
BINDIR             : /usr/local/bin
DATADIR            : /usr/local/share
INCLUDEDIR         : /usr/local/include
LIBDIR             : /usr/local/lib
MANDIR             : /usr/local/share/man

srcroot            :
abs_srcroot        : /root/redis-6.2.14/deps/jemalloc/
objroot            :
abs_objroot        : /root/redis-6.2.14/deps/jemalloc/

JEMALLOC_PREFIX    : je_
JEMALLOC_PRIVATE_NAMESPACE
                   : je_
install_suffix     :
malloc_conf        :
autogen            : 0
debug              : 0
stats              : 1
prof               : 0
prof-libunwind     : 0
prof-libgcc        : 0
prof-gcc           : 0
fill               : 1
utrace             : 0
xmalloc            : 0
log                : 0
lazy_lock          : 0
cache-oblivious    : 1
cxx                : 0
===============================================================================
cd jemalloc && make CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS="" lib/libjemalloc.a
make[3]: Entering directory `/root/redis-6.2.14/deps/jemalloc'
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/jemalloc.sym.o src/jemalloc.c
nm -a src/jemalloc.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/jemalloc.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/arena.sym.o src/arena.c
nm -a src/arena.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/arena.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/background_thread.sym.o src/background_thread.c
nm -a src/background_thread.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/background_thread.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/base.sym.o src/base.c
nm -a src/base.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/base.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/bin.sym.o src/bin.c
nm -a src/bin.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/bin.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/bitmap.sym.o src/bitmap.c
nm -a src/bitmap.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/bitmap.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/ckh.sym.o src/ckh.c
nm -a src/ckh.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/ckh.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/ctl.sym.o src/ctl.c
nm -a src/ctl.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/ctl.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/div.sym.o src/div.c
nm -a src/div.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/div.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/extent.sym.o src/extent.c
nm -a src/extent.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/extent.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/extent_dss.sym.o src/extent_dss.c
nm -a src/extent_dss.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/extent_dss.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/extent_mmap.sym.o src/extent_mmap.c
nm -a src/extent_mmap.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/extent_mmap.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/hash.sym.o src/hash.c
nm -a src/hash.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/hash.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/hooks.sym.o src/hooks.c
nm -a src/hooks.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/hooks.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/large.sym.o src/large.c
nm -a src/large.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/large.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/log.sym.o src/log.c
nm -a src/log.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/log.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/malloc_io.sym.o src/malloc_io.c
nm -a src/malloc_io.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/malloc_io.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/mutex.sym.o src/mutex.c
nm -a src/mutex.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/mutex.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/mutex_pool.sym.o src/mutex_pool.c
nm -a src/mutex_pool.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/mutex_pool.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/nstime.sym.o src/nstime.c
nm -a src/nstime.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/nstime.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/pages.sym.o src/pages.c
nm -a src/pages.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/pages.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/prng.sym.o src/prng.c
nm -a src/prng.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/prng.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/prof.sym.o src/prof.c
nm -a src/prof.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/prof.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/rtree.sym.o src/rtree.c
nm -a src/rtree.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/rtree.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/stats.sym.o src/stats.c
nm -a src/stats.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/stats.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/sz.sym.o src/sz.c
nm -a src/sz.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/sz.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/tcache.sym.o src/tcache.c
nm -a src/tcache.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/tcache.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/ticker.sym.o src/ticker.c
nm -a src/ticker.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/ticker.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/tsd.sym.o src/tsd.c
nm -a src/tsd.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/tsd.sym
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/witness.sym.o src/witness.c
nm -a src/witness.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/witness.sym
/bin/sh include/jemalloc/internal/private_namespace.sh src/jemalloc.sym src/arena.sym src/background_thread.sym src/base.sym src/bin.sym src/bitmap.sym src/ckh.sym src/ctl.sym src/div.sym src/extent.sym src/extent_dss.sym src/extent_mmap.sym src/hash.sym src/hooks.sym src/large.sym src/log.sym src/malloc_io.sym src/mutex.sym src/mutex_pool.sym src/nstime.sym src/pages.sym src/prng.sym src/prof.sym src/rtree.sym src/stats.sym src/sz.sym src/tcache.sym src/ticker.sym src/tsd.sym src/witness.sym > include/jemalloc/internal/private_namespace.gen.h
cp include/jemalloc/internal/private_namespace.gen.h include/jemalloc/internal/private_namespace.gen.h
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/jemalloc.o src/jemalloc.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/arena.o src/arena.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/background_thread.o src/background_thread.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/base.o src/base.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/bin.o src/bin.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/bitmap.o src/bitmap.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ckh.o src/ckh.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ctl.o src/ctl.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/div.o src/div.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/extent.o src/extent.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/extent_dss.o src/extent_dss.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/extent_mmap.o src/extent_mmap.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/hash.o src/hash.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/hooks.o src/hooks.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/large.o src/large.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/log.o src/log.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/malloc_io.o src/malloc_io.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mutex.o src/mutex.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mutex_pool.o src/mutex_pool.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/nstime.o src/nstime.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/pages.o src/pages.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/prng.o src/prng.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/prof.o src/prof.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/rtree.o src/rtree.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/stats.o src/stats.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/sz.o src/sz.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/tcache.o src/tcache.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ticker.o src/ticker.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/tsd.o src/tsd.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/witness.o src/witness.c
ar crus lib/libjemalloc.a src/jemalloc.o src/arena.o src/background_thread.o src/base.o src/bin.o src/bitmap.o src/ckh.o src/ctl.o src/div.o src/extent.o src/extent_dss.o src/extent_mmap.o src/hash.o src/hooks.o src/large.o src/log.o src/malloc_io.o src/mutex.o src/mutex_pool.o src/nstime.o src/pages.o src/prng.o src/prof.o src/rtree.o src/stats.o src/sz.o src/tcache.o src/ticker.o src/tsd.o src/witness.o
make[3]: Leaving directory `/root/redis-6.2.14/deps/jemalloc'
make[2]: Leaving directory `/root/redis-6.2.14/deps'
    CC adlist.o
    CC quicklist.o
    CC ae.o
    CC anet.o
    CC dict.o
    CC server.o
    CC sds.o
    CC zmalloc.o
    CC lzf_c.o
    CC lzf_d.o
    CC pqsort.o
    CC zipmap.o
    CC sha1.o
    CC ziplist.o
    CC release.o
    CC networking.o
    CC util.o
    CC object.o
    CC db.o
    CC replication.o
    CC rdb.o
    CC t_string.o
    CC t_list.o
    CC t_set.o
    CC t_zset.o
    CC t_hash.o
    CC config.o
    CC aof.o
    CC pubsub.o
    CC multi.o
    CC debug.o
    CC sort.o
    CC intset.o
    CC syncio.o
    CC cluster.o
    CC crc16.o
    CC endianconv.o
    CC slowlog.o
    CC scripting.o
    CC bio.o
    CC rio.o
    CC rand.o
    CC memtest.o
    CC crcspeed.o
    CC crc64.o
    CC bitops.o
    CC sentinel.o
    CC notify.o
    CC setproctitle.o
    CC blocked.o
    CC hyperloglog.o
    CC latency.o
    CC sparkline.o
    CC redis-check-rdb.o
    CC redis-check-aof.o
    CC geo.o
    CC lazyfree.o
    CC module.o
    CC evict.o
    CC expire.o
    CC geohash.o
    CC geohash_helper.o
    CC childinfo.o
    CC defrag.o
    CC siphash.o
    CC rax.o
    CC t_stream.o
    CC listpack.o
    CC localtime.o
    CC lolwut.o
    CC lolwut5.o
    CC lolwut6.o
    CC acl.o
    CC gopher.o
    CC tracking.o
    CC connection.o
    CC tls.o
    CC sha256.o
    CC timeout.o
    CC setcpuaffinity.o
    CC monotonic.o
    CC mt19937-64.o
    LINK redis-server
    INSTALL redis-sentinel
    CC redis-cli.o
    CC cli_common.o
    LINK redis-cli
    CC redis-benchmark.o
    LINK redis-benchmark
    INSTALL redis-check-rdb
    INSTALL redis-check-aof

Hint: It's a good idea to run 'make test' ;)

make[1]: Leaving directory `/root/redis-6.2.14/src'
[root@redis-server redis-6.2.14]#

可以看到出现了It's a good idea to run 'make test'提示,表示编译成功。

4. 安装

使用make install PREFIX=/srv/redis-6.2.14命令安装,安装时指定安装目录。

sh
[root@redis-server redis-6.2.14]# make install PREFIX=/srv/redis-6.2.14
cd src && make install
make[1]: Entering directory `/root/redis-6.2.14/src'
    CC Makefile.dep
make[1]: Leaving directory `/root/redis-6.2.14/src'
make[1]: Entering directory `/root/redis-6.2.14/src'

Hint: It's a good idea to run 'make test' ;)

    INSTALL redis-server
    INSTALL redis-benchmark
    INSTALL redis-cli
make[1]: Leaving directory `/root/redis-6.2.14/src'
[root@redis-server redis-6.2.14]# echo $?
0
[root@redis-server redis-6.2.14]# ll /srv/redis-6.2.14
total 0
drwxr-xr-x 2 root root 134 Jun 10 18:25 bin
[root@redis-server redis-6.2.14]# ll /srv/redis-6.2.14/bin/
total 18936
-rwxr-xr-x 1 root root 4830616 Jun 10 18:25 redis-benchmark
lrwxrwxrwx 1 root root      12 Jun 10 18:25 redis-check-aof -> redis-server
lrwxrwxrwx 1 root root      12 Jun 10 18:25 redis-check-rdb -> redis-server
-rwxr-xr-x 1 root root 5004728 Jun 10 18:25 redis-cli
lrwxrwxrwx 1 root root      12 Jun 10 18:25 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 9548176 Jun 10 18:25 redis-server
[root@redis-server redis-6.2.14]#

可以看到,安装成功,并生成了相应对应的二进制文件。

5. 校验

查看redis-serverredis-cli的版本信息:

sh
[root@redis-server redis-6.2.14]# cd /srv/redis-6.2.14/bin/
[root@redis-server bin]# ./redis-server --version
Redis server v=6.2.14 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=ad623970888ef0a
[root@redis-server bin]# ./redis-cli --version
redis-cli 6.2.14
[root@redis-server bin]#

可以看到,能够正常显示redis-serverredis-cli的版本信息。

6. 复制redis配置文件

在redis源码中配置有一个配置文件,我们将它复制到/srv/redis-6.2.14/conf目录下。

sh
[root@redis-server ~]# ls -lah redis-6.2.14/redis.conf
-rw-rw-r-- 1 root root 92K Oct 18  2023 redis-6.2.14/redis.conf
[root@redis-server ~]# cd /srv/redis-6.2.14
[root@redis-server redis-6.2.14]# mkdir conf
[root@redis-server redis-6.2.14]# cp -p ~/redis-6.2.14/redis.conf conf
[root@redis-server redis-6.2.14]# ls -lah conf/redis.conf
-rw-rw-r-- 1 root root 92K Oct 18  2023 conf/redis.conf
[root@redis-server redis-6.2.14]#

保存一份默认的配置文件:

sh
[root@redis-server redis-6.2.14]# cp -p conf/redis.conf conf/redis.conf.default
[root@redis-server redis-6.2.14]# md5sum conf/*
d9a1e1fba487325b188ee5ec7bd78ae5  conf/redis.conf
d9a1e1fba487325b188ee5ec7bd78ae5  conf/redis.conf.default
[root@redis-server redis-6.2.14]#

7. 修改redis配置文件

修改redis配置,最后查看未注释的配置:

sh
[root@redis-server redis-6.2.14]# grep -v '#' conf/redis.conf|awk NF
bind 192.168.56.121 127.0.0.1
protected-mode no
port 29736
tcp-backlog 511
timeout 300
tcp-keepalive 300
daemonize no
pidfile /srv/redis/pid/redis_29736.pid
loglevel notice
logfile "/srv/redis/logs/redis_29736.log"
crash-log-enabled yes
databases 16
always-show-logo no
set-proc-title no
proc-title-template "{title} {listen-addr} {server-mode}"
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
rdb-del-sync-files no
dir /srv/redis/data
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
requirepass ALONGPASSWORD
maxmemory 1gb
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
lazyfree-lazy-user-flush no
oom-score-adj no
oom-score-adj-values 0 200 800
disable-thp yes
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
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
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
[root@redis-server redis-6.2.14]#

带注释说明的配置文件内容:

ini
# Redis configuration file example.
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first argument:
#
# ./redis-server /path/to/redis.conf

# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
# units are case insensitive so 1GB 1Gb 1gB are all the same.

################################## INCLUDES ###################################

# Include one or more other config files here.  This is useful if you
# have a standard template that goes to all Redis servers but also need
# to customize a few per-server settings.  Include files can include
# other files, so use this wisely.
#
# Note that option "include" won't be rewritten by command "CONFIG REWRITE"
# from admin or Redis Sentinel. Since Redis always uses the last processed
# line as value of a configuration directive, you'd better put includes
# at the beginning of this file to avoid overwriting config change at runtime.
#
# If instead you are interested in using includes to override configuration
# options, it is better to use include as the last line.
#
# include /path/to/local.conf
# include /path/to/other.conf

################################## MODULES #####################################

# Load modules at startup. If the server is not able to load modules
# it will abort. It is possible to use multiple loadmodule directives.
#
# loadmodule /path/to/my_module.so
# loadmodule /path/to/other_module.so

################################## NETWORK #####################################

# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all available network interfaces on the host machine.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
# Each address can be prefixed by "-", which means that redis will not fail to
# start if the address is not available. Being not available only refers to
# addresses that does not correspond to any network interfece. Addresses that
# are already in use will always fail, and unsupported protocols will always BE
# silently skipped.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1     # listens on two specific IPv4 addresses
# bind 127.0.0.1 ::1              # listens on loopback IPv4 and IPv6
# bind * -::*                     # like the default, all available interfaces


#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only on the
# IPv4 and IPv6 (if available) loopback interface addresses (this means Redis
# will only be able to accept client connections from the same host that it is
# running on).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT OUT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# bind 127.0.0.1 -::1

# BEGIN MEIZHAOHUI COMMENTS
#   bind 配置的是 redis server 网卡的地址,配置哪个网卡地址,
#   你就可以通过哪个网卡地址访问redis,而不是外部访问redis的ip列表
# END MEIZHAOHUI COMMENTS
bind 192.168.56.121 127.0.0.1

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and if:
#
# 1) The server is not binding explicitly to a set of addresses using the
#    "bind" directive.
# 2) No password is configured.
#
# The server only accepts connections from clients connecting from the
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
# sockets.
#
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
# protected-mode yes

# BEGIN MEIZHAOHUI COMMENTS
#   protected-mode yes 保护模式,这种模式限制了只有本地可以访问redis服务器
#   如果需要外部客户端连接redis服务器,则应设置为 protected-mode no 非保护模式
# END MEIZHAOHUI COMMENTS
protected-mode no

# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
# port 6379

# BEGIN MEIZHAOHUI COMMENTS
#   redis服务监听端口,默认6379
#   使用默认的端口号不是很安全,为了安全一点,需要修改默认的端口号
#   建议修改为10000以上,60000以下的端口,我这里设置为29736
# END MEIZHAOHUI COMMENTS
port 29736

# TCP listen() backlog.
#
# In high requests-per-second environments you need a high backlog in order
# to avoid slow clients connection issues. Note that the Linux kernel
# will silently truncate it to the value of /proc/sys/net/core/somaxconn so
# make sure to raise both the value of somaxconn and tcp_max_syn_backlog
# in order to get the desired effect.
tcp-backlog 511
# BEGIN MEIZHAOHUI COMMENTS
#   在linux系统中控制tcp三次握手已完成连接队列的长度
#   在高并发系统中,你需要设置一个较高的tcp-backlog来避免客户端连接速度慢的问题(三次握手的速度)
#   取 /proc/sys/net/core/somaxconn 和 tcp-backlog 配置两者中的小值
#   对于负载很大的服务程序来说一般会将它修改为2048或者更大。
#   在/etc/sysctl.conf中添加:net.core.somaxconn = 2048,然后在终端中执行sysctl -p
# END MEIZHAOHUI COMMENTS


# Unix socket.
#
# Specify the path for the Unix socket that will be used to listen for
# incoming connections. There is no default, so Redis will not listen
# on a unix socket when not specified.
#
# unixsocket /run/redis.sock
# unixsocketperm 700

# Close the connection after a client is idle for N seconds (0 to disable)
# timeout 0

# BEGIN MEIZHAOHUI COMMENTS
#   客户端空闲超时时间,默认为0,关闭超时时间
#   我设置为300秒,当客户端闲置300秒后关闭连接
# END MEIZHAOHUI COMMENTS
timeout 300

# TCP keepalive.
#
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
# of communication. This is useful for two reasons:
#
# 1) Detect dead peers.
# 2) Force network equipment in the middle to consider the connection to be
#    alive.
#
# On Linux, the specified value (in seconds) is the period used to send ACKs.
# Note that to close the connection the double of the time is needed.
# On other kernels the period depends on the kernel configuration.
#
# A reasonable value for this option is 300 seconds, which is the new
# Redis default starting with Redis 3.2.1.
tcp-keepalive 300

# BEGIN MEIZHAOHUI COMMENTS
#   它是 TCP 连接保活策略,可以通过 tcp-keepalive 配置项来进行设置,单位为秒
#   假如设置为 60 秒,则 server 端会每 60 秒向连接空闲的客户端发起一次 ACK 请求,
#   以检查客户端是否已经挂掉,对于无响应的客户端则会关闭其连接。
#   如果设置为 0,则不会进行保活检测(默认为 tcp-keepalive 300)
# END MEIZHAOHUI COMMENTS


################################# TLS/SSL #####################################

# By default, TLS/SSL is disabled. To enable it, the "tls-port" configuration
# directive can be used to define TLS-listening ports. To enable TLS on the
# default port, use:
#
# port 0
# tls-port 6379

# Configure a X.509 certificate and private key to use for authenticating the
# server to connected clients, masters or cluster peers.  These files should be
# PEM formatted.
#
# tls-cert-file redis.crt 
# tls-key-file redis.key
#
# If the key file is encrypted using a passphrase, it can be included here
# as well.
#
# tls-key-file-pass secret

# Normally Redis uses the same certificate for both server functions (accepting
# connections) and client functions (replicating from a master, establishing
# cluster bus connections, etc.).
#
# Sometimes certificates are issued with attributes that designate them as
# client-only or server-only certificates. In that case it may be desired to use
# different certificates for incoming (server) and outgoing (client)
# connections. To do that, use the following directives:
#
# tls-client-cert-file client.crt
# tls-client-key-file client.key
#
# If the key file is encrypted using a passphrase, it can be included here
# as well.
#
# tls-client-key-file-pass secret

# Configure a DH parameters file to enable Diffie-Hellman (DH) key exchange,
# required by older versions of OpenSSL (<3.0). Newer versions do not require
# this configuration and recommend against it.
#
# tls-dh-params-file redis.dh

# Configure a CA certificate(s) bundle or directory to authenticate TLS/SSL
# clients and peers.  Redis requires an explicit configuration of at least one
# of these, and will not implicitly use the system wide configuration.
#
# tls-ca-cert-file ca.crt
# tls-ca-cert-dir /etc/ssl/certs

# By default, clients (including replica servers) on a TLS port are required
# to authenticate using valid client side certificates.
#
# If "no" is specified, client certificates are not required and not accepted.
# If "optional" is specified, client certificates are accepted and must be
# valid if provided, but are not required.
#
# tls-auth-clients no
# tls-auth-clients optional

# By default, a Redis replica does not attempt to establish a TLS connection
# with its master.
#
# Use the following directive to enable TLS on replication links.
#
# tls-replication yes

# By default, the Redis Cluster bus uses a plain TCP connection. To enable
# TLS for the bus protocol, use the following directive:
#
# tls-cluster yes

# By default, only TLSv1.2 and TLSv1.3 are enabled and it is highly recommended
# that older formally deprecated versions are kept disabled to reduce the attack surface.
# You can explicitly specify TLS versions to support.
# Allowed values are case insensitive and include "TLSv1", "TLSv1.1", "TLSv1.2",
# "TLSv1.3" (OpenSSL >= 1.1.1) or any combination.
# To enable only TLSv1.2 and TLSv1.3, use:
#
# tls-protocols "TLSv1.2 TLSv1.3"

# Configure allowed ciphers.  See the ciphers(1ssl) manpage for more information
# about the syntax of this string.
#
# Note: this configuration applies only to <= TLSv1.2.
#
# tls-ciphers DEFAULT:!MEDIUM

# Configure allowed TLSv1.3 ciphersuites.  See the ciphers(1ssl) manpage for more
# information about the syntax of this string, and specifically for TLSv1.3
# ciphersuites.
#
# tls-ciphersuites TLS_CHACHA20_POLY1305_SHA256

# When choosing a cipher, use the server's preference instead of the client
# preference. By default, the server follows the client's preference.
#
# tls-prefer-server-ciphers yes

# By default, TLS session caching is enabled to allow faster and less expensive
# reconnections by clients that support it. Use the following directive to disable
# caching.
#
# tls-session-caching no

# Change the default number of TLS sessions cached. A zero value sets the cache
# to unlimited size. The default size is 20480.
#
# tls-session-cache-size 5000

# Change the default timeout of cached TLS sessions. The default timeout is 300
# seconds.
#
# tls-session-cache-timeout 60

################################# GENERAL #####################################

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
# When Redis is supervised by upstart or systemd, this parameter has no impact.
daemonize no

# BEGIN MEIZHAOHUI COMMENTS
#   是否以守护进程方式运行
#   我后面需要使用supervisor来启动Redis,因此不以守护进程方式运行
# END MEIZHAOHUI COMMENTS


# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
#   supervised no      - no supervision interaction
#   supervised upstart - signal upstart by putting Redis into SIGSTOP mode
#                        requires "expect stop" in your upstart job config
#   supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
#                        on startup, and updating Redis status on a regular
#                        basis.
#   supervised auto    - detect upstart or systemd method based on
#                        UPSTART_JOB or NOTIFY_SOCKET environment variables
# Note: these supervision methods only signal "process is ready."
#       They do not enable continuous pings back to your supervisor.
#
# The default is "no". To run under upstart/systemd, you can simply uncomment
# the line below:
#
# supervised auto

# BEGIN MEIZHAOHUI COMMENTS
#   若从upstart或systemd运行Redis,则Redis可以与监控树交互。
#   supervised no      - 无相互监督,默认
#   supervised upstart - 使Redis进入SIGSTOP模式并监控upstart
#   supervised systemd - 通过设置READY=1到$NOTIFY_SOCKET来监控systemd
#   supervised auto    - 基于UPSTART_JOB或NOTIFY_SOCKET环境变量的监督自动检测upstart或systemd方法
# END MEIZHAOHUI COMMENTS



# If a pid file is specified, Redis writes it where specified at startup
# and removes it at exit.
#
# When the server runs non daemonized, no pid file is created if none is
# specified in the configuration. When the server is daemonized, the pid file
# is used even if not specified, defaulting to "/var/run/redis.pid".
#
# Creating a pid file is best effort: if Redis is not able to create it
# nothing bad happens, the server will start and run normally.
#
# Note that on modern Linux systems "/run/redis.pid" is more conforming
# and should be used instead.
# pidfile /var/run/redis_6379.pid

# BEGIN MEIZHAOHUI COMMENTS
#   设置PID文件,我将redis相关的文件都放在 /srv/redis 目录下
# END MEIZHAOHUI COMMENTS
pidfile /srv/redis/pid/redis_29736.pid

# Specify the server verbosity level.
# This can be one of:
# debug (a lot of information, useful for development/testing)
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
loglevel notice

# BEGIN MEIZHAOHUI COMMENTS
#   loglevel 指定日志级别
#   开发阶段可以设置成 debug,生产阶段通常设置为 notice 或者 warning,默认为 loglevel notice
# END MEIZHAOHUI COMMENTS

# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
# logfile ""

# BEGIN MEIZHAOHUI COMMENTS
#   logfile 指定日志文件
#   redis 在运行过程中,会输出一些日志信息;默认情况下,这些日志信息会输出到控制台;
#   我们可以使用 logfile 配置日志文件,使 redis 把日志信息输出到指定文件中
# END MEIZHAOHUI COMMENTS
logfile "/srv/redis/logs/redis_29736.log"

# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
# syslog-enabled no
# BEGIN MEIZHAOHUI COMMENTS
#   syslog-enabled 是否把日志输出到系统日志,默认no,即不输出到系统日志
# END MEIZHAOHUI COMMENTS


# Specify the syslog identity.
# syslog-ident redis
# BEGIN MEIZHAOHUI COMMENTS
#   syslog-ident 指定syslog的标示符,如果'syslog-enabled'是no,则这个选项无效
# END MEIZHAOHUI COMMENTS


# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
# syslog-facility local0
# BEGIN MEIZHAOHUI COMMENTS
#   syslog-facility 指定syslog 设备(facility), 必须是USER或者LOCAL0到LOCAL7
# END MEIZHAOHUI COMMENTS

# To disable the built in crash log, which will possibly produce cleaner core
# dumps when they are needed, uncomment the following:
#
# crash-log-enabled no
# BEGIN MEIZHAOHUI COMMENTS
#   crash-log-enabled参数用于启用或禁用Redis的崩溃日志功能
#   当Redis发生崩溃时,崩溃日志将被记录在特定的日志文件中,以帮助用户诊断和调试问题。
#   如果你禁用了崩溃日志功能,当Redis发生崩溃时,你将无法获得相关的日志信息,可能会增加故障排查的难度。
#   因此,一般情况下建议将crash-log-enabled参数设置为"yes"
# END MEIZHAOHUI COMMENTS
crash-log-enabled yes

# To disable the fast memory check that's run as part of the crash log, which
# will possibly let redis terminate sooner, uncomment the following:
#
# crash-memcheck-enabled no
# BEGIN MEIZHAOHUI COMMENTS
#   crash-memcheck-enabled是一个启用或禁用内存检查的参数。
#   当启用内存检查时,Redis会使用Valgrind实用程序memcheck来检查内存错误和泄漏。
#   这有助于发现和修复潜在的内存问题
#   请注意,启用内存检查会显著影响Redis的性能,因为它会增加运行时开销。
#   因此,仅在调试或测试目的时才应启用此参数。在生产环境中,应禁用它以获得最佳性能。
#   因此,保持默认crash-memcheck-enabled no即可
# END MEIZHAOHUI COMMENTS


# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases'-1
databases 16
# BEGIN MEIZHAOHUI COMMENTS
#   设置数据库的数量,默认16个
# END MEIZHAOHUI COMMENTS


# By default Redis shows an ASCII art logo only when started to log to the
# standard output and if the standard output is a TTY and syslog logging is
# disabled. Basically this means that normally a logo is displayed only in
# interactive sessions.
#
# However it is possible to force the pre-4.0 behavior and always show a
# ASCII art logo in startup logs by setting the following option to yes.
always-show-logo no
# BEGIN MEIZHAOHUI COMMENTS
#   Redis服务器在启动时是否显示LOGO
# END MEIZHAOHUI COMMENTS

# By default, Redis modifies the process title (as seen in 'top' and 'ps') to
# provide some runtime information. It is possible to disable this and leave
# the process name as executed by setting the following to no.
# set-proc-title yes
# BEGIN MEIZHAOHUI COMMENTS
#   设置Redis进程的标题,我不自定义标题
#   设置 set-proc-title no
# END MEIZHAOHUI COMMENTS
set-proc-title no

# When changing the process title, Redis uses the following template to construct
# the modified title.
#
# Template variables are specified in curly brackets. The following variables are
# supported:
#
# {title}           Name of process as executed if parent, or type of child process.
# {listen-addr}     Bind address or '*' followed by TCP or TLS port listening on, or
#                   Unix socket if only that's available.
# {server-mode}     Special mode, i.e. "[sentinel]" or "[cluster]".
# {port}            TCP port listening on, or 0.
# {tls-port}        TLS port listening on, or 0.
# {unixsocket}      Unix domain socket listening on, or "".
# {config-file}     Name of configuration file used.
#
proc-title-template "{title} {listen-addr} {server-mode}"
# BEGIN MEIZHAOHUI COMMENTS
#   设置Redis进程的标题模板,保持默认值
# END MEIZHAOHUI COMMENTS

################################ SNAPSHOTTING  ################################

# Save the DB to disk.
#
# save <seconds> <changes>
#
# Redis will save the DB if both the given number of seconds and the given
# number of write operations against the DB occurred.
#
# Snapshotting can be completely disabled with a single empty string argument
# as in following example:
#
# save ""
#
# Unless specified otherwise, by default Redis will save the DB:
#   * After 3600 seconds (an hour) if at least 1 key changed
#   * After 300 seconds (5 minutes) if at least 100 keys changed
#   * After 60 seconds if at least 10000 keys changed
#
# You can set these explicitly by uncommenting the three following lines.
#
# save 3600 1
# save 300 100
# save 60 10000

# BEGIN MEIZHAOHUI COMMENTS
#   在Redis 6.2.14中,save配置指令已经被弃用,并在新版本中被移除。
#   Redis 6.0之前的版本使用save指令来配置在特定的时间间隔内执行数据集的持久化操作。
#   然而,这种方式是同步的,会阻塞服务器进程,因此不推荐在生产环境中使用。
#
#   在Redis 6.0及以上版本,持久化操作采用了新的默认配置,通过RDB和AOF来进行数据的持久化。
#   RDB是定时的数据快照,AOF是追加日志形式的持久化方式,它可以提供更好的持久化保证。
# END MEIZHAOHUI COMMENTS

# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
# This will make the user aware (in a hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# disaster will happen.
#
# If the background saving process will start working again Redis will
# automatically allow writes again.
#
# However if you have setup your proper monitoring of the Redis server
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.
stop-writes-on-bgsave-error yes

# BEGIN MEIZHAOHUI COMMENTS
#   stop-writes-on-bgsave-error 配置项是Redis的一个配置选项,用于控制当后台保存(RDB持久化)出现错误时,是否停止接收写操作。
#   如果设置为yes,则当后台保存进程因为某些错误(例如磁盘空间不足)无法执行时,Redis将停止接收写操作以避免数据不一致。
#   如果设置为no,即使后台保存失败,Redis也将继续处理写操作。
#   我们使用默认值,Redis在后台保存出错时停止写操作。
# END MEIZHAOHUI COMMENTS

# Compress string objects using LZF when dump .rdb databases?
# By default compression is enabled as it's almost always a win.
# If you want to save some CPU in the saving child set it to 'no' but
# the dataset will likely be bigger if you have compressible values or keys.
rdbcompression yes
# BEGIN MEIZHAOHUI COMMENTS
#   是否开启RDB文件压缩。
#   RDB文件压缩是Redis的一个优化特性,它可以显著减少RDB文件的大小,从而减少磁盘I/O操作,进而提升Redis的性能。
# END MEIZHAOHUI COMMENTS

# Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
# This makes the format more resistant to corruption but there is a performance
# hit to pay (around 10%) when saving and loading RDB files, so you can disable it
# for maximum performances.
#
# RDB files created with checksum disabled have a checksum of zero that will
# tell the loading code to skip the check.
rdbchecksum yes
# BEGIN MEIZHAOHUI COMMENTS
#   是否开启RDB文件数据校验。
#   Redis 6.2.14 引入了 RDB 文件的校验和功能,以确保数据的一致性和完整性。
#   这是通过在 RDB 文件的末尾添加一个 8 字节的校验和来实现的。
#   当 Redis 加载 RDB 文件时,它会计算文件的校验和,并与文件末尾的校验和进行比较,以验证文件的完整性。
# END MEIZHAOHUI COMMENTS

# Enables or disables full sanitation checks for ziplist and listpack etc when
# loading an RDB or RESTORE payload. This reduces the chances of a assertion or
# crash later on while processing commands.
# Options:
#   no         - Never perform full sanitation
#   yes        - Always perform full sanitation
#   clients    - Perform full sanitation only for user connections.
#                Excludes: RDB files, RESTORE commands received from the master
#                connection, and client connections which have the
#                skip-sanitize-payload ACL flag.
# The default should be 'clients' but since it currently affects cluster
# resharding via MIGRATE, it is temporarily set to 'no' by default.
#
# sanitize-dump-payload no
# BEGIN MEIZHAOHUI COMMENTS
#   sanitize-dump-payload配置项是用来在使用RDB持久化时,对数据进行清理和/或转换的。
#   当sanitize-dump-payload设置为yes时,Redis会尝试去除RDB文件中的一些不安全的payload,
#   如果它们不能被直接去除,它们将被替换为安全的值。
#   需要注意的是,这个配置项可能会对数据导入性能产生影响,因此在生产环境中使用时需要谨慎考虑。
# END MEIZHAOHUI COMMENTS

# The filename where to dump the DB
dbfilename dump.rdb
# BEGIN MEIZHAOHUI COMMENTS
#   数据库文件名,也就是RDB持久化时Dump文件的名字。
#   保持默认即可。
# END MEIZHAOHUI COMMENTS

# Remove RDB files used by replication in instances without persistence
# enabled. By default this option is disabled, however there are environments
# where for regulations or other security concerns, RDB files persisted on
# disk by masters in order to feed replicas, or stored on disk by replicas
# in order to load them for the initial synchronization, should be deleted
# ASAP. Note that this option ONLY WORKS in instances that have both AOF
# and RDB persistence disabled, otherwise is completely ignored.
#
# An alternative (and sometimes better) way to obtain the same effect is
# to use diskless replication on both master and replicas instances. However
# in the case of replicas, diskless is not always an option.
rdb-del-sync-files no
# BEGIN MEIZHAOHUI COMMENTS
#   删除未启用持久性的实例中复制所使用的 RDB 文件。
#   请注意,此选项仅适用于同时禁用 AOF 和 RDB 持久性的实例,否则将被完全忽略。
#   保持默认即可。
# END MEIZHAOHUI COMMENTS


# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
# dir ./
# BEGIN MEIZHAOHUI COMMENTS
#   dir配置指的是Redis工作目录,用于存储持久化的数据文件和日志文件等。
#   我们将数据文件单独存放到 /srv/redis/data 目录下
# END MEIZHAOHUI COMMENTS
dir /srv/redis/data

################################# REPLICATION #################################

# Master-Replica replication. Use replicaof to make a Redis instance a copy of
# another Redis server. A few things to understand ASAP about Redis replication.
#
#   +------------------+      +---------------+
#   |      Master      | ---> |    Replica    |
#   | (receive writes) |      |  (exact copy) |
#   +------------------+      +---------------+
#
# 1) Redis replication is asynchronous, but you can configure a master to
#    stop accepting writes if it appears to be not connected with at least
#    a given number of replicas.
# 2) Redis replicas are able to perform a partial resynchronization with the
#    master if the replication link is lost for a relatively small amount of
#    time. You may want to configure the replication backlog size (see the next
#    sections of this file) with a sensible value depending on your needs.
# 3) Replication is automatic and does not need user intervention. After a
#    network partition replicas automatically try to reconnect to masters
#    and resynchronize with them.
#
# replicaof <masterip> <masterport>
# BEGIN MEIZHAOHUI COMMENTS
#   关于 Redis 复制,有几件事需要尽快了解。
#   1) Redis 复制是异步的,但您可以配置主服务器,如果它似乎与至少给定数量的副本没有连接,则停止接受写入。
#   2) 如果复制链接在相对较短的时间内丢失,Redis 副本能够与主服务器执行部分重新同步。您可能需要根据需要使用合理的值配置复制积压大小。
#   3) 复制是自动的,不需要用户干预。在网络断开后,副本会自动尝试重新连接到主服务器,并与它们重新同步。
#
#   replicaof指令被用于将当前的Redis服务器实例配置为另一个Redis服务器实例的复制品。
#   这是一个主从复制的配置选项,通常在Redis的配置文件中设置。
# END MEIZHAOHUI COMMENTS


# If the master is password protected (using the "requirepass" configuration
# directive below) it is possible to tell the replica to authenticate before
# starting the replication synchronization process, otherwise the master will
# refuse the replica request.
#
# masterauth <master-password>
#
# BEGIN MEIZHAOHUI COMMENTS
#   masterauth配置指令用于设置连接到主节点(如果Redis实例是复制的从节点)时所需的密码。
#   主从配置时,从节点需要配置该参数。
# END MEIZHAOHUI COMMENTS

#
# However this is not enough if you are using Redis ACLs (for Redis version
# 6 or greater), and the default user is not capable of running the PSYNC
# command and/or other commands needed for replication. In this case it's
# better to configure a special user to use with replication, and specify the
# masteruser configuration as such:
#
# masteruser <username>
#
# BEGIN MEIZHAOHUI COMMENTS
#   masteruser 用来指定主节点使用的用户。Redis 6或以上版本才支持ACL控制。
# END MEIZHAOHUI COMMENTS


#
# When masteruser is specified, the replica will authenticate against its
# master using the new AUTH form: AUTH <username> <password>.

# When a replica loses its connection with the master, or when the replication
# is still in progress, the replica can act in two different ways:
#
# 1) if replica-serve-stale-data is set to 'yes' (the default) the replica will
#    still reply to client requests, possibly with out of date data, or the
#    data set may just be empty if this is the first synchronization.
#
# 2) If replica-serve-stale-data is set to 'no' the replica will reply with
#    an error "SYNC with master in progress" to all commands except:
#    INFO, REPLICAOF, AUTH, PING, SHUTDOWN, REPLCONF, ROLE, CONFIG, SUBSCRIBE,
#    UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBLISH, PUBSUB, COMMAND, POST,
#    HOST and LATENCY.
#
replica-serve-stale-data yes
# BEGIN MEIZHAOHUI COMMENTS
#   replica-serve-stale-data配置选项用于控制副本节点在没有可用的主节点时的行为。
#   当设置为yes时,副本会继续响应客户端请求,尽管它可能没有从主节点接收到最新的数据。
#   当设置为no时,除了指定的命令之外,副本会对所有请求返回错误"SYNC with master in progress"。
#   保持默认即可。
# END MEIZHAOHUI COMMENTS


# You can configure a replica instance to accept writes or not. Writing against
# a replica instance may be useful to store some ephemeral data (because data
# written on a replica will be easily deleted after resync with the master) but
# may also cause problems if clients are writing to it because of a
# misconfiguration.
#
# Since Redis 2.6 by default replicas are read-only.
#
# Note: read only replicas are not designed to be exposed to untrusted clients
# on the internet. It's just a protection layer against misuse of the instance.
# Still a read only replica exports by default all the administrative commands
# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve
# security of read only replicas using 'rename-command' to shadow all the
# administrative / dangerous commands.
replica-read-only yes
# BEGIN MEIZHAOHUI COMMENTS
#   副本只读。
# END MEIZHAOHUI COMMENTS

# Replication SYNC strategy: disk or socket.
#
# New replicas and reconnecting replicas that are not able to continue the
# replication process just receiving differences, need to do what is called a
# "full synchronization". An RDB file is transmitted from the master to the
# replicas.
#
# The transmission can happen in two different ways:
#
# 1) Disk-backed: The Redis master creates a new process that writes the RDB
#                 file on disk. Later the file is transferred by the parent
#                 process to the replicas incrementally.
# 2) Diskless: The Redis master creates a new process that directly writes the
#              RDB file to replica sockets, without touching the disk at all.
#
# With disk-backed replication, while the RDB file is generated, more replicas
# can be queued and served with the RDB file as soon as the current child
# producing the RDB file finishes its work. With diskless replication instead
# once the transfer starts, new replicas arriving will be queued and a new
# transfer will start when the current one terminates.
#
# When diskless replication is used, the master waits a configurable amount of
# time (in seconds) before starting the transfer in the hope that multiple
# replicas will arrive and the transfer can be parallelized.
#
# With slow disks and fast (large bandwidth) networks, diskless replication
# works better.
repl-diskless-sync no
# BEGIN MEIZHAOHUI COMMENTS
#   是否使用socket方式复制数据(无盘同步),新slave连接连接时候需要做数据的全量同步,
#   redis server就要从内存dump出新的RDB文件,然后从master传到slave,有两种方式把RDB文件传输给客户端:
#   1) 基于硬盘(disk-backed):master创建一个新进程dump RDB,RDB完成之后由父进程(即主进程)传给slaves。
#   2) 基于socket(diskless): master创建一个新进程直接dump RDB到slave的socket,不经过主进程,不经过硬盘。
#   基于硬盘的话,RDB文件创建后,一旦创建完毕,可以同时服务更多的slave,
#   但是基于socket的话, 新slave连接到master之后得逐个同步数据。
#   在磁盘较慢并且网络较快的时候,可以用diskless(yes),否则使用磁盘(no)。
#   保持默认即可。
# END MEIZHAOHUI COMMENTS


# When diskless replication is enabled, it is possible to configure the delay
# the server waits in order to spawn the child that transfers the RDB via socket
# to the replicas.
#
# This is important since once the transfer starts, it is not possible to serve
# new replicas arriving, that will be queued for the next RDB transfer, so the
# server waits a delay in order to let more replicas arrive.
#
# The delay is specified in seconds, and by default is 5 seconds. To disable
# it entirely just set it to 0 seconds and the transfer will start ASAP.
repl-diskless-sync-delay 5
# BEGIN MEIZHAOHUI COMMENTS
#   diskless复制的延迟时间,设置0为关闭,在延迟时间内连接的新客户端,会一起通过disk方式同步数据,
#   但是一旦复制开始还没有结束之前,master节点不会再接收新slave的复制请求,直到下一次同步开始。
#   保持默认即可。
#   repl-diskless-sync no 使用磁盘复制数据时,这个配置无用。
# END MEIZHAOHUI COMMENTS


# -----------------------------------------------------------------------------
# WARNING: RDB diskless load is experimental. Since in this setup the replica
# does not immediately store an RDB on disk, it may cause data loss during
# failovers. RDB diskless load + Redis modules not handling I/O reads may also
# cause Redis to abort in case of I/O errors during the initial synchronization
# stage with the master. Use only if you know what you are doing.
# -----------------------------------------------------------------------------
#
# Replica can load the RDB it reads from the replication link directly from the
# socket, or store the RDB to a file and read that file after it was completely
# received from the master.
#
# In many cases the disk is slower than the network, and storing and loading
# the RDB file may increase replication time (and even increase the master's
# Copy on Write memory and salve buffers).
# However, parsing the RDB file directly from the socket may mean that we have
# to flush the contents of the current database before the full rdb was
# received. For this reason we have the following options:
#
# "disabled"    - Don't use diskless load (store the rdb file to the disk first)
# "on-empty-db" - Use diskless load only when it is completely safe.
# "swapdb"      - Keep a copy of the current db contents in RAM while parsing
#                 the data directly from the socket. note that this requires
#                 sufficient memory, if you don't have it, you risk an OOM kill.
repl-diskless-load disabled
# BEGIN MEIZHAOHUI COMMENTS
#   repl-diskless-load选项是用来控制无盘复制(diskless replication)功能的启用与否。
#   如果启用,则意味着当主服务器进行数据同步时,可以不将数据写入磁盘文件,而是通过网络直接发送给从服务器。
#   这可以提高数据同步的效率,减少磁盘I/O的开销。
#   默认不启用。保持默认即可。
# END MEIZHAOHUI COMMENTS


# Replicas send PINGs to server in a predefined interval. It's possible to
# change this interval with the repl_ping_replica_period option. The default
# value is 10 seconds.
#
# repl-ping-replica-period 10
# BEGIN MEIZHAOHUI COMMENTS
#   副本多长时间向向主节点发送一次PING请求
#   默认10秒。保持默认即可。
# END MEIZHAOHUI COMMENTS

# The following option sets the replication timeout for:
#
# 1) Bulk transfer I/O during SYNC, from the point of view of replica.
# 2) Master timeout from the point of view of replicas (data, pings).
# 3) Replica timeout from the point of view of masters (REPLCONF ACK pings).
#
# It is important to make sure that this value is greater than the value
# specified for repl-ping-replica-period otherwise a timeout will be detected
# every time there is low traffic between the master and the replica. The default
# value is 60 seconds.
#
# repl-timeout 60
# BEGIN MEIZHAOHUI COMMENTS
#   复制连接的超时时间,需要大于repl-ping-slave-period,否则会经常报超时。
#   默认60秒。保持默认即可。
# END MEIZHAOHUI COMMENTS

# Disable TCP_NODELAY on the replica socket after SYNC?
#
# If you select "yes" Redis will use a smaller number of TCP packets and
# less bandwidth to send data to replicas. But this can add a delay for
# the data to appear on the replica side, up to 40 milliseconds with
# Linux kernels using a default configuration.
#
# If you select "no" the delay for data to appear on the replica side will
# be reduced but more bandwidth will be used for replication.
#
# By default we optimize for low latency, but in very high traffic conditions
# or when the master and replicas are many hops away, turning this to "yes" may
# be a good idea.
repl-disable-tcp-nodelay no
# BEGIN MEIZHAOHUI COMMENTS
#   在socket模式下是否在slave套接字发送SYNC之后禁用 TCP_NODELAY。
#   由于不使用socket模式。保持默认即可。
# END MEIZHAOHUI COMMENTS


# Set the replication backlog size. The backlog is a buffer that accumulates
# replica data when replicas are disconnected for some time, so that when a
# replica wants to reconnect again, often a full resync is not needed, but a
# partial resync is enough, just passing the portion of data the replica
# missed while disconnected.
#
# The bigger the replication backlog, the longer the replica can endure the
# disconnect and later be able to perform a partial resynchronization.
#
# The backlog is only allocated if there is at least one replica connected.
#
# repl-backlog-size 1mb
# BEGIN MEIZHAOHUI COMMENTS
#   复制缓冲区内存大小,只有在slave连接之后才分配内存。
#   请注意,设置的repl-backlog-size值不能超过主服务器的可用内存。
#   在实际操作中,应当根据实际需求和服务器的内存容量来设置这个值。
#   如果复制延迟严重,可以考虑增加这个值。
#   如果主服务器数据变化不频繁,可以减少这个值来节省内存。
#   保持默认即可。
# END MEIZHAOHUI COMMENTS


# After a master has no connected replicas for some time, the backlog will be
# freed. The following option configures the amount of seconds that need to
# elapse, starting from the time the last replica disconnected, for the backlog
# buffer to be freed.
#
# Note that replicas never free the backlog for timeout, since they may be
# promoted to masters later, and should be able to correctly "partially
# resynchronize" with other replicas: hence they should always accumulate backlog.
#
# A value of 0 means to never release the backlog.
#
# repl-backlog-ttl 3600
# BEGIN MEIZHAOHUI COMMENTS
#   多长时间master没有slave连接,就清空复制缓冲区内存。
#   默认3600秒。
#   保持默认即可。
# END MEIZHAOHUI COMMENTS

# The replica priority is an integer number published by Redis in the INFO
# output. It is used by Redis Sentinel in order to select a replica to promote
# into a master if the master is no longer working correctly.
#
# A replica with a low priority number is considered better for promotion, so
# for instance if there are three replicas with priority 10, 100, 25 Sentinel
# will pick the one with priority 10, that is the lowest.
#
# However a special priority of 0 marks the replica as not able to perform the
# role of master, so a replica with priority of 0 will never be selected by
# Redis Sentinel for promotion.
#
# By default the priority is 100.
replica-priority 100
# BEGIN MEIZHAOHUI COMMENTS
#   当master不可用,Sentinel会根据slave的优先级选举一个master,
#   最低的优先级的slave,当选master。
#   即值小的节点当前新的master。
#   而配置成0,永远不会被选举。
#   保持默认即可。
#   如果配置成哨兵模式,可以适当修改从节点的优先级值。
# END MEIZHAOHUI COMMENTS

# -----------------------------------------------------------------------------
# By default, Redis Sentinel includes all replicas in its reports. A replica
# can be excluded from Redis Sentinel's announcements. An unannounced replica
# will be ignored by the 'sentinel replicas <master>' command and won't be
# exposed to Redis Sentinel's clients.
#
# This option does not change the behavior of replica-priority. Even with
# replica-announced set to 'no', the replica can be promoted to master. To
# prevent this behavior, set replica-priority to 0.
#
# replica-announced yes
# BEGIN MEIZHAOHUI COMMENTS
#   默认情况下,Redis Sentinel 在其报告中包括所有副本。
#   副本可以从 Redis Sentinel 的公告中排除。
#   未公告的副本将被"sentinel replicas <master>"命令忽略,
#   并且不会暴露给 Redis Sentinel 的客户端。
#
#   保持默认即可。
#   此配置不会改变从节点的选举行为,即使replica-announced no ,这个节点也可以提升为主节点。
#   要禁止该节点提升为主节点,应配置replica-priority 0 不参入选举。
# END MEIZHAOHUI COMMENTS


# It is possible for a master to stop accepting writes if there are less than
# N replicas connected, having a lag less or equal than M seconds.
#
# The N replicas need to be in "online" state.
#
# The lag in seconds, that must be <= the specified value, is calculated from
# the last ping received from the replica, that is usually sent every second.
#
# This option does not GUARANTEE that N replicas will accept the write, but
# will limit the window of exposure for lost writes in case not enough replicas
# are available, to the specified number of seconds.
#
# For example to require at least 3 replicas with a lag <= 10 seconds use:
#
# min-replicas-to-write 3
# min-replicas-max-lag 10
#
# Setting one or the other to 0 disables the feature.
#
# By default min-replicas-to-write is set to 0 (feature disabled) and
# min-replicas-max-lag is set to 10.

# BEGIN MEIZHAOHUI COMMENTS
#   如果连接的副本少于 N 个,且延迟小于或等于 M 秒,则主服务器可能会停止接受写入。
#   N 个副本需要处于"在线"状态。
#   延迟(以秒为单位),必须小于等于指定值,
#   是根据从副本收到的最后一个 ping 计算得出的,通常每秒发送一次。
#   至少有3个可连接的slave,master才接受写操作。
#   3个slave的ping延迟不能超过10秒,否则master也将停止写操作。
#   如果集群本来就只有3个节点,可以考虑减少min-replicas-to-write的值,
#   比如设置为1,这样即使只有一个副本,主节点也会进行数据持久化。
#   默认情况下,禁用了该特性。
# END MEIZHAOHUI COMMENTS



# A Redis master is able to list the address and port of the attached
# replicas in different ways. For example the "INFO replication" section
# offers this information, which is used, among other tools, by
# Redis Sentinel in order to discover replica instances.
# Another place where this info is available is in the output of the
# "ROLE" command of a master.
#
# The listed IP address and port normally reported by a replica is
# obtained in the following way:
#
#   IP: The address is auto detected by checking the peer address
#   of the socket used by the replica to connect with the master.
#
#   Port: The port is communicated by the replica during the replication
#   handshake, and is normally the port that the replica is using to
#   listen for connections.
#
# However when port forwarding or Network Address Translation (NAT) is
# used, the replica may actually be reachable via different IP and port
# pairs. The following two options can be used by a replica in order to
# report to its master a specific set of IP and port, so that both INFO
# and ROLE will report those values.
#
# There is no need to use both the options if you need to override just
# the port or the IP address.
#
# replica-announce-ip 5.5.5.5
# replica-announce-port 1234
# BEGIN MEIZHAOHUI COMMENTS
#   配置通告的IP和端口信息,我们不单独设置。
# END MEIZHAOHUI COMMENTS

############################### KEYS TRACKING #################################

# Redis implements server assisted support for client side caching of values.
# This is implemented using an invalidation table that remembers, using
# a radix key indexed by key name, what clients have which keys. In turn
# this is used in order to send invalidation messages to clients. Please
# check this page to understand more about the feature:
#
#   https://redis.io/topics/client-side-caching
#
# When tracking is enabled for a client, all the read only queries are assumed
# to be cached: this will force Redis to store information in the invalidation
# table. When keys are modified, such information is flushed away, and
# invalidation messages are sent to the clients. However if the workload is
# heavily dominated by reads, Redis could use more and more memory in order
# to track the keys fetched by many clients.
#
# For this reason it is possible to configure a maximum fill value for the
# invalidation table. By default it is set to 1M of keys, and once this limit
# is reached, Redis will start to evict keys in the invalidation table
# even if they were not modified, just to reclaim memory: this will in turn
# force the clients to invalidate the cached values. Basically the table
# maximum size is a trade off between the memory you want to spend server
# side to track information about who cached what, and the ability of clients
# to retain cached objects in memory.
#
# If you set the value to 0, it means there are no limits, and Redis will
# retain as many keys as needed in the invalidation table.
# In the "stats" INFO section, you can find information about the number of
# keys in the invalidation table at every given moment.
#
# Note: when key tracking is used in broadcasting mode, no memory is used
# in the server side so this setting is useless.
#
# tracking-table-max-keys 1000000
# BEGIN MEIZHAOHUI COMMENTS
#   配置追踪表(tracking table)的最大键数量的。
#   追踪表是Redis用来记录键空间通知事件的内存结构,这些事件可以是键的添加、删除或者过期等。
#   保持默认即可。
# END MEIZHAOHUI COMMENTS

################################## SECURITY ###################################

# Warning: since Redis is pretty fast, an outside user can try up to
# 1 million passwords per second against a modern box. This means that you
# should use very strong passwords, otherwise they will be very easy to break.
# Note that because the password is really a shared secret between the client
# and the server, and should not be memorized by any human, the password
# can be easily a long string from /dev/urandom or whatever, so by using a
# long and unguessable password no brute force attack will be possible.

# Redis ACL users are defined in the following format:
#
#   user <username> ... acl rules ...
#
# For example:
#
#   user worker +@list +@connection ~jobs:* on >ffa9203c493aa99
#
# The special username "default" is used for new connections. If this user
# has the "nopass" rule, then new connections will be immediately authenticated
# as the "default" user without the need of any password provided via the
# AUTH command. Otherwise if the "default" user is not flagged with "nopass"
# the connections will start in not authenticated state, and will require
# AUTH (or the HELLO command AUTH option) in order to be authenticated and
# start to work.
# BEGIN MEIZHAOHUI COMMENTS
#   警告:由于 Redis 速度非常快,外部用户每秒最多可以尝试 100 万个密码来破解现代机器。
#   这意味着您应该使用非常强的密码,否则它们将很容易被破解。
#   请注意,由于密码实际上是客户端和服务器之间的共享秘密,不应被任何人记住,
#   因此密码很容易是来自 /dev/urandom 或其他任何东西的长字符串,
#   因此通过使用长且不可猜测的密码,不可能进行暴力攻击。
# END MEIZHAOHUI COMMENTS


#
# The ACL rules that describe what a user can do are the following:
#
#  on           Enable the user: it is possible to authenticate as this user.
#  off          Disable the user: it's no longer possible to authenticate
#               with this user, however the already authenticated connections
#               will still work.
#  skip-sanitize-payload    RESTORE dump-payload sanitation is skipped.
#  sanitize-payload         RESTORE dump-payload is sanitized (default).
#  +<command>   Allow the execution of that command
#  -<command>   Disallow the execution of that command
#  +@<category> Allow the execution of all the commands in such category
#               with valid categories are like @admin, @set, @sortedset, ...
#               and so forth, see the full list in the server.c file where
#               the Redis command table is described and defined.
#               The special category @all means all the commands, but currently
#               present in the server, and that will be loaded in the future
#               via modules.
#  +<command>|subcommand    Allow a specific subcommand of an otherwise
#                           disabled command. Note that this form is not
#                           allowed as negative like -DEBUG|SEGFAULT, but
#                           only additive starting with "+".
#  allcommands  Alias for +@all. Note that it implies the ability to execute
#               all the future commands loaded via the modules system.
#  nocommands   Alias for -@all.
#  ~<pattern>   Add a pattern of keys that can be mentioned as part of
#               commands. For instance ~* allows all the keys. The pattern
#               is a glob-style pattern like the one of KEYS.
#               It is possible to specify multiple patterns.
#  allkeys      Alias for ~*
#  resetkeys    Flush the list of allowed keys patterns.
#  &<pattern>   Add a glob-style pattern of Pub/Sub channels that can be
#               accessed by the user. It is possible to specify multiple channel
#               patterns.
#  allchannels  Alias for &*
#  resetchannels            Flush the list of allowed channel patterns.
#  ><password>  Add this password to the list of valid password for the user.
#               For example >mypass will add "mypass" to the list.
#               This directive clears the "nopass" flag (see later).
#  <<password>  Remove this password from the list of valid passwords.
#  nopass       All the set passwords of the user are removed, and the user
#               is flagged as requiring no password: it means that every
#               password will work against this user. If this directive is
#               used for the default user, every new connection will be
#               immediately authenticated with the default user without
#               any explicit AUTH command required. Note that the "resetpass"
#               directive will clear this condition.
#  resetpass    Flush the list of allowed passwords. Moreover removes the
#               "nopass" status. After "resetpass" the user has no associated
#               passwords and there is no way to authenticate without adding
#               some password (or setting it as "nopass" later).
#  reset        Performs the following actions: resetpass, resetkeys, off,
#               -@all. The user returns to the same state it has immediately
#               after its creation.
#
# ACL rules can be specified in any order: for instance you can start with
# passwords, then flags, or key patterns. However note that the additive
# and subtractive rules will CHANGE MEANING depending on the ordering.
# For instance see the following example:
#
#   user alice on +@all -DEBUG ~* >somepassword
#
# This will allow "alice" to use all the commands with the exception of the
# DEBUG command, since +@all added all the commands to the set of the commands
# alice can use, and later DEBUG was removed. However if we invert the order
# of two ACL rules the result will be different:
#
#   user alice on -DEBUG +@all ~* >somepassword
#
# Now DEBUG was removed when alice had yet no commands in the set of allowed
# commands, later all the commands are added, so the user will be able to
# execute everything.
#
# Basically ACL rules are processed left-to-right.
#
# For more information about ACL configuration please refer to
# the Redis web site at https://redis.io/topics/acl

# ACL LOG
#
# The ACL Log tracks failed commands and authentication events associated
# with ACLs. The ACL Log is useful to troubleshoot failed commands blocked 
# by ACLs. The ACL Log is stored in memory. You can reclaim memory with 
# ACL LOG RESET. Define the maximum entry length of the ACL Log below.
acllog-max-len 128
# BEGIN MEIZHAOHUI COMMENTS
#   acllog-max-len配置项用于设置ACL日志的最大长度。
#   ACL日志记录了所有的访问控制列表(ACL)相关的命令执行历史。
#   当ACL日志记录数据超过了acllog-max-len配置的长度时,旧的记录会被移除。
# END MEIZHAOHUI COMMENTS


# Using an external ACL file
#
# Instead of configuring users here in this file, it is possible to use
# a stand-alone file just listing users. The two methods cannot be mixed:
# if you configure users here and at the same time you activate the external
# ACL file, the server will refuse to start.
#
# The format of the external ACL user file is exactly the same as the
# format that is used inside redis.conf to describe users.
#
# aclfile /etc/redis/users.acl
# BEGIN MEIZHAOHUI COMMENTS
#   使用外部 ACL 文件。aclfile配置用来设置外部ACL文件路径。
#   除了在此文件中配置用户之外,还可以使用# 仅列出用户的独立文件。
#   这两种方法不能混合使用:
#   如果您在此配置用户,同时激活外部ACL 文件,服务器将拒绝启动。
#
#  外部 ACL 用户文件的格式与 redis.conf 中用于描述用户的格式完全相同。
#  保持默认即可。不启动ACL文件。
# END MEIZHAOHUI COMMENTS

# IMPORTANT NOTE: starting with Redis 6 "requirepass" is just a compatibility
# layer on top of the new ACL system. The option effect will be just setting
# the password for the default user. Clients will still authenticate using
# AUTH <password> as usually, or more explicitly with AUTH default <password>
# if they follow the new protocol: both will work.
#
# The requirepass is not compatable with aclfile option and the ACL LOAD
# command, these will cause requirepass to be ignored.
#
# requirepass foobared
# BEGIN MEIZHAOHUI COMMENTS
#   重要提示:从 Redis 6 开始,"requirepass"只是新 ACL 系统之上的兼容层。
#   该选项的效果只是设置默认用户的密码。
#   客户端仍将像往常一样使用 AUTH <password> 进行身份验证,
#   或者更明确地使用 AUTH default <password> 进行身份验证,
#   如果它们遵循新协议:两者都可以工作。
#
#   requirepass 与 aclfile 选项和 ACL LOAD 命令不兼容,
#   这些将导致 requirepass 被忽略。
#
# 请注意,出于安全考虑,应确保密码足够复杂,并在生产环境中使用复杂的安全措施来保护密码。
# END MEIZHAOHUI COMMENTS
requirepass ALONGPASSWORD

# New users are initialized with restrictive permissions by default, via the
# equivalent of this ACL rule 'off resetkeys -@all'. Starting with Redis 6.2, it
# is possible to manage access to Pub/Sub channels with ACL rules as well. The
# default Pub/Sub channels permission if new users is controlled by the 
# acl-pubsub-default configuration directive, which accepts one of these values:
#
# allchannels: grants access to all Pub/Sub channels
# resetchannels: revokes access to all Pub/Sub channels
#
# To ensure backward compatibility while upgrading Redis 6.0, acl-pubsub-default
# defaults to the 'allchannels' permission.
#
# Future compatibility note: it is very likely that in a future version of Redis
# the directive's default of 'allchannels' will be changed to 'resetchannels' in
# order to provide better out-of-the-box Pub/Sub security. Therefore, it is
# recommended that you explicitly define Pub/Sub permissions for all users
# rather then rely on implicit default values. Once you've set explicit
# Pub/Sub for all existing users, you should uncomment the following line.
#
# acl-pubsub-default resetchannels

# Command renaming (DEPRECATED).
#
# ------------------------------------------------------------------------
# WARNING: avoid using this option if possible. Instead use ACLs to remove
# commands from the default user, and put them only in some admin user you
# create for administrative purposes.
# ------------------------------------------------------------------------
#
# It is possible to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# hard to guess so that it will still be available for internal-use tools
# but not available for general clients.
#

# BEGIN MEIZHAOHUI COMMENTS
#   可以在共享环境中更改危险命令的名称,暂时不设置。
# END MEIZHAOHUI COMMENTS
# Example:
#
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#
# It is also possible to completely kill a command by renaming it into
# an empty string:
#
# rename-command CONFIG ""
#
# Please note that changing the name of commands that are logged into the
# AOF file or transmitted to replicas may cause problems.

################################### CLIENTS ####################################

# Set the max number of connected clients at the same time. By default
# this limit is set to 10000 clients, however if the Redis server is not
# able to configure the process file limit to allow for the specified limit
# the max number of allowed clients is set to the current file limit
# minus 32 (as Redis reserves a few file descriptors for internal uses).
#
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
#
# IMPORTANT: When Redis Cluster is used, the max number of connections is also
# shared with the cluster bus: every node in the cluster will use two
# connections, one incoming and another outgoing. It is important to size the
# limit accordingly in case of very large clusters.
#
# maxclients 10000
# BEGIN MEIZHAOHUI COMMENTS
#   设置同时连接的最大客户端数量。
#   默认情况下,此限制设置为 10000 个客户端。
#   但是如果 Redis 服务器无法配置进程文件限制以允许指定的限制,
#   则允许的最大客户端数量将设置为当前文件限制减 32(因为 Redis 保留了一些文件描述符供内部使用)。
#
#   一旦达到限制,Redis 将关闭所有新连接并发送错误"已达到最大客户端数量"。
#
#   重要提示:使用 Redis 集群时,最大连接数也与集群总线共享:
#   集群中的每个节点都将使用两个连接,一个传入,另一个传出。
#   如果集群非常大,则必须相应地调整限制的大小。
#   我们不单独设置。
# END MEIZHAOHUI COMMENTS

############################## MEMORY MANAGEMENT ################################

# Set a memory usage limit to the specified amount of bytes.
# When the memory limit is reached Redis will try to remove keys
# according to the eviction policy selected (see maxmemory-policy).
#
# If Redis can't remove keys according to the policy, or if the policy is
# set to 'noeviction', Redis will start to reply with errors to commands
# that would use more memory, like SET, LPUSH, and so on, and will continue
# to reply to read-only commands like GET.
#
# This option is usually useful when using Redis as an LRU or LFU cache, or to
# set a hard memory limit for an instance (using the 'noeviction' policy).
#
# WARNING: If you have replicas attached to an instance with maxmemory on,
# the size of the output buffers needed to feed the replicas are subtracted
# from the used memory count, so that network problems / resyncs will
# not trigger a loop where keys are evicted, and in turn the output
# buffer of replicas is full with DELs of keys evicted triggering the deletion
# of more keys, and so forth until the database is completely emptied.
#
# In short... if you have replicas attached it is suggested that you set a lower
# limit for maxmemory so that there is some free RAM on the system for replica
# output buffers (but this is not needed if the policy is 'noeviction').
#
# maxmemory <bytes>
# BEGIN MEIZHAOHUI COMMENTS
#   将内存使用限制设置为指定的字节数。
#   当达到内存限制时,Redis 将尝试根据所选的驱逐策略删除键(请参阅 maxmemory-policy)。
#
#   如果 Redis 无法根据策略删除键,或者策略设置为"noeviction",
#   Redis 将开始以错误回复将使用更多内存的命令,例如 SET、LPUSH 等,并将继续回复只读命令,例如 GET。
#
#   此选项通常在将 Redis 用作 LRU 或 LFU 缓存时有用,或者在为实例设置硬内存限制时很有用(使用"noeviction"策略)。
#
#   警告:如果您将副本附加到启用了 maxmemory 的实例,
#   将从已用内存计数中减去提供副本所需的输出缓冲区大小,这样网络问题/重新同步就不会触发循环,导致键被逐出,
#   反过来,副本的输出缓冲区已满,被逐出的键的 DEL 触发了更多键的删除,依此类推,直到数据库完全清空。
#
#   简而言之……如果您附加了副本,建议您为 maxmemory 设置一个较低的限制,
#   以便系统上有一些可用于副本输出缓冲区的可用 RAM(但如果策略为"noeviction",则不需要这样做)。
# END MEIZHAOHUI COMMENTS
maxmemory 1gb

# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select one from the following behaviors:
#
# volatile-lru -> Evict using approximated LRU, only keys with an expire set.
# allkeys-lru -> Evict any key using approximated LRU.
# volatile-lfu -> Evict using approximated LFU, only keys with an expire set.
# allkeys-lfu -> Evict any key using approximated LFU.
# volatile-random -> Remove a random key having an expire set.
# allkeys-random -> Remove a random key, any key.
# volatile-ttl -> Remove the key with the nearest expire time (minor TTL)
# noeviction -> Don't evict anything, just return an error on write operations.
#
# LRU means Least Recently Used
# LFU means Least Frequently Used
#
# Both LRU, LFU and volatile-ttl are implemented using approximated
# randomized algorithms.
#
# Note: with any of the above policies, when there are no suitable keys for
# eviction, Redis will return an error on write operations that require
# more memory. These are usually commands that create new keys, add data or
# modify existing keys. A few examples are: SET, INCR, HSET, LPUSH, SUNIONSTORE,
# SORT (due to the STORE argument), and EXEC (if the transaction includes any
# command that requires memory).
#
# The default is:
#
# maxmemory-policy noeviction
# BEGIN MEIZHAOHUI COMMENTS
#   MAXMEMORY POLICY:达到 maxmemory 时,Redis 将如何选择要删除的内容。您可以从以下行为中选择一个:
#
#   volatile-lru -> 使用近似 LRU 驱逐,仅驱逐设置了过期时间的键。
#   allkeys-lru -> 使用近似 LRU 驱逐任何键。
#   volatile-lfu -> 使用近似 LFU 驱逐,仅驱逐设置了过期时间的键。
#   allkeys-lfu -> 使用近似 LFU 驱逐任何键。
#   volatile-random -> 删除设置了过期时间的随机键。
#   allkeys-random -> 删除随机键,任何键。
#   volatile-ttl -> 删除具有最近过期时间(次要 TTL)的键
#   noeviction -> 不驱逐任何内容,仅在写入操作时返回错误。
#
#   LRU 表示最近最少使用
#   LFU 表示最不频繁使用
#
#   LRU、LFU 和 volatile-ttl 都是使用近似随机算法实现的。
#
#   注意:对于上述任何一种策略,当没有适合驱逐的键时,Redis 将在需要更多内存的写入操作上返回错误。
#   这些通常是创建新键、添加数据或修改现有键的命令。
#   一些示例是:SET、INCR、HSET、LPUSH、SUNIONSTORE、SORT(由于 STORE 参数)和 EXEC(如果事务包含任何需要内存的命令)。
#   默认是 maxmemory-policy noeviction, 即不驱逐任何内容,仅在写入操作时返回错误。
# END MEIZHAOHUI COMMENTS


# LRU, LFU and minimal TTL algorithms are not precise algorithms but approximated
# algorithms (in order to save memory), so you can tune it for speed or
# accuracy. By default Redis will check five keys and pick the one that was
# used least recently, you can change the sample size using the following
# configuration directive.
#
# The default of 5 produces good enough results. 10 Approximates very closely
# true LRU but costs more CPU. 3 is faster but not very accurate.
#
# maxmemory-samples 5
# BEGIN MEIZHAOHUI COMMENTS
#   LRU、LFU 和最小 TTL 算法不是精确算法,而是近似算法(为了节省内存),
#   因此您可以调整速度或准确性。
#   默认情况下,Redis 将检查五个键并选择最近使用最少的键,您可以使用以下配置指令更改样本大小。
#
#   默认值 5 产生足够好的结果。10 非常接近真正的 LRU,但消耗更多 CPU。3 更快但不太准确。
#   因为未启用驱逐算法,此配置无作用。
#   我们保持默认 maxmemory-samples 5 即可。
# END MEIZHAOHUI COMMENTS

# Eviction processing is designed to function well with the default setting.
# If there is an unusually large amount of write traffic, this value may need to
# be increased.  Decreasing this value may reduce latency at the risk of 
# eviction processing effectiveness
#   0 = minimum latency, 10 = default, 100 = process without regard to latency
#
# maxmemory-eviction-tenacity 10
# BEGIN MEIZHAOHUI COMMENTS
#   设置移除容忍度。
#   数值越小表示容忍度越低,需要移除的数据移除延迟越小;
#   数值越大表示容忍度越高,需要移除的数据移除延迟越大。
#   如果写入流量异常大,则可能需要增加此值。
#   降低此值可能会降低延迟,但可能会降低驱逐处理效率
#   0 = 最小延迟,10 = 默认值,100 = 不考虑延迟的处理。
# END MEIZHAOHUI COMMENTS

# Starting from Redis 5, by default a replica will ignore its maxmemory setting
# (unless it is promoted to master after a failover or manually). It means
# that the eviction of keys will be just handled by the master, sending the
# DEL commands to the replica as keys evict in the master side.
#
# This behavior ensures that masters and replicas stay consistent, and is usually
# what you want, however if your replica is writable, or you want the replica
# to have a different memory setting, and you are sure all the writes performed
# to the replica are idempotent, then you may change this default (but be sure
# to understand what you are doing).
#
# Note that since the replica by default does not evict, it may end using more
# memory than the one set via maxmemory (there are certain buffers that may
# be larger on the replica, or data structures may sometimes take more memory
# and so forth). So make sure you monitor your replicas and make sure they
# have enough memory to never hit a real out-of-memory condition before the
# master hits the configured maxmemory setting.
#
# replica-ignore-maxmemory yes
# BEGIN MEIZHAOHUI COMMENTS
#   replica-ignore-maxmemor用于控制 Redis 副本(replica)在达到 maxmemory 限制时的行为。
#   当 replica-ignore-maxmemory 设置为 yes 时,副本会忽略 maxmemory 设置,
#   并允许内存持续增长超过 maxmemory 指定的限制。
#   这可能会导致副本的内存使用超过主服务器,并可能导致不一致的数据状态。
#
#   通常,这个选项应当设置为 no,以确保副本服务器的内存使用保持在安全的范围内。
# END MEIZHAOHUI COMMENTS


# Redis reclaims expired keys in two ways: upon access when those keys are
# found to be expired, and also in background, in what is called the
# "active expire key". The key space is slowly and interactively scanned
# looking for expired keys to reclaim, so that it is possible to free memory
# of keys that are expired and will never be accessed again in a short time.
#
# The default effort of the expire cycle will try to avoid having more than
# ten percent of expired keys still in memory, and will try to avoid consuming
# more than 25% of total memory and to add latency to the system. However
# it is possible to increase the expire "effort" that is normally set to
# "1", to a greater value, up to the value "10". At its maximum value the
# system will use more CPU, longer cycles (and technically may introduce
# more latency), and will tolerate less already expired keys still present
# in the system. It's a tradeoff between memory, CPU and latency.
#
# active-expire-effort 1
# BEGIN MEIZHAOHUI COMMENTS
#   active-expire-effort 配置指的是对过期键进行处理的活跃性工作量。
#   这个配置影响了Redis如何平衡CPU时间来处理过期键和其他任务,如持久化和命令处理。
#   值从1-10,值越大,占用CPU资源越多。
# END MEIZHAOHUI COMMENTS

############################# LAZY FREEING ####################################

# Redis has two primitives to delete keys. One is called DEL and is a blocking
# deletion of the object. It means that the server stops processing new commands
# in order to reclaim all the memory associated with an object in a synchronous
# way. If the key deleted is associated with a small object, the time needed
# in order to execute the DEL command is very small and comparable to most other
# O(1) or O(log_N) commands in Redis. However if the key is associated with an
# aggregated value containing millions of elements, the server can block for
# a long time (even seconds) in order to complete the operation.
#
# For the above reasons Redis also offers non blocking deletion primitives
# such as UNLINK (non blocking DEL) and the ASYNC option of FLUSHALL and
# FLUSHDB commands, in order to reclaim memory in background. Those commands
# are executed in constant time. Another thread will incrementally free the
# object in the background as fast as possible.
#
# DEL, UNLINK and ASYNC option of FLUSHALL and FLUSHDB are user-controlled.
# It's up to the design of the application to understand when it is a good
# idea to use one or the other. However the Redis server sometimes has to
# delete keys or flush the whole database as a side effect of other operations.
# Specifically Redis deletes objects independently of a user call in the
# following scenarios:
#
# 1) On eviction, because of the maxmemory and maxmemory policy configurations,
#    in order to make room for new data, without going over the specified
#    memory limit.
# 2) Because of expire: when a key with an associated time to live (see the
#    EXPIRE command) must be deleted from memory.
# 3) Because of a side effect of a command that stores data on a key that may
#    already exist. For example the RENAME command may delete the old key
#    content when it is replaced with another one. Similarly SUNIONSTORE
#    or SORT with STORE option may delete existing keys. The SET command
#    itself removes any old content of the specified key in order to replace
#    it with the specified string.
# 4) During replication, when a replica performs a full resynchronization with
#    its master, the content of the whole database is removed in order to
#    load the RDB file just transferred.
#
# In all the above cases the default is to delete objects in a blocking way,
# like if DEL was called. However you can configure each case specifically
# in order to instead release memory in a non-blocking way like if UNLINK
# was called, using the following configuration directives.

# BEGIN MEIZHAOHUI COMMENTS
#   Redis有两个命令用于删除键。一个称为DEL,是对对象的阻塞删除。
#   这意味着服务器停止处理新命令,以便以同步方式回收与对象关联的所有内存。
#   如果删除的键与一个小对象相关联,则执行DEL命令所需的时间非常短,
#   与Redis中的大多数其他O(1)或O(log_N)命令相当。但是,
#   如果key与包含数百万个元素的聚合值关联,则服务器可以阻塞很长时间(甚至几秒钟)以完成操作。
#
#   出于上述原因,Redis还提供了UNLINK(non-blocking DEL)等非阻塞删除命令
#   以及FLUSHALL和FLUSHDB命令的异步选项,以便在后台回收内存。
#   这些命令在固定时间内执行。另一个线程将尽可能在后台释放对象。
#
#   FLUSHALL和FLUSHDB的DEL、UNLINK和ASYNC选项由用户控制。
#   这取决于应用程序的设计,所以了解何时使用一个或另一个是一个好主意。
#   然而,Redis服务器有时不得不删除keys或刷新整个数据库,这是其他操作的副作用。
#   具体来说,在以下情况下,Redis独立于用户调用删除对象:
#   1.在逐出时,由于maxmemory和maxmemory策略配置,为了在不超过指定内存限制的情况下为新数据腾出空间
#   2.因为过期:必须从内存中删除具有相关生存时间的key
#   3.因为将数据存储在可能已经存在的keys上的命令的副作用。
#       例如,当旧的keys内容被另一个keys内容替换时,RENAME命令可能会删除它。
#       类似地,SUNIONSTORE或SORT with STORE选项可以删除现有keys。
#       SET命令本身删除指定键的任何旧内容,以便用指定字符串替换它。
#   4.在复制过程中,当复制副本与其主服务器执行完全重新同步时,将删除整个数据库的内容,以便加载刚刚传输的RDB文件。
# END MEIZHAOHUI COMMENTS

lazyfree-lazy-eviction no
# BEGIN MEIZHAOHUI COMMENTS
#   当 redis 内存达到阈值 maxmemory 时,是否开启异步惰性淘汰,
#   开启的话,可能使用淘汰键的内存释放不及时,导致redis内存超用,超过maxmemory的限制不建议开启。
# END MEIZHAOHUI COMMENTS
lazyfree-lazy-expire no
# BEGIN MEIZHAOHUI COMMENTS
#   针对设置有TTL的键,达到过期后,被redis清理删除时是否采用lazy free机制。
#   没特殊要求的话,保持默认不开启。
# END MEIZHAOHUI COMMENTS
lazyfree-lazy-server-del no
# BEGIN MEIZHAOHUI COMMENTS
#   执行DEL命令时,是否异步执行删除操作。
#   没特殊要求的话,保持默认不开启。
# END MEIZHAOHUI COMMENTS
replica-lazy-flush no
# BEGIN MEIZHAOHUI COMMENTS
#   主要用于复制过程中,全量同步的场景,从节点是否异步删除整个db。
#   没特殊要求的话,保持默认不开启。
# END MEIZHAOHUI COMMENTS


# It is also possible, for the case when to replace the user code DEL calls
# with UNLINK calls is not easy, to modify the default behavior of the DEL
# command to act exactly like UNLINK, using the following configuration
# directive:
# BEGIN MEIZHAOHUI COMMENTS
#   将代码中的del替换成unlink可能不是那么太容易,所以为了让del
#   命令的实际效果等价于unlink,
#   你可以修改配置文件为lazyfree-lazy-user-del yes
# END MEIZHAOHUI COMMENTS
lazyfree-lazy-user-del no

# FLUSHDB, FLUSHALL, and SCRIPT FLUSH support both asynchronous and synchronous
# deletion, which can be controlled by passing the [SYNC|ASYNC] flags into the
# commands. When neither flag is passed, this directive will be used to determine
# if the data should be deleted asynchronously.

# BEGIN MEIZHAOHUI COMMENTS
#   FLUSHDB、FLUSHALL 和 SCRIPT FLUSH 支持异步和同步
#   删除,可通过将 [SYNC|ASYNC] 标志传递到命令中来控制。
#   当未传递任何标志时,此指令将用于确定是否应异步删除数据。
#   保持默认不启用异步删除。
# END MEIZHAOHUI COMMENTS
lazyfree-lazy-user-flush no

################################ THREADED I/O #################################

# Redis is mostly single threaded, however there are certain threaded
# operations such as UNLINK, slow I/O accesses and other things that are
# performed on side threads.
#
# Now it is also possible to handle Redis clients socket reads and writes
# in different I/O threads. Since especially writing is so slow, normally
# Redis users use pipelining in order to speed up the Redis performances per
# core, and spawn multiple instances in order to scale more. Using I/O
# threads it is possible to easily speedup two times Redis without resorting
# to pipelining nor sharding of the instance.
#
# By default threading is disabled, we suggest enabling it only in machines
# that have at least 4 or more cores, leaving at least one spare core.
# Using more than 8 threads is unlikely to help much. We also recommend using
# threaded I/O only if you actually have performance problems, with Redis
# instances being able to use a quite big percentage of CPU time, otherwise
# there is no point in using this feature.
#
# So for instance if you have a four cores boxes, try to use 2 or 3 I/O
# threads, if you have a 8 cores, try to use 6 threads. In order to
# enable I/O threads use the following configuration directive:
#
# io-threads 4
# BEGIN MEIZHAOHUI COMMENTS
#   官方表示,当使用redis时有性能瓶颈时,才推荐开启该功能,但是消耗更多的cpu时间。
#   并且,开启i/o多线程,至少要是4核以上的cpu,
#   并且需要预留一个空闲cpu。
#   比如4核就配io-threads=2,
#   8核至多配io-threads=6。
#   对于4核以上的机器,官方更推荐配置io-threads=4,
#   因为再往上叠加,收益相对较低了,也没有太大必要。
# END MEIZHAOHUI COMMENTS

#
# Setting io-threads to 1 will just use the main thread as usual.
# When I/O threads are enabled, we only use threads for writes, that is
# to thread the write(2) syscall and transfer the client buffers to the
# socket. However it is also possible to enable threading of reads and
# protocol parsing using the following configuration directive, by setting
# it to yes:
# io-threads-do-reads no
# BEGIN MEIZHAOHUI COMMENTS
#   io-threads-do-reads配置默认no。
#   i/o多线程默认是的是写socket多线程,socket连接本身就是epoll多路复用模式,
#   理解下来开启此配置对性能不太有提升空间。
# END MEIZHAOHUI COMMENTS
#
# Usually threading reads doesn't help much.
#
# NOTE 1: This configuration directive cannot be changed at runtime via
# CONFIG SET. Aso this feature currently does not work when SSL is
# enabled.
#
# NOTE 2: If you want to test the Redis speedup using redis-benchmark, make
# sure you also run the benchmark itself in threaded mode, using the
# --threads option to match the number of Redis threads, otherwise you'll not
# be able to notice the improvements.

############################ KERNEL OOM CONTROL ##############################

# On Linux, it is possible to hint the kernel OOM killer on what processes
# should be killed first when out of memory.
#
# Enabling this feature makes Redis actively control the oom_score_adj value
# for all its processes, depending on their role. The default scores will
# attempt to have background child processes killed before all others, and
# replicas killed before masters.
#
# Redis supports three options:
#
# no:       Don't make changes to oom-score-adj (default).
# yes:      Alias to "relative" see below.
# absolute: Values in oom-score-adj-values are written as is to the kernel.
# relative: Values are used relative to the initial value of oom_score_adj when
#           the server starts and are then clamped to a range of -1000 to 1000.
#           Because typically the initial value is 0, they will often match the
#           absolute values.
oom-score-adj no
# BEGIN MEIZHAOHUI COMMENTS
#   在 Linux 上,可以提示内核 OOM 终止程序在内存不足时应首先终止哪些进程。
#   oom-score-adj 参数用于设置 Redis 进程在内存不足时被系统杀死的可能性。
#   保持默认不开启。
# END MEIZHAOHUI COMMENTS

# When oom-score-adj is used, this directive controls the specific values used
# for master, replica and background child processes. Values range -2000 to
# 2000 (higher means more likely to be killed).
#
# Unprivileged processes (not root, and without CAP_SYS_RESOURCE capabilities)
# can freely increase their value, but not decrease it below its initial
# settings. This means that setting oom-score-adj to "relative" and setting the
# oom-score-adj-values to positive values will always succeed.
oom-score-adj-values 0 200 800
# BEGIN MEIZHAOHUI COMMENTS
#   oom-score-adj 配置未开启,此配置无效。
# END MEIZHAOHUI COMMENTS


#################### KERNEL transparent hugepage CONTROL ######################

# Usually the kernel Transparent Huge Pages control is set to "madvise" or
# or "never" by default (/sys/kernel/mm/transparent_hugepage/enabled), in which
# case this config has no effect. On systems in which it is set to "always",
# redis will attempt to disable it specifically for the redis process in order
# to avoid latency problems specifically with fork(2) and CoW.
# If for some reason you prefer to keep it enabled, you can set this config to
# "no" and the kernel global to "always".

disable-thp yes
# BEGIN MEIZHAOHUI COMMENTS
#   disable-thp 配置项是用来控制是否禁用Transparent Huge Pages (THP)特性的。
#   THP透明大页是Linux系统中用于支持大页面的一个特性,它可以提高内存的使用效率,
#   但也可能对一些需要低延迟的应用程序造成影响,因为它会破坏内存的局部性。
#       cat /sys/kernel/mm/transparent_hugepage/enabled
#       [always] madvise never   <------- 这种是透明大页开启状态
#       cat /sys/kernel/mm/transparent_hugepage/enabled
#       always madvise [never]   <------- 这种是透明大页关闭状态
# END MEIZHAOHUI COMMENTS

############################## APPEND ONLY MODE ###############################

# By default Redis asynchronously dumps the dataset on disk. This mode is
# good enough in many applications, but an issue with the Redis process or
# a power outage may result into a few minutes of writes lost (depending on
# the configured save points).
#
# The Append Only File is an alternative persistence mode that provides
# much better durability. For instance using the default data fsync policy
# (see later in the config file) Redis can lose just one second of writes in a
# dramatic event like a server power outage, or a single write if something
# wrong with the Redis process itself happens, but the operating system is
# still running correctly.
#
# AOF and RDB persistence can be enabled at the same time without problems.
# If the AOF is enabled on startup Redis will load the AOF, that is the file
# with the better durability guarantees.
#
# Please check https://redis.io/topics/persistence for more information.
# BEGIN MEIZHAOHUI COMMENTS
#   默认情况下,Redis 会异步将数据集转储到磁盘上。
#   此模式在许多应用程序中都足够好,但 Redis 进程出现问题或断电可能会导致几分钟的写入丢失(取决于配置的保存点)。
#
#   这种只增文件是可选的能够提供更好的体验的数据持久化策略。
#   Redis 可能会在服务器断电等重大事件中丢失一秒钟的写入,
#   或者如果 Redis 进程本身出现问题,但操作系统仍在正常运行,则只会丢失一次写入。
#   可以同时启用 AOF 和 RDB 持久性而不会出现问题。
#   如果在启动时启用了 AOF,Redis 将加载 AOF,即具有更好耐用性保证的文件。
# END MEIZHAOHUI COMMENTS

# appendonly no
appendonly yes
# BEGIN MEIZHAOHUI COMMENTS
#   默认 appendonly no 表示未开启AOF只增文件模式。
#   为了让我们Redis在异常时数据丢失更少,开启该参数,
#   设置appendonly yes 打开 AOF持久化。
# END MEIZHAOHUI COMMENTS

# The name of the append only file (default: "appendonly.aof")

appendfilename "appendonly.aof"
# BEGIN MEIZHAOHUI COMMENTS
#   AOF持久化文件名
# END MEIZHAOHUI COMMENTS

# The fsync() call tells the Operating System to actually write data on disk
# instead of waiting for more data in the output buffer. Some OS will really flush
# data on disk, some other OS will just try to do it ASAP.
#
# Redis supports three different modes:
#
# no: don't fsync, just let the OS flush the data when it wants. Faster.
# always: fsync after every write to the append only log. Slow, Safest.
# everysec: fsync only one time every second. Compromise.
#
# The default is "everysec", as that's usually the right compromise between
# speed and data safety. It's up to you to understand if you can relax this to
# "no" that will let the operating system flush the output buffer when
# it wants, for better performances (but if you can live with the idea of
# some data loss consider the default persistence mode that's snapshotting),
# or on the contrary, use "always" that's very slow but a bit safer than
# everysec.
#
# More details please check the following article:
# http://antirez.com/post/redis-persistence-demystified.html
#
# If unsure, use "everysec".

# BEGIN MEIZHAOHUI COMMENTS
#   fsync() 调用会告知操作系统实际将数据写入磁盘,
#   而不是等待输出缓冲区中出现更多数据。有些操作系统会真正刷新磁盘上的数据,
#   而有些操作系统则会尝试尽快执行此操作。
#   Redis 支持三种不同的模式:
#
#   no:不进行 fsync,只让操作系统在需要时刷新数据。速度更快。
#   always:每次写入仅附加日志后进行 fsync。速度慢,最安全。
#   everysec:每秒仅进行一次 fsync。折衷。
#   默认值为“everysec”,因为这通常是速度和数据安全性之间的正确折衷。
#
#   我们使用默认值 appendfsync everysec 每秒写入一次。
# END MEIZHAOHUI COMMENTS

# appendfsync always
appendfsync everysec
# appendfsync no

# When the AOF fsync policy is set to always or everysec, and a background
# saving process (a background save or AOF log background rewriting) is
# performing a lot of I/O against the disk, in some Linux configurations
# Redis may block too long on the fsync() call. Note that there is no fix for
# this currently, as even performing fsync in a different thread will block
# our synchronous write(2) call.
#
# In order to mitigate this problem it's possible to use the following option
# that will prevent fsync() from being called in the main process while a
# BGSAVE or BGREWRITEAOF is in progress.
#
# This means that while another child is saving, the durability of Redis is
# the same as "appendfsync none". In practical terms, this means that it is
# possible to lose up to 30 seconds of log in the worst scenario (with the
# default Linux settings).
#
# If you have latency problems turn this to "yes". Otherwise leave it as
# "no" that is the safest pick from the point of view of durability.

# BEGIN MEIZHAOHUI COMMENTS
#   bgrewriteaof机制,在一个子进程中进行aof的重写,
#   从而不阻塞主进程对其余命令的处理,同时解决了aof文件过大问题。
#   现在问题出现了,同时在执行bgrewriteaof操作和主进程写aof文件的操作,
#   两者都会操作磁盘,而bgrewriteaof往往会涉及大量磁盘操作,
#   这样就会造成主进程在写aof文件的时候出现阻塞的情形,
#   现在no-appendfsync-on-rewrite参数出场了。
#   如果该参数设置为no,是最安全的方式,不会丢失数据,但是要忍受阻塞的问题。
#   如果设置为yes呢?这就相当于将appendfsync设置为no,这说明并没有执行磁盘操作,
#   只是写入了缓冲区,因此这样并不会造成阻塞(因为没有竞争磁盘),
#   但是如果这个时候redis挂掉,就会丢失数据。丢失多少数据呢?
#   在linux的操作系统的默认设置下,最多会丢失30s的数据。
#   因此,如果应用系统无法忍受延迟,而可以容忍少量的数据丢失,则设置为yes。
#   如果应用系统无法忍受数据丢失,则设置为no。
# END MEIZHAOHUI COMMENTS
no-appendfsync-on-rewrite no

# Automatic rewrite of the append only file.
# Redis is able to automatically rewrite the log file implicitly calling
# BGREWRITEAOF when the AOF log size grows by the specified percentage.
#
# This is how it works: Redis remembers the size of the AOF file after the
# latest rewrite (if no rewrite has happened since the restart, the size of
# the AOF at startup is used).
#
# This base size is compared to the current size. If the current size is
# bigger than the specified percentage, the rewrite is triggered. Also
# you need to specify a minimal size for the AOF file to be rewritten, this
# is useful to avoid rewriting the AOF file even if the percentage increase
# is reached but it is still pretty small.
#
# Specify a percentage of zero in order to disable the automatic AOF
# rewrite feature.

# BEGIN MEIZHAOHUI COMMENTS
#   auto-aof-rewrite-percentage,设置触发 AOF 重写的百分比,一般建议设置为 100% 。
#   当 AOF 文件体积增长超过上次 AOF 重写的体积的指定百分比时,
#   Redis 会自动触发一个新的 AOF 重写操作。
#   auto-aof-rewrite-min-size 设置最小 AOF 文件大小,一般建议设置为 64mb。
# END MEIZHAOHUI COMMENTS
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb


# An AOF file may be found to be truncated at the end during the Redis
# startup process, when the AOF data gets loaded back into memory.
# This may happen when the system where Redis is running
# crashes, especially when an ext4 filesystem is mounted without the
# data=ordered option (however this can't happen when Redis itself
# crashes or aborts but the operating system still works correctly).
#
# Redis can either exit with an error when this happens, or load as much
# data as possible (the default now) and start if the AOF file is found
# to be truncated at the end. The following option controls this behavior.
#
# If aof-load-truncated is set to yes, a truncated AOF file is loaded and
# the Redis server starts emitting a log to inform the user of the event.
# Otherwise if the option is set to no, the server aborts with an error
# and refuses to start. When the option is set to no, the user requires
# to fix the AOF file using the "redis-check-aof" utility before to restart
# the server.
#
# Note that if the AOF file will be found to be corrupted in the middle
# the server will still exit with an error. This option only applies when
# Redis will try to read more data from the AOF file but not enough bytes
# will be found.
# BEGIN MEIZHAOHUI COMMENTS
#   aof文件可能在尾部是不完整的,当redis启动的时候,aof文件的数据被载入内存。
#   重启可能发生在redis所在的主机操作系统宕机后,尤其在ext4文件系统没有加上data=ordered选项会出现这种现象。
#   redis宕机或者异常终止不会造成尾部不完整现象,可以选择让redis退出,
#   或者导入尽可能多的数据。如果选择的是yes,当截断的aof文件被导入的时候,
#   会自动发布一个log给客户端然后load。
#   如果是no,用户必须手动redis-check-aof修复AOF文件才可以。
# END MEIZHAOHUI COMMENTS
aof-load-truncated yes

# When rewriting the AOF file, Redis is able to use an RDB preamble in the
# AOF file for faster rewrites and recoveries. When this option is turned
# on the rewritten AOF file is composed of two different stanzas:
#
#   [RDB file][AOF tail]
#
# When loading, Redis recognizes that the AOF file starts with the "REDIS"
# string and loads the prefixed RDB file, then continues loading the AOF
# tail.
# BEGIN MEIZHAOHUI COMMENTS
#   在Redis4.0之后,新增了RDB-AOF混合持久化方式。这种方式结合了RDB和AOF的优点,既能快速加载又能避免丢失过多的数据。
#   具体配置为:aof-use-rdb-preamble: 设置为yes表示开启,设置为no表示禁用。
#   当开启混合持久化时,主进程先fork出子进程将现有内存副本全量以RDB方式写入aof文件中,
#   然后将缓冲区中的增量命令以AOF方式写入aof文件中,
#   写入完成后通知主进程更新相关信息,并将新的含有 RDB和AOF两种格式的aof文件替换旧的aof文件。
#   简单来说:混合持久化方式产生的文件一部分是RDB格式,一部分是AOF格式。
# END MEIZHAOHUI COMMENTS
aof-use-rdb-preamble yes

################################ LUA SCRIPTING  ###############################

# Max execution time of a Lua script in milliseconds.
#
# If the maximum execution time is reached Redis will log that a script is
# still in execution after the maximum allowed time and will start to
# reply to queries with an error.
#
# When a long running script exceeds the maximum execution time only the
# SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be
# used to stop a script that did not yet call any write commands. The second
# is the only way to shut down the server in the case a write command was
# already issued by the script but the user doesn't want to wait for the natural
# termination of the script.
#
# Set it to 0 or a negative value for unlimited execution without warnings.
# BEGIN MEIZHAOHUI COMMENTS
#   Lua脚本的使用和设置超时时间,默认5000毫秒,即5秒。
#   但这里有个坑,当一个脚本达到最大执行时长的时候,Redis并不会强制停止脚本的运行,
#   仅仅在日志里打印个警告,告知有脚本超时。
#   开始允许接受其他客户端请求,但仅限于 SCRIPT KILL 和 SHUTDOWN NOSAVE 两个命令
#   其他请求仍返回busy错误,
#   如果脚本已经改写了数据内容,SCRIPT KILL将报出以下错误,因为它破坏数据集的内容。
#   为什么不能直接停掉呢?
#   因为 Redis 必须保证脚本执行的原子性,中途停止可能导致内存的数据集上只修改了部分数据。
#
#   Redis脚本里的写命令是等到执行完成后再一次性写入AOF的。
#   参考:https://www.jb51.net/article/230175.htm Redis中Lua脚本的使用和设置超时
# END MEIZHAOHUI COMMENTS
lua-time-limit 5000

################################ REDIS CLUSTER  ###############################

# Normal Redis instances can't be part of a Redis Cluster; only nodes that are
# started as cluster nodes can. In order to start a Redis instance as a
# cluster node enable the cluster support uncommenting the following:
# BEGIN MEIZHAOHUI COMMENTS
#   普通 Redis 实例不能成为 Redis 集群的一部分;只有作为集群节点启动的节点才可以。
#   为了将 Redis 实例作为集群节点启动,请取消注释以下内容以启用集群支持:
# END MEIZHAOHUI COMMENTS
#
# cluster-enabled yes

# Every cluster node has a cluster configuration file. This file is not
# intended to be edited by hand. It is created and updated by Redis nodes.
# Every Redis Cluster node requires a different cluster configuration file.
# Make sure that instances running in the same system do not have
# overlapping cluster configuration file names.
# BEGIN MEIZHAOHUI COMMENTS
#   每个集群节点都有一个集群配置文件。此文件不应手动编辑。它由 Redis 节点创建和更新。
#   每个 Redis 集群节点都需要不同的集群配置文件。
#   确保在同一系统中运行的实例没有重复的集群配置文件名。
# END MEIZHAOHUI COMMENTS
#
# cluster-config-file nodes-6379.conf

# Cluster node timeout is the amount of milliseconds a node must be unreachable
# for it to be considered in failure state.
# Most other internal time limits are a multiple of the node timeout.
# BEGIN MEIZHAOHUI COMMENTS
#   集群节点超时是节点必须处于不可访问状态的毫秒数。
#   才会被视为处于故障状态。
#   大多数其他内部时间限制都是节点超时的倍数。
# END MEIZHAOHUI COMMENTS
#
# cluster-node-timeout 15000

# A replica of a failing master will avoid to start a failover if its data
# looks too old.
#
# There is no simple way for a replica to actually have an exact measure of
# its "data age", so the following two checks are performed:
#
# 1) If there are multiple replicas able to failover, they exchange messages
#    in order to try to give an advantage to the replica with the best
#    replication offset (more data from the master processed).
#    Replicas will try to get their rank by offset, and apply to the start
#    of the failover a delay proportional to their rank.
#
# 2) Every single replica computes the time of the last interaction with
#    its master. This can be the last ping or command received (if the master
#    is still in the "connected" state), or the time that elapsed since the
#    disconnection with the master (if the replication link is currently down).
#    If the last interaction is too old, the replica will not try to failover
#    at all.
#
# The point "2" can be tuned by user. Specifically a replica will not perform
# the failover if, since the last interaction with the master, the time
# elapsed is greater than:
#
#   (node-timeout * cluster-replica-validity-factor) + repl-ping-replica-period
#
# So for example if node-timeout is 30 seconds, and the cluster-replica-validity-factor
# is 10, and assuming a default repl-ping-replica-period of 10 seconds, the
# replica will not try to failover if it was not able to talk with the master
# for longer than 310 seconds.
# BEGIN MEIZHAOHUI COMMENTS
#   如果数据看起来太旧,故障主服务器的副本将避免启动故障转移。
#   对于副本来说,没有简单的方法可以准确测量其“数据年龄”,因此需要执行以下两项检查:
#  
#   1) 如果有多个副本能够进行故障转移,它们将交换消息,以尝试为具有最佳复制偏移量的副本(处理来自主服务器的更多数据)提供优势(可以理解为优先级)。
#   副本将尝试通过偏移量获取其排名,并在故障转移开始时应用与其排名成比例的延迟。
#   2) 每个副本计算与其主服务器最后一次交互的时间。这可以是最后一次收到的 ping 或命令(如果主服务器仍处于“连接”状态),
#   也可以是自与主服务器断开连接以来经过的时间(如果复制链接当前已关闭)。
#   如果最后一次交互太旧,副本将根本不会尝试故障转移。
#  
#   点“2”可以由用户调整。具体来说,如果自上次与主服务器交互以来,经过的时间大于:
#   (node-timeout * cluster-replica-validity-factor) + repl-ping-replica-period
#  
#   例如,如果 node-timeout 为 30 秒,cluster-replica-validity-factor为 10,
#   并假设默认 repl-ping-replica-period 为 10 秒,
#   则如果副本无法与主服务器通信超过 310 秒,则副本将不会尝试故障转移。
# END MEIZHAOHUI COMMENTS

#
# A large cluster-replica-validity-factor may allow replicas with too old data to failover
# a master, while a too small value may prevent the cluster from being able to
# elect a replica at all.
#
# For maximum availability, it is possible to set the cluster-replica-validity-factor
# to a value of 0, which means, that replicas will always try to failover the
# master regardless of the last time they interacted with the master.
# (However they'll always try to apply a delay proportional to their
# offset rank).
#
# Zero is the only value able to guarantee that when all the partitions heal
# the cluster will always be able to continue.
# BEGIN MEIZHAOHUI COMMENTS
#   较大的 cluster-replica-validity-factor 可能允许数据过旧的副本故障转移为主服务器,
#   而太小的值可能会阻止集群能够# 选举副本。
#   如果设置为 0 ,则不管 slave 与 master 之间断开多久,都认为自己有资格成为 master。
# END MEIZHAOHUI COMMENTS
#
# cluster-replica-validity-factor 10

# Cluster replicas are able to migrate to orphaned masters, that are masters
# that are left without working replicas. This improves the cluster ability
# to resist to failures as otherwise an orphaned master can't be failed over
# in case of failure if it has no working replicas.
#
# Replicas migrate to orphaned masters only if there are still at least a
# given number of other working replicas for their old master. This number
# is the "migration barrier". A migration barrier of 1 means that a replica
# will migrate only if there is at least 1 other working replica for its master
# and so forth. It usually reflects the number of replicas you want for every
# master in your cluster.
#
# Default is 1 (replicas migrate only if their masters remain with at least
# one replica). To disable migration just set it to a very large value or
# set cluster-allow-replica-migration to 'no'.
# A value of 0 can be set but is useful only for debugging and dangerous
# in production.
# BEGIN MEIZHAOHUI COMMENTS
#   没有 slave 节点的 master 节点称为孤儿 master节点,这个配置就是用于防止出现裸奔的 master。
#   当某个 master 的 slave 节点宕机后,集群会从其他 master 中选出一个富余的 slave 节点迁移过来,
#   确保每个 master 节点至少有一个 slave 节点,
#   防止当孤立 master 节点宕机时,没有slave节点可以升为 master 导致集群不可用。
#   默认配置为 cluster-migration-barrier 1,是一个迁移临界值。
#   含义是:迁移后 master 节点至少还有 1 个 slave 节点才能做迁移操作。
#   比如 master A 节点有2个以上 slave 节点 ,当集群出现孤儿 master B 节点时,
#   A 节点富余的 slave 节点可以迁移到 master B 节点上。
#   生产环境建议维持默认值,最大可能保证高可用。
# END MEIZHAOHUI COMMENTS
#
# cluster-migration-barrier 1

# Turning off this option allows to use less automatic cluster configuration.
# It both disables migration to orphaned masters and migration from masters
# that became empty.
#
# Default is 'yes' (allow automatic migrations).
#
# BEGIN MEIZHAOHUI COMMENTS
#   允许自动迁移。
# END MEIZHAOHUI COMMENTS
# cluster-allow-replica-migration yes

# By default Redis Cluster nodes stop accepting queries if they detect there
# is at least a hash slot uncovered (no available node is serving it).
# This way if the cluster is partially down (for example a range of hash slots
# are no longer covered) all the cluster becomes, eventually, unavailable.
# It automatically returns available as soon as all the slots are covered again.
#
# However sometimes you want the subset of the cluster which is working,
# to continue to accept queries for the part of the key space that is still
# covered. In order to do so, just set the cluster-require-full-coverage
# option to no.
#
# BEGIN MEIZHAOHUI COMMENTS
#   当 redis cluster 发现至少还有一个 哈希槽没有被分配时禁止查询操作。
#   这就会导致集群部分宕机,整个集群就不可用了,
#   当所有哈希槽都有分配,集群会自动变为可用状态。
#   默认值 yes , 即需要集群完整性,方可对外提供服务。
# END MEIZHAOHUI COMMENTS
# cluster-require-full-coverage yes

# This option, when set to yes, prevents replicas from trying to failover its
# master during master failures. However the replica can still perform a
# manual failover, if forced to do so.
#
# This is useful in different scenarios, especially in the case of multiple
# data center operations, where we want one side to never be promoted if not
# in the case of a total DC failure.
#
# BEGIN MEIZHAOHUI COMMENTS
#   默认配置为 no,当配置成 yes,在master 宕机时,slave 不会做故障转移升为 master。
#   这个配置在多数据中心的情况下会很有用,你可能希望某个数据中心永远不要升级为 master 节点,
#   否则 master 节点就漂移到其他数据中心了。
# END MEIZHAOHUI COMMENTS
# cluster-replica-no-failover no

# This option, when set to yes, allows nodes to serve read traffic while the
# the cluster is in a down state, as long as it believes it owns the slots. 
#
# This is useful for two cases.  The first case is for when an application 
# doesn't require consistency of data during node failures or network partitions.
# One example of this is a cache, where as long as the node has the data it
# should be able to serve it. 
#
# The second use case is for configurations that don't meet the recommended  
# three shards but want to enable cluster mode and scale later. A 
# master outage in a 1 or 2 shard configuration causes a read/write outage to the
# entire cluster without this option set, with it set there is only a write outage.
# Without a quorum of masters, slot ownership will not change automatically. 
#
# BEGIN MEIZHAOHUI COMMENTS
#   cluster-allow-reads-when-down配置选项用于控制在节点
#   标记为FAIL(即节点认为它自己已经下线,不能正确处理命令请求)时,
#   集群是否允许对该节点进行读操作。
#
#   当cluster-allow-reads-when-down配置项设置为yes时,
#   即使一个节点因为网络分区问题被集群标记为FAIL,
#   集群的其他节点仍然可以从这个节点进行读操作。
#   这可以提供一定程度的数据可读性,
#   但是需要注意,由于数据可能不同步,因此可能会返回过时的数据。
#
#   当cluster-allow-reads-when-down配置项设置为no时,
#   一旦一个节点被集群标记为FAIL,它将不再从这个节点进行读操作。
# END MEIZHAOHUI COMMENTS
# cluster-allow-reads-when-down no

# In order to setup your cluster make sure to read the documentation
# available at https://redis.io web site.

########################## CLUSTER DOCKER/NAT support  ########################

# In certain deployments, Redis Cluster nodes address discovery fails, because
# addresses are NAT-ted or because ports are forwarded (the typical case is
# Docker and other containers).
# BEGIN MEIZHAOHUI COMMENTS
#   在某些部署中,Redis 集群节点地址发现失败,因为
#   地址经过了 NAT 处理或者端口被转发(典型情况是
#   Docker 和其他容器)。
#
#   我们此处不用docker部署redis,忽略下面这四个配置项。
# END MEIZHAOHUI COMMENTS
#
# In order to make Redis Cluster working in such environments, a static
# configuration where each node knows its public address is needed. The
# following four options are used for this scope, and are:
#
# * cluster-announce-ip
# * cluster-announce-port
# * cluster-announce-tls-port
# * cluster-announce-bus-port
#
# Each instructs the node about its address, client ports (for connections
# without and with TLS) and cluster message bus port. The information is then
# published in the header of the bus packets so that other nodes will be able to
# correctly map the address of the node publishing the information.
#
# If cluster-tls is set to yes and cluster-announce-tls-port is omitted or set
# to zero, then cluster-announce-port refers to the TLS port. Note also that
# cluster-announce-tls-port has no effect if cluster-tls is set to no.
#
# If the above options are not used, the normal Redis Cluster auto-detection
# will be used instead.
#
# Note that when remapped, the bus port may not be at the fixed offset of
# clients port + 10000, so you can specify any port and bus-port depending
# on how they get remapped. If the bus-port is not set, a fixed offset of
# 10000 will be used as usual.
#
# Example:
#
# cluster-announce-ip 10.1.1.5
# cluster-announce-tls-port 6379
# cluster-announce-port 0
# cluster-announce-bus-port 6380

################################## SLOW LOG ###################################

# The Redis Slow Log is a system to log queries that exceeded a specified
# execution time. The execution time does not include the I/O operations
# like talking with the client, sending the reply and so forth,
# but just the time needed to actually execute the command (this is the only
# stage of command execution where the thread is blocked and can not serve
# other requests in the meantime).
#
# You can configure the slow log with two parameters: one tells Redis
# what is the execution time, in microseconds, to exceed in order for the
# command to get logged, and the other parameter is the length of the
# slow log. When a new command is logged the oldest one is removed from the
# queue of logged commands.

# The following time is expressed in microseconds, so 1000000 is equivalent
# to one second. Note that a negative number disables the slow log, while
# a value of zero forces the logging of every command.
# BEGIN MEIZHAOHUI COMMENTS
#   执行时间超过该值的命令会被记录在慢查询日志中。
#   该值的单位是微秒,当执行时间超过这个值的命令会被记录,
#   值为0表示记录所有命令,值为负数表示不记录任何命令。
#   微秒(1秒 = 1000毫秒 = 1000000微秒)
# END MEIZHAOHUI COMMENTS
slowlog-log-slower-than 10000

# There is no limit to this length. Just be aware that it will consume memory.
# You can reclaim memory used by the slow log with SLOWLOG RESET.
# BEGIN MEIZHAOHUI COMMENTS
#   slowlog-max-len的作用是指定慢查询日志最多存储的条数。
#   实际上,Redis使用了一个列表存放慢查询日志,
#   slowlog-max-len就是这个列表的最大长度。
#   当一个新的命令满足满足慢查询条件时,被插入这个列表中。
#   当慢查询日志列表已经达到最大长度时,最早插入的那条命令将被从列表中移出。
#   比如,slowlog-max-len被设置为10,当有第11条命令插入时,
#   在列表中的第1条命令先被移出,然后再把第11条命令放入列表。
# END MEIZHAOHUI COMMENTS
slowlog-max-len 128

################################ LATENCY MONITOR ##############################

# The Redis latency monitoring subsystem samples different operations
# at runtime in order to collect data related to possible sources of
# latency of a Redis instance.
#
# Via the LATENCY command this information is available to the user that can
# print graphs and obtain reports.
#
# The system only logs operations that were performed in a time equal or
# greater than the amount of milliseconds specified via the
# latency-monitor-threshold configuration directive. When its value is set
# to zero, the latency monitor is turned off.
#
# By default latency monitoring is disabled since it is mostly not needed
# if you don't have latency issues, and collecting data has a performance
# impact, that while very small, can be measured under big load. Latency
# monitoring can easily be enabled at runtime using the command
# "CONFIG SET latency-monitor-threshold <milliseconds>" if needed.
# BEGIN MEIZHAOHUI COMMENTS
#   延迟监视器
#   Redis 延迟监视子系统在运行时对不同的操作进行采样,
#   以便收集与 Redis 实例的可能延迟源相关的数据。
#   这个参数的默认值是0,意味着禁用延迟监控。
#   用于指定处理命令请求的最大延迟时间(单位微秒)。
#   如果某个命令的处理延迟超过这个值,Redis 会在日志中记录一条警告信息。
#   如果你想启用并设置一个特定的阈值,请确保将其值设置为合理的高低值,
#   以避免在正常的操作中记录警告。
# END MEIZHAOHUI COMMENTS
latency-monitor-threshold 0

############################# EVENT NOTIFICATION ##############################

# Redis can notify Pub/Sub clients about events happening in the key space.
# This feature is documented at https://redis.io/topics/notifications
#
# For instance if keyspace events notification is enabled, and a client
# performs a DEL operation on key "foo" stored in the Database 0, two
# messages will be published via Pub/Sub:
#
# PUBLISH __keyspace@0__:foo del
# PUBLISH __keyevent@0__:del foo
#
# It is possible to select the events that Redis will notify among a set
# of classes. Every class is identified by a single character:
#
#  K     Keyspace events, published with __keyspace@<db>__ prefix.
#  E     Keyevent events, published with __keyevent@<db>__ prefix.
#  g     Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ...
#  $     String commands
#  l     List commands
#  s     Set commands
#  h     Hash commands
#  z     Sorted set commands
#  x     Expired events (events generated every time a key expires)
#  e     Evicted events (events generated when a key is evicted for maxmemory)
#  t     Stream commands
#  d     Module key type events
#  m     Key-miss events (Note: It is not included in the 'A' class)
#  A     Alias for g$lshzxetd, so that the "AKE" string means all the events
#        (Except key-miss events which are excluded from 'A' due to their
#         unique nature).
#
#  The "notify-keyspace-events" takes as argument a string that is composed
#  of zero or multiple characters. The empty string means that notifications
#  are disabled.
#
#  Example: to enable list and generic events, from the point of view of the
#           event name, use:
#
#  notify-keyspace-events Elg
#
#  Example 2: to get the stream of the expired keys subscribing to channel
#             name __keyevent@0__:expired use:
#
#  notify-keyspace-events Ex
#
#  By default all notifications are disabled because most users don't need
#  this feature and the feature has some overhead. Note that if you don't
#  specify at least one of K or E, no events will be delivered.
# BEGIN MEIZHAOHUI COMMENTS
#   事件通知。
#   默认情况下,所有通知均被禁用,
#   因为大多数用户不需要此功能,并且此功能有一些开销。
# END MEIZHAOHUI COMMENTS
notify-keyspace-events ""

############################### GOPHER SERVER #################################

# Redis contains an implementation of the Gopher protocol, as specified in
# the RFC 1436 (https://www.ietf.org/rfc/rfc1436.txt).
#
# The Gopher protocol was very popular in the late '90s. It is an alternative
# to the web, and the implementation both server and client side is so simple
# that the Redis server has just 100 lines of code in order to implement this
# support.
#
# What do you do with Gopher nowadays? Well Gopher never *really* died, and
# lately there is a movement in order for the Gopher more hierarchical content
# composed of just plain text documents to be resurrected. Some want a simpler
# internet, others believe that the mainstream internet became too much
# controlled, and it's cool to create an alternative space for people that
# want a bit of fresh air.
#
# Anyway for the 10nth birthday of the Redis, we gave it the Gopher protocol
# as a gift.
#
# --- HOW IT WORKS? ---
#
# The Redis Gopher support uses the inline protocol of Redis, and specifically
# two kind of inline requests that were anyway illegal: an empty request
# or any request that starts with "/" (there are no Redis commands starting
# with such a slash). Normal RESP2/RESP3 requests are completely out of the
# path of the Gopher protocol implementation and are served as usual as well.
#
# If you open a connection to Redis when Gopher is enabled and send it
# a string like "/foo", if there is a key named "/foo" it is served via the
# Gopher protocol.
#
# In order to create a real Gopher "hole" (the name of a Gopher site in Gopher
# talking), you likely need a script like the following:
#
#   https://github.com/antirez/gopher2redis
#
# --- SECURITY WARNING ---
#
# If you plan to put Redis on the internet in a publicly accessible address
# to server Gopher pages MAKE SURE TO SET A PASSWORD to the instance.
# Once a password is set:
#
#   1. The Gopher server (when enabled, not by default) will still serve
#      content via Gopher.
#   2. However other commands cannot be called before the client will
#      authenticate.
#
# So use the 'requirepass' option to protect your instance.
#
# Note that Gopher is not currently supported when 'io-threads-do-reads'
# is enabled.
#
# To enable Gopher support, uncomment the following line and set the option
# from no (the default) to yes.
#
# BEGIN MEIZHAOHUI COMMENTS
#   是否启用gopher协议的web访问。
#   Gopher 协议在 90 年代末非常流行。
#   它是 Web 的替代品,服务器端和客户端的实现都非常简单,
#   以至于 Redis 服务器只需 100 行代码即可实现此支持。
#   保持默认不开启。
# END MEIZHAOHUI COMMENTS
# gopher-enabled no

############################### ADVANCED CONFIG ###############################

# Hashes are encoded using a memory efficient data structure when they have a
# small number of entries, and the biggest entry does not exceed a given
# threshold. These thresholds can be configured using the following directives.
# BEGIN MEIZHAOHUI COMMENTS
#   高级设置。
#   当哈希值包含少量条目且最大条目不超过给定阈值时,
#   哈希值将使用内存高效的数据结构进行编码。
#   可以使用以下指令配置这些阈值。
#   hash-max-ziplist-entries,使用压缩列表保存时哈希集合中最大元素个数。
#   hash-max-ziplist-value, 使用压缩列表保存时哈希集合中单个元素的最大长度。
#   键值对个数小于512,所有的键值对的键和值的字符串长度都小于64个字节时用ziplist,否则用hashtable。
#   注意:ziplist可以升级为hashtable,但hashtable不能降级为ziplist,
#   在节省内存空间方面哈希表是没有压缩列表高效的!
# END MEIZHAOHUI COMMENTS
hash-max-ziplist-entries 512
hash-max-ziplist-value 64

# Lists are also encoded in a special way to save a lot of space.
# The number of entries allowed per internal list node can be specified
# as a fixed maximum size or a maximum number of elements.
# For a fixed maximum size, use -5 through -1, meaning:
# -5: max size: 64 Kb  <-- not recommended for normal workloads
# -4: max size: 32 Kb  <-- not recommended
# -3: max size: 16 Kb  <-- probably not recommended
# -2: max size: 8 Kb   <-- good
# -1: max size: 4 Kb   <-- good
# Positive numbers mean store up to _exactly_ that number of elements
# per list node.
# The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size),
# but if your use case is unique, adjust the settings as necessary.
# BEGIN MEIZHAOHUI COMMENTS
#   列表也以特殊方式编码以节省大量空间。
#   可以将每个内部列表节点允许的条目数指定为
#   固定最大大小或最大元素数。
#   对于固定最大大小,请使用 -5 到 -1,这意味着:
#   -5:最大大小:64 Kb <-- 不推荐用于正常工作负载
#   -4:最大大小:32 Kb <-- 不推荐
#   -3:最大大小:16 Kb <-- 可能不推荐
#   -2:最大大小:8 Kb <-- 好
#   -1:最大大小:4 Kb <-- 好
#   正数表示每个列表节点最多存储该数量的元素。
#   性能最高的选项通常是 -2(8 Kb 大小)或 -1(4 Kb 大小)。
#   保持默认即可。
# END MEIZHAOHUI COMMENTS
list-max-ziplist-size -2

# Lists may also be compressed.
# Compress depth is the number of quicklist ziplist nodes from *each* side of
# the list to *exclude* from compression.  The head and tail of the list
# are always uncompressed for fast push/pop operations.  Settings are:
# 0: disable all list compression
# 1: depth 1 means "don't start compressing until after 1 node into the list,
#    going from either the head or tail"
#    So: [head]->node->node->...->node->[tail]
#    [head], [tail] will always be uncompressed; inner nodes will compress.
# 2: [head]->[next]->node->node->...->node->[prev]->[tail]
#    2 here means: don't compress head or head->next or tail->prev or tail,
#    but compress all nodes between them.
# 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail]
# etc.
# BEGIN MEIZHAOHUI COMMENTS
#   列表也可以进行压缩。默认为0,禁用列表压缩。
#   保持默认即可。
# END MEIZHAOHUI COMMENTS
list-compress-depth 0

# Sets have a special encoding in just one case: when a set is composed
# of just strings that happen to be integers in radix 10 in the range
# of 64 bit signed integers.
# The following configuration setting sets the limit in the size of the
# set in order to use this special memory saving encoding.
# BEGIN MEIZHAOHUI COMMENTS
#   集合仅在一种情况下具有特殊编码:
#   当集合仅由恰好是基数为 10 的整数且范围为 64 位有符号整数的字符串组成时。
# END MEIZHAOHUI COMMENTS
set-max-intset-entries 512

# Similarly to hashes and lists, sorted sets are also specially encoded in
# order to save a lot of space. This encoding is only used when the length and
# elements of a sorted set are below the following limits:
# BEGIN MEIZHAOHUI COMMENTS
#   与哈希和列表类似,有序集合也经过特殊编码,以节省大量空间。
#   只有当有序集合的长度和元素低于以下限制时才使用此编码:
# END MEIZHAOHUI COMMENTS
zset-max-ziplist-entries 128
zset-max-ziplist-value 64

# HyperLogLog sparse representation bytes limit. The limit includes the
# 16 bytes header. When an HyperLogLog using the sparse representation crosses
# this limit, it is converted into the dense representation.
#
# A value greater than 16000 is totally useless, since at that point the
# dense representation is more memory efficient.
#
# The suggested value is ~ 3000 in order to have the benefits of
# the space efficient encoding without slowing down too much PFADD,
# which is O(N) with the sparse encoding. The value can be raised to
# ~ 10000 when CPU is not a concern, but space is, and the data set is
# composed of many HyperLogLogs with cardinality in the 0 - 15000 range.
# BEGIN MEIZHAOHUI COMMENTS
#   hll-sparse-max-bytes用来控制稀疏HyperLogLog结构的最大保存字节数。
#   HyperLogLog是一种用于进行基数估计的数据结构,
#   通过牺牲一定的精确度来减小占用的内存空间。
# END MEIZHAOHUI COMMENTS
hll-sparse-max-bytes 3000

# Streams macro node max size / items. The stream data structure is a radix
# tree of big nodes that encode multiple items inside. Using this configuration
# it is possible to configure how big a single node can be in bytes, and the
# maximum number of items it may contain before switching to a new node when
# appending new stream entries. If any of the following settings are set to
# zero, the limit is ignored, so for instance it is possible to set just a
# max entries limit by setting max-bytes to 0 and max-entries to the desired
# value.
# BEGIN MEIZHAOHUI COMMENTS
#   stream-node-max-bytes参数用于设置stream节点的最大字节数。
#   每个stream节点都是由多个消息组成的,并且每个消息都有一定的字节数。
#   该参数用于限制stream节点的最大字节数,以避免节点过大而导致内存占用过多的问题。
#   stream-node-max-entries参数用于限制一个stream节点(即一个stream所包含的数据的单位)中的最大条目数。
#   默认值为100。当节点中的条目数量达到该限制时,Redis会自动将节点拆分为更小的节点,
#   并创建新的节点来存储后续的条目。
# END MEIZHAOHUI COMMENTS
stream-node-max-bytes 4096
stream-node-max-entries 100

# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
# order to help rehashing the main Redis hash table (the one mapping top-level
# keys to values). The hash table implementation Redis uses (see dict.c)
# performs a lazy rehashing: the more operation you run into a hash table
# that is rehashing, the more rehashing "steps" are performed, so if the
# server is idle the rehashing is never complete and some more memory is used
# by the hash table.
#
# The default is to use this millisecond 10 times every second in order to
# actively rehash the main dictionaries, freeing memory when possible.
#
# If unsure:
# use "activerehashing no" if you have hard latency requirements and it is
# not a good thing in your environment that Redis can reply from time to time
# to queries with 2 milliseconds delay.
#
# use "activerehashing yes" if you don't have such hard requirements but
# want to free memory asap when possible.
# BEGIN MEIZHAOHUI COMMENTS
#   active rehashing(主动重哈希)是通过设置activerehashing参数来启用的。
#   active rehashing是一种动态将哈希槽从一个节点转移到另一个节点的机制。
#   在Redis集群中,哈希槽被分配给不同的节点来存储数据。当节点的负载不均衡时,
#   active rehashing可以将一部分哈希槽从负载较高的节点移动到负载较低的节点,
#   以实现负载均衡。这个过程是在运行时进行的,并且是自动执行的。
# END MEIZHAOHUI COMMENTS
activerehashing yes

# The client output buffer limits can be used to force disconnection of clients
# that are not reading data from the server fast enough for some reason (a
# common reason is that a Pub/Sub client can't consume messages as fast as the
# publisher can produce them).
#
# The limit can be set differently for the three different classes of clients:
#
# normal -> normal clients including MONITOR clients
# replica  -> replica clients
# pubsub -> clients subscribed to at least one pubsub channel or pattern
#
# The syntax of every client-output-buffer-limit directive is the following:
#
# client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
#
# A client is immediately disconnected once the hard limit is reached, or if
# the soft limit is reached and remains reached for the specified number of
# seconds (continuously).
# So for instance if the hard limit is 32 megabytes and the soft limit is
# 16 megabytes / 10 seconds, the client will get disconnected immediately
# if the size of the output buffers reach 32 megabytes, but will also get
# disconnected if the client reaches 16 megabytes and continuously overcomes
# the limit for 10 seconds.
#
# By default normal clients are not limited because they don't receive data
# without asking (in a push way), but just after a request, so only
# asynchronous clients may create a scenario where data is requested faster
# than it can read.
#
# Instead there is a default limit for pubsub and replica clients, since
# subscribers and replicas receive data in a push fashion.
#
# Both the hard or the soft limit can be disabled by setting them to zero.

# BEGIN MEIZHAOHUI COMMENTS
#   client-output-buffer-limit参数是用来限制客户端输出缓冲区的大小的。
#   参数的格式为:
#   client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
#   其中,
#   <class>指定了要限制的客户端类型,包括normal、slave、pubsub和replica。
#   <hard-limit>表示客户端输出缓冲区的硬限制大小,单位为字节。当输出缓冲区大小超过这个限制时,客户端将被立即关闭。
#   <soft-limit>表示客户端输出缓冲区的软限制大小,单位为字节。当输出缓冲区大小超过这个限制时,Redis将开始主动丢弃一部分缓冲区中的数据,以避免缓冲区溢出。
#   <soft seconds>表示在达到软限制后,Redis将开始丢弃缓冲区数据的持续时间。以秒为单位进行设置。
# END MEIZHAOHUI COMMENTS
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

# Client query buffers accumulate new commands. They are limited to a fixed
# amount by default in order to avoid that a protocol desynchronization (for
# instance due to a bug in the client) will lead to unbound memory usage in
# the query buffer. However you can configure it here if you have very special
# needs, such us huge multi/exec requests or alike.
#
# client-query-buffer-limit 1gb

# In the Redis protocol, bulk requests, that are, elements representing single
# strings, are normally limited to 512 mb. However you can change this limit
# here, but must be 1mb or greater
#
# proto-max-bulk-len 512mb

# Redis calls an internal function to perform many background tasks, like
# closing connections of clients in timeout, purging expired keys that are
# never requested, and so forth.
#
# Not all tasks are performed with the same frequency, but Redis checks for
# tasks to perform according to the specified "hz" value.
#
# By default "hz" is set to 10. Raising the value will use more CPU when
# Redis is idle, but at the same time will make Redis more responsive when
# there are many keys expiring at the same time, and timeouts may be
# handled with more precision.
#
# The range is between 1 and 500, however a value over 100 is usually not
# a good idea. Most users should use the default of 10 and raise this up to
# 100 only in environments where very low latency is required.
# BEGIN MEIZHAOHUI COMMENTS
#   Redis 调用内部函数来执行许多后台任务,
#   例如关闭超时的客户端连接、清除从未请求的过期键等等。
#
#   并非所有任务都以相同的频率执行,但 Redis 会根据指定的"hz"值检查要执行的任务。
#
#   默认情况下,"hz"设置为 10。当 Redis 空闲时,提高该值将使用更多 CPU,
#   但同时当有许多键同时过期时,Redis 的响应速度会更快,并且可以更精确地处理超时。
#
#   该参数范围在 1 到 500 之间,但超过 100 的值是不推荐的。
#   大多数用户应该使用默认值 10,并仅在需要非常低延迟的环境中将其提高到 100。
#   默认的HZ值为10,表示每秒进行10次的定时任务检查。
# END MEIZHAOHUI COMMENTS
hz 10

# Normally it is useful to have an HZ value which is proportional to the
# number of clients connected. This is useful in order, for instance, to
# avoid too many clients are processed for each background task invocation
# in order to avoid latency spikes.
#
# Since the default HZ value by default is conservatively set to 10, Redis
# offers, and enables by default, the ability to use an adaptive HZ value
# which will temporarily raise when there are many connected clients.
#
# When dynamic HZ is enabled, the actual configured HZ will be used
# as a baseline, but multiples of the configured HZ value will be actually
# used as needed once more clients are connected. In this way an idle
# instance will use very little CPU time while a busy instance will be
# more responsive.
# BEGIN MEIZHAOHUI COMMENTS
#   dynamic-hz用于控制Redis是否动态调整服务器的心跳频率。
#   心跳频率是Redis服务器在非阻塞状态下执行任务的速率。
#   在每次循环中,服务器都会操纵定时器(用于计算心跳)。
#   dynamic-hz参数允许Redis根据服务器的负载动态地调整心跳频率。
#   如果dynamic-hz被设置为yes,Redis将根据服务器的负载情况自动调整心跳频率。
#   具体来说,如果服务器忙碌并且使用率较高,Redis会增加心跳频率以提高响应速度。
#   相反,如果服务器处于空闲状态,Redis会降低心跳频率以节省资源。
# END MEIZHAOHUI COMMENTS
dynamic-hz yes

# When a child rewrites the AOF file, if the following option is enabled
# the file will be fsync-ed every 32 MB of data generated. This is useful
# in order to commit the file to the disk more incrementally and avoid
# big latency spikes.
# BEGIN MEIZHAOHUI COMMENTS
#   aof-rewrite-incremental-fsync参数用于控制重写过程中自动执行fsync的频率。
#   fsync是一个用于将数据写入磁盘的系统调用,它确保数据写入磁盘后才返回。
#   然而,频繁的执行fsync操作会导致性能下降。
#   aof-rewrite-incremental-fsync参数接受以下值:
#   yes:表示在AOF重写期间会自动执行fsync操作。这是默认值,可以确保AOF文件的安全性,但可能会影响性能。
#   no:表示在AOF重写期间不执行fsync操作。这样可以提高性能,但可能会增加数据丢失的风险。
# END MEIZHAOHUI COMMENTS
aof-rewrite-incremental-fsync yes

# When redis saves RDB file, if the following option is enabled
# the file will be fsync-ed every 32 MB of data generated. This is useful
# in order to commit the file to the disk more incrementally and avoid
# big latency spikes.
# BEGIN MEIZHAOHUI COMMENTS
#   rdb-save-incremental-fsync参数用于控制是否在进行RDB持久化时进行增量fsync操作。
#   RDB持久化是将Redis的内存数据以二进制格式写入磁盘文件,以保证数据在重启时的持久性。
#   在默认情况下,Redis会在进行RDB持久化时执行一个完整的fsync操作,将数据强制刷写到磁盘上。
#   但是,完整的fsync操作可能会导致一定的性能损失,特别是在写入大量数据时。
#   为了减轻这种性能损失,Redis 6引入了rdb-save-incremental-fsync参数。
#   默认情况下,rdb-save-incremental-fsync参数的值为yes,表示在进行RDB持久化时进行增量fsync操作。
#   增量fsync操作只会将数据写入磁盘的文件系统缓存中,并不会马上将数据刷写到磁盘上。
#   这种方式可以提高性能,但是可能会增加数据丢失的风险,在发生宕机的情况下可能会有一定的数据丢失。
# END MEIZHAOHUI COMMENTS
rdb-save-incremental-fsync yes

# Redis LFU eviction (see maxmemory setting) can be tuned. However it is a good
# idea to start with the default settings and only change them after investigating
# how to improve the performances and how the keys LFU change over time, which
# is possible to inspect via the OBJECT FREQ command.
#
# There are two tunable parameters in the Redis LFU implementation: the
# counter logarithm factor and the counter decay time. It is important to
# understand what the two parameters mean before changing them.
#
# The LFU counter is just 8 bits per key, it's maximum value is 255, so Redis
# uses a probabilistic increment with logarithmic behavior. Given the value
# of the old counter, when a key is accessed, the counter is incremented in
# this way:
#
# 1. A random number R between 0 and 1 is extracted.
# 2. A probability P is calculated as 1/(old_value*lfu_log_factor+1).
# 3. The counter is incremented only if R < P.
#
# The default lfu-log-factor is 10. This is a table of how the frequency
# counter changes with a different number of accesses with different
# logarithmic factors:
#
# +--------+------------+------------+------------+------------+------------+
# | factor | 100 hits   | 1000 hits  | 100K hits  | 1M hits    | 10M hits   |
# +--------+------------+------------+------------+------------+------------+
# | 0      | 104        | 255        | 255        | 255        | 255        |
# +--------+------------+------------+------------+------------+------------+
# | 1      | 18         | 49         | 255        | 255        | 255        |
# +--------+------------+------------+------------+------------+------------+
# | 10     | 10         | 18         | 142        | 255        | 255        |
# +--------+------------+------------+------------+------------+------------+
# | 100    | 8          | 11         | 49         | 143        | 255        |
# +--------+------------+------------+------------+------------+------------+
#
# NOTE: The above table was obtained by running the following commands:
#
#   redis-benchmark -n 1000000 incr foo
#   redis-cli object freq foo
#
# NOTE 2: The counter initial value is 5 in order to give new objects a chance
# to accumulate hits.
#
# The counter decay time is the time, in minutes, that must elapse in order
# for the key counter to be divided by two (or decremented if it has a value
# less <= 10).
#
# The default value for the lfu-decay-time is 1. A special value of 0 means to
# decay the counter every time it happens to be scanned.
#
# lfu-log-factor 10
# lfu-decay-time 1

########################### ACTIVE DEFRAGMENTATION #######################
#
# What is active defragmentation?
# -------------------------------
#
# Active (online) defragmentation allows a Redis server to compact the
# spaces left between small allocations and deallocations of data in memory,
# thus allowing to reclaim back memory.
#
# Fragmentation is a natural process that happens with every allocator (but
# less so with Jemalloc, fortunately) and certain workloads. Normally a server
# restart is needed in order to lower the fragmentation, or at least to flush
# away all the data and create it again. However thanks to this feature
# implemented by Oran Agra for Redis 4.0 this process can happen at runtime
# in a "hot" way, while the server is running.
#
# Basically when the fragmentation is over a certain level (see the
# configuration options below) Redis will start to create new copies of the
# values in contiguous memory regions by exploiting certain specific Jemalloc
# features (in order to understand if an allocation is causing fragmentation
# and to allocate it in a better place), and at the same time, will release the
# old copies of the data. This process, repeated incrementally for all the keys
# will cause the fragmentation to drop back to normal values.
#
# Important things to understand:
#
# 1. This feature is disabled by default, and only works if you compiled Redis
#    to use the copy of Jemalloc we ship with the source code of Redis.
#    This is the default with Linux builds.
#
# 2. You never need to enable this feature if you don't have fragmentation
#    issues.
#
# 3. Once you experience fragmentation, you can enable this feature when
#    needed with the command "CONFIG SET activedefrag yes".
#
# The configuration parameters are able to fine tune the behavior of the
# defragmentation process. If you are not sure about what they mean it is
# a good idea to leave the defaults untouched.

# Enabled active defragmentation
# activedefrag no

# Minimum amount of fragmentation waste to start active defrag
# active-defrag-ignore-bytes 100mb

# Minimum percentage of fragmentation to start active defrag
# active-defrag-threshold-lower 10

# Maximum percentage of fragmentation at which we use maximum effort
# active-defrag-threshold-upper 100

# Minimal effort for defrag in CPU percentage, to be used when the lower
# threshold is reached
# active-defrag-cycle-min 1

# Maximal effort for defrag in CPU percentage, to be used when the upper
# threshold is reached
# active-defrag-cycle-max 25

# Maximum number of set/hash/zset/list fields that will be processed from
# the main dictionary scan
# active-defrag-max-scan-fields 1000

# Jemalloc background thread for purging will be enabled by default
# BEGIN MEIZHAOHUI COMMENTS
#   jemalloc-bg-thread 参数是一个用于控制 jemalloc 后台线程行为的选项。
#   jemalloc 是一个用于 Redis 内存分配的开源库,它的主要特点是支持多线程内存分配,
#   可以提高 Redis 的并发性能。
#   jemalloc-bg-thread 参数的默认值是 yes,它表示启用 jemalloc 后台线程。
#   这个后台线程主要用于处理 jemalloc 的内存处理任务,
#   例如内存碎片整理、内存归还等,它可以在后台异步地执行这些任务,
#   避免阻塞 Redis 的主线程。
#   当发生写入删除操作时,jemalloc 可能会产生一些内存碎片。
#   这些内存碎片会导致 Redis 的内存使用效率下降。
#   启用 jemalloc-bg-thread 可以定期对这些内存碎片进行整理,提高 Redis 的内存使用效率。
# END MEIZHAOHUI COMMENTS
jemalloc-bg-thread yes

# It is possible to pin different threads and processes of Redis to specific
# CPUs in your system, in order to maximize the performances of the server.
# This is useful both in order to pin different Redis threads in different
# CPUs, but also in order to make sure that multiple Redis instances running
# in the same host will be pinned to different CPUs.
#
# Normally you can do this using the "taskset" command, however it is also
# possible to this via Redis configuration directly, both in Linux and FreeBSD.
#
# You can pin the server/IO threads, bio threads, aof rewrite child process, and
# the bgsave child process. The syntax to specify the cpu list is the same as
# the taskset command:
#
# Set redis server/io threads to cpu affinity 0,2,4,6:
# server_cpulist 0-7:2
#
# Set bio threads to cpu affinity 1,3:
# bio_cpulist 1,3
#
# Set aof rewrite child process to cpu affinity 8,9,10,11:
# aof_rewrite_cpulist 8-11
#
# Set bgsave child process to cpu affinity 1,10,11
# bgsave_cpulist 1,10-11

# In some cases redis will emit warnings and even refuse to start if it detects
# that the system is in bad state, it is possible to suppress these warnings
# by setting the following config which takes a space delimited list of warnings
# to suppress
#
# ignore-warnings ARM64-COW-BUG

创建相关目录:

sh
[root@redis-server redis-6.2.14]# cd /srv/
[root@redis-server srv]# ln -s redis-6.2.14 redis
[root@redis-server srv]# mkdir redis/{pid,logs,data}
[root@redis-server srv]# ls -d redis/{pid,logs,data}
redis/data  redis/logs  redis/pid

8. 启动redis服务

8.1 尝试启动redis服务

sh
[root@redis-server ~]# cd /srv/
[root@redis-server redis]# ./bin/redis-server ./conf/redis.conf

此时,redis服务是在前台启动的。我们重新开一个控制台窗口,查看redis服务状态。

sh
[root@redis-server ~]# ps -ef|grep redis
root      1820  1479  0 11:35 pts/0    00:00:00 ./bin/redis-server ./conf/redis.conf
root      2567  1532  0 11:49 pts/1    00:00:00 grep --color=always redis
[root@redis-server ~]# netstat -tunlp|grep redis
tcp        0      0 127.0.0.1:29736         0.0.0.0:*               LISTEN      1820/./bin/redis-se
tcp        0      0 192.168.56.121:29736    0.0.0.0:*               LISTEN      1820/./bin/redis-se
[root@redis-server ~]#

可以看到,服务启动了。查看一下日志:

sh
[root@redis-server ~]# tail /srv/redis/logs/redis_29736.log
1820:C 07 Jul 2024 11:35:09.760 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1820:C 07 Jul 2024 11:35:09.760 # Redis version=6.2.14, bits=64, commit=00000000, modified=0, pid=1820, just started
1820:C 07 Jul 2024 11:35:09.760 # Configuration loaded
1820:M 07 Jul 2024 11:35:09.760 * Increased maximum number of open files to 10032 (it was originally set to 1024).
1820:M 07 Jul 2024 11:35:09.760 * monotonic clock: POSIX clock_gettime
1820:M 07 Jul 2024 11:35:09.760 * Running mode=standalone, port=29736.
1820:M 07 Jul 2024 11:35:09.760 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1820:M 07 Jul 2024 11:35:09.760 # Server initialized
1820:M 07 Jul 2024 11:35:09.760 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1820:M 07 Jul 2024 11:35:09.760 * Ready to accept connections
[root@redis-server ~]#

可以看到,redis日志有了,但其中有两个警告信息。

8.2 修复Memory overcommit must be enabled告警

按提示修改/etc/sysctl.conf 配置文件:

sh
# 查看当前/etc/sysctl.conf配置
[root@redis-server ~]# cat /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).


# 修改配置
[root@redis-server ~]# echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf


# 再次查看当前/etc/sysctl.conf配置
[root@redis-server ~]# cat /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
vm.overcommit_memory = 1
[root@redis-server ~]# sysctl -p
vm.overcommit_memory = 1
[root@redis-server ~]#

再次启动redis服务:

sh
# 此处是按Ctrl+C停止之前启动的redis服务
[root@redis-server redis]# ./bin/redis-server ./conf/redis.conf^C

# 查看一下sysctl配置生效没有
[root@redis-server redis]# sysctl -p|grep commit
vm.overcommit_memory = 1

# 可以看到配置生效了,清空一下之前的日志
[root@redis-server redis]# > logs/redis_29736.log

# 再次启动服务
[root@redis-server redis]# ./bin/redis-server ./conf/redis.conf

此时查看日志已经可以看到没有WARNING Memory overcommit must be enabled!告警了:

sh
[root@redis-server ~]# cat /srv/redis/logs/redis_29736.log
2929:C 07 Jul 2024 11:56:55.391 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2929:C 07 Jul 2024 11:56:55.391 # Redis version=6.2.14, bits=64, commit=00000000, modified=0, pid=2929, just started
2929:C 07 Jul 2024 11:56:55.391 # Configuration loaded
2929:M 07 Jul 2024 11:56:55.392 * Increased maximum number of open files to 10032 (it was originally set to 1024).
2929:M 07 Jul 2024 11:56:55.392 * monotonic clock: POSIX clock_gettime
2929:M 07 Jul 2024 11:56:55.392 * Running mode=standalone, port=29736.
2929:M 07 Jul 2024 11:56:55.392 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
2929:M 07 Jul 2024 11:56:55.392 # Server initialized
2929:M 07 Jul 2024 11:56:55.392 * Ready to accept connections
[root@redis-server ~]#

查看redis相关信息:

sh
[root@redis-server ~]# /srv/redis/bin/redis-cli -p 29736
127.0.0.1:29736> info memory
NOAUTH Authentication required.
127.0.0.1:29736> auth ALONGPASSWORD
OK
127.0.0.1:29736> info memory
# Memory
used_memory:874208
used_memory_human:853.72K
used_memory_rss:10477568
used_memory_rss_human:9.99M
used_memory_peak:875952
used_memory_peak_human:855.42K
used_memory_peak_perc:99.80%
used_memory_overhead:832632
used_memory_startup:812120
used_memory_dataset:41576
used_memory_dataset_perc:66.96%
allocator_allocated:1180856
allocator_active:1462272
allocator_resident:3829760
total_system_memory:8201236480
total_system_memory_human:7.64G
used_memory_lua:30720
used_memory_lua_human:30.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:1073741824
maxmemory_human:1.00G
maxmemory_policy:noeviction
allocator_frag_ratio:1.24
allocator_frag_bytes:281416
allocator_rss_ratio:2.62
allocator_rss_bytes:2367488
rss_overhead_ratio:2.74
rss_overhead_bytes:6647808
mem_fragmentation_ratio:12.58
mem_fragmentation_bytes:9644376
mem_not_counted_for_evict:4
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:20504
mem_aof_buffer:8
mem_allocator:jemalloc-5.1.0
active_defrag_running:0
lazyfree_pending_objects:0
lazyfreed_objects:0
127.0.0.1:29736> info replication
# Replication
role:master
connected_slaves:0
master_failover_state:no-failover
master_replid:43d84609e88c12077b3d3e3a3d84dc8a062b9200
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
127.0.0.1:29736>

尝试执行redis基本命令:

sh
127.0.0.1:29736> set number 6379
OK
127.0.0.1:29736> get number
"6379"
127.0.0.1:29736> set name redis
OK
127.0.0.1:29736> get name
"redis"
127.0.0.1:29736>

可以看到,可以正常设置和获取键值。

本首页参考 https://notes.fe-mm.com/ 配置而成