Redis的搭建和Redis的集群搭建

时光总嘲笑我的痴心妄想 提交于 2020-11-25 09:20:31

1、Redis的官网:https://redis.io/      Redis的测试网站:http://try.redis.io/

2、参考博客:https://www.cnblogs.com/mafly/p/redis_cluster.html

http://blog.mayongfa.cn/258.html

windows安装参考:http://www.cnblogs.com/jaign/articles/7920588.html#top

3、Centos操作系统中Redis的安装:

开始使用的hadoop用户和自己指定的目录,然后出现了一些问题,最后使用了root用户进行安装,顺利安装。自己安装多小心吧。

首先下载一下Redis,详细参考http://blog.mayongfa.cn/258.html

然后将redis解压缩到指定的目录,解压缩操作:

4、编译安装redis:

执行make出现错误:

[hadoop@slaver1 package]$ cd ../soft/redis-3.2.5/
[hadoop@slaver1 redis-3.2.5]$ ls
00-RELEASENOTES  COPYING  Makefile   redis.conf       runtest-sentinel  tests
BUGS             deps     MANIFESTO  runtest          sentinel.conf     utils
CONTRIBUTING     INSTALL  README.md  runtest-cluster  src
[hadoop@slaver1 redis-3.2.5]$ make
cd src && make all
make[1]: Entering directory `/home/hadoop/soft/redis-3.2.5/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
(cd ../deps && make distclean)
make[2]: Entering directory `/home/hadoop/soft/redis-3.2.5/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd geohash-int && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/home/hadoop/soft/redis-3.2.5/deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic -DREDIS_STATIC='' >> .make-settings
echo WARN=-Wall -W >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -DREDIS_STATIC='' -Wall -W -O2 -g -ggdb   -I../deps/geohash-int -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_FINAL_LDFLAGS=  -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua geohash-int jemalloc)
make[2]: Entering directory `/home/hadoop/soft/redis-3.2.5/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd geohash-int && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-ldflags)
(echo "" > .make-cflags)
MAKE hiredis
cd hiredis && make static
make[3]: Entering directory `/home/hadoop/soft/redis-3.2.5/deps/hiredis'
gcc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
make[3]: gcc: Command not found
make[3]: *** [net.o] Error 127
make[3]: Leaving directory `/home/hadoop/soft/redis-3.2.5/deps/hiredis'
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory `/home/hadoop/soft/redis-3.2.5/deps'
make[1]: [persist-settings] Error 2 (ignored)
    CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/home/hadoop/soft/redis-3.2.5/src'
make: *** [all] Error 2
[hadoop@slaver1 redis-3.2.5]$ make install
cd src && make install
make[1]: Entering directory `/home/hadoop/soft/redis-3.2.5/src'
    CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/home/hadoop/soft/redis-3.2.5/src'
make: *** [install] Error 2
[hadoop@slaver1 redis-3.2.5]$ ls
00-RELEASENOTES  COPYING  Makefile   redis.conf       runtest-sentinel  tests
BUGS             deps     MANIFESTO  runtest          sentinel.conf     utils
CONTRIBUTING     INSTALL  README.md  runtest-cluster  src
[hadoop@slaver1 redis-3.2.5]$ cd ..
[hadoop@slaver1 soft]$ ls
apache-maven-3.5.3   flume-1.5.0-cdh5.3.6-bin  kafka_2.9.2-0.8.1          sqoop-1.4.5-cdh5.3.6
apache-tomcat-7.0.8  hadoop-2.5.0-cdh5.3.6     oozie-4.0.0-cdh5.3.6       zookeeper-3.4.5-cdh5.3.6
azkaban              hbase-0.98.6-cdh5.3.6     redis-3.2.5
eclipse              hive-0.13.1-cdh5.3.6      scala-2.11.4
export               jdk1.7.0_79               spark-1.5.1-bin-hadoop2.4
[hadoop@slaver1 soft]$ cd redis-3.2.5/
[hadoop@slaver1 redis-3.2.5]$ ls
00-RELEASENOTES  COPYING  Makefile   redis.conf       runtest-sentinel  tests
BUGS             deps     MANIFESTO  runtest          sentinel.conf     utils
CONTRIBUTING     INSTALL  README.md  runtest-cluster  src
[hadoop@slaver1 redis-3.2.5]$ make
cd src && make all
make[1]: Entering directory `/home/hadoop/soft/redis-3.2.5/src'
    CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/home/hadoop/soft/redis-3.2.5/src'
make: *** [all] Error 2
[hadoop@slaver1 redis-3.2.5]$

 出现上面这个错误,百度说安装gcc啥的,安装了还是报错了。然后呢,我按照参考的连接操作,执行make不出现错误了。

[hadoop@slaver1 package]$ mv redis-3.2.5 /usr/local/redis
mv: cannot move `redis-3.2.5' to `/usr/local/redis': Permission denied
[hadoop@slaver1 package]$ su
Password: 
[root@slaver1 package]# clear
[root@slaver1 package]# ls
all_host                                       kafka_2.9.2-0.8.1.tgz
azkaban-executor-server-2.5.0.tar.gz           redis-3.2.5
azkaban-sql-script-2.5.0.tar.gz                redis-3.2.5.tar.gz
azkaban-web-server-2.5.0.tar.gz                slf4j-1.7.6
greenplum-db-4.3.8.2-build-1-RHEL5-x86_64.7z   slf4j-1.7.6.zip
greenplum-db-4.3.8.2-build-1-RHEL5-x86_64.zip
[root@slaver1 package]# ll
total 298100
-rw-r--r--   1 root   root          25 Jun 11 16:34 all_host
-rwxrw-rw-.  1 hadoop hadoop  11157302 Oct 19  2017 azkaban-executor-server-2.5.0.tar.gz
-rwxrw-rw-.  1 hadoop hadoop      1928 Oct 19  2017 azkaban-sql-script-2.5.0.tar.gz
-rwxrw-rw-.  1 hadoop hadoop  11989669 Oct 19  2017 azkaban-web-server-2.5.0.tar.gz
-rw-rw-r--.  1 hadoop hadoop 120991865 Jun 11 14:00 greenplum-db-4.3.8.2-build-1-RHEL5-x86_64.7z
-rw-rw-r--.  1 hadoop hadoop 141636514 Jun 11 14:23 greenplum-db-4.3.8.2-build-1-RHEL5-x86_64.zip
-rw-rw-r--.  1 hadoop hadoop  13424570 Apr 24 15:18 kafka_2.9.2-0.8.1.tgz
drwxrwxr-x   6 hadoop hadoop      4096 Oct 26  2016 redis-3.2.5
-rw-rw-r--   1 hadoop hadoop   1544040 Oct 26  2016 redis-3.2.5.tar.gz
drwxrwxrwx. 19 hadoop hadoop      4096 Feb  6  2014 slf4j-1.7.6
-rw-rw-r--.  1 hadoop hadoop   4478807 Apr 24 17:53 slf4j-1.7.6.zip
[root@slaver1 package]# mv redis-3.2.5 /usr/local/redis
[root@slaver1 package]# ls
all_host                              greenplum-db-4.3.8.2-build-1-RHEL5-x86_64.7z   slf4j-1.7.6
azkaban-executor-server-2.5.0.tar.gz  greenplum-db-4.3.8.2-build-1-RHEL5-x86_64.zip  slf4j-1.7.6.zip
azkaban-sql-script-2.5.0.tar.gz       kafka_2.9.2-0.8.1.tgz
azkaban-web-server-2.5.0.tar.gz       redis-3.2.5.tar.gz
[root@slaver1 package]# cd /usr/local/redis/
[root@slaver1 redis]# ls
00-RELEASENOTES  COPYING  Makefile   redis.conf       runtest-sentinel  tests
BUGS             deps     MANIFESTO  runtest          sentinel.conf     utils
CONTRIBUTING     INSTALL  README.md  runtest-cluster  src
[root@slaver1 redis]# make
cd src && make all
make[1]: Entering directory `/usr/local/redis/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
(cd ../deps && make distclean)
make[2]: Entering directory `/usr/local/redis/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd geohash-int && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/usr/local/redis/deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic -DREDIS_STATIC='' >> .make-settings
echo WARN=-Wall -W >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -DREDIS_STATIC='' -Wall -W -O2 -g -ggdb   -I../deps/geohash-int -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_FINAL_LDFLAGS=  -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua geohash-int jemalloc)
make[2]: Entering directory `/usr/local/redis/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd geohash-int && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-ldflags)
(echo "" > .make-cflags)
MAKE hiredis
cd hiredis && make static
make[3]: Entering directory `/usr/local/redis/deps/hiredis'
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  hiredis.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  sds.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  async.c
ar rcs libhiredis.a net.o hiredis.o sds.o async.o
make[3]: Leaving directory `/usr/local/redis/deps/hiredis'
MAKE linenoise
cd linenoise && make
make[3]: Entering directory `/usr/local/redis/deps/linenoise'
cc  -Wall -Os -g  -c linenoise.c
make[3]: Leaving directory `/usr/local/redis/deps/linenoise'
MAKE lua
cd lua/src && make all CFLAGS="-O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' " MYLDFLAGS="" AR="ar rcu"
make[3]: Entering directory `/usr/local/redis/deps/lua/src'
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lapi.o lapi.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lcode.o lcode.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o ldebug.o ldebug.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o ldo.o ldo.c
ldo.c: In function ‘f_parser’:
ldo.c:496: warning: unused variable ‘c’
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o ldump.o ldump.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lfunc.o lfunc.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lgc.o lgc.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o llex.o llex.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lmem.o lmem.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lobject.o lobject.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lopcodes.o lopcodes.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lparser.o lparser.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lstate.o lstate.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lstring.o lstring.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o ltable.o ltable.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o ltm.o ltm.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lundump.o lundump.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lvm.o lvm.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lzio.o lzio.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o strbuf.o strbuf.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o fpconv.o fpconv.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lauxlib.o lauxlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lbaselib.o lbaselib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o ldblib.o ldblib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o liolib.o liolib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lmathlib.o lmathlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o loslib.o loslib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o ltablib.o ltablib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lstrlib.o lstrlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o loadlib.o loadlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o linit.o linit.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lua_cjson.o lua_cjson.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lua_struct.o lua_struct.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lua_cmsgpack.o lua_cmsgpack.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o lua_bit.o lua_bit.c
ar rcu 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=''    -c -o lua.o lua.c
cc -o lua  lua.o liblua.a -lm 
liblua.a(loslib.o): In function `os_tmpname':
loslib.c:(.text+0x35): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o luac.o luac.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC=''    -c -o print.o print.c
cc -o luac  luac.o print.o liblua.a -lm 
make[3]: Leaving directory `/usr/local/redis/deps/lua/src'
MAKE geohash-int
cd geohash-int && make
make[3]: Entering directory `/usr/local/redis/deps/geohash-int'
cc  -Wall -O2 -g  -c geohash.c
cc  -Wall -O2 -g  -c geohash_helper.c
make[3]: Leaving directory `/usr/local/redis/deps/geohash-int'
MAKE jemalloc
cd jemalloc && ./configure --with-lg-quantum=3 --with-jemalloc-prefix=je_ --enable-cc-silence 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 how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /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 intmax_t... 8
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking whether pause instruction is compilable... yes
checking for ar... ar
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 whether __attribute__ syntax is compilable... yes
checking whether compiler supports -fvisibility=hidden... yes
checking whether compiler supports -Werror... yes
checking whether tls_model attribute is compilable... yes
checking whether compiler supports -Werror... yes
checking whether alloc_size attribute is compilable... yes
checking whether compiler supports -Werror... yes
checking whether format(gnu_printf, ...) attribute is compilable... yes
checking whether compiler supports -Werror... yes
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... /usr/bin/autoconf
checking for memalign... yes
checking for valloc... yes
checking configured backtracing method... N/A
checking for sbrk... yes
checking whether utrace(2) is compilable... no
checking whether valgrind is compilable... no
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 for library containing clock_gettime... -lrt
checking for secure_getenv... no
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 atomic(9) is compilable... no
checking whether Darwin OSAtomic*() is compilable... no
checking whether madvise(2) 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 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 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_internal.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/private_namespace.h commands
config.status: executing include/jemalloc/internal/private_unnamespace.h commands
config.status: executing include/jemalloc/internal/public_symbols.txt 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   : 4.0.3-0-ge9192eacf8935e29fc62fddc2701f7942b1cc02c
library revision   : 2

CONFIG             : --with-lg-quantum=3 --with-jemalloc-prefix=je_ --enable-cc-silence 'CFLAGS=-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops ' LDFLAGS=
CC                 : gcc
CFLAGS             : -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -fvisibility=hidden
CPPFLAGS           :  -D_GNU_SOURCE -D_REENTRANT
LDFLAGS            : 
EXTRA_LDFLAGS      : 
LIBS               :  -lpthread
TESTLIBS           : -lrt 
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        : /usr/local/redis/deps/jemalloc/
objroot            : 
abs_objroot        : /usr/local/redis/deps/jemalloc/

JEMALLOC_PREFIX    : je_
JEMALLOC_PRIVATE_NAMESPACE
                   : je_
install_suffix     : 
autogen            : 0
cc-silence         : 1
debug              : 0
code-coverage      : 0
stats              : 1
prof               : 0
prof-libunwind     : 0
prof-libgcc        : 0
prof-gcc           : 0
tcache             : 1
fill               : 1
utrace             : 0
valgrind           : 0
xmalloc            : 0
munmap             : 0
lazy_lock          : 0
tls                : 1
cache-oblivious    : 1
===============================================================================
cd jemalloc && make CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS="" lib/libjemalloc.a
make[3]: Entering directory `/usr/local/redis/deps/jemalloc'
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/atomic.o src/atomic.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/bitmap.o src/bitmap.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk.o src/chunk.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk_dss.o src/chunk_dss.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk_mmap.o src/chunk_mmap.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/extent.o src/extent.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/huge.o src/huge.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mb.o src/mb.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/pages.o src/pages.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/quarantine.o src/quarantine.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/tcache.o src/tcache.c
gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/util.o src/util.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
ar crus lib/libjemalloc.a src/jemalloc.o src/arena.o src/atomic.o src/base.o src/bitmap.o src/chunk.o src/chunk_dss.o src/chunk_mmap.o src/ckh.o src/ctl.o src/extent.o src/hash.o src/huge.o src/mb.o src/mutex.o src/pages.o src/prof.o src/quarantine.o src/rtree.o src/stats.o src/tcache.o src/util.o src/tsd.o
make[3]: Leaving directory `/usr/local/redis/deps/jemalloc'
make[2]: Leaving directory `/usr/local/redis/deps'
    CC adlist.o
    CC quicklist.o
    CC ae.o
In file included from ae.c:53:
ae_epoll.c: In function ‘aeApiAddEvent’:
ae_epoll.c:75: warning: missing initializer
ae_epoll.c:75: warning: (near initialization for ‘ee.data’)
ae_epoll.c: In function ‘aeApiDelEvent’:
ae_epoll.c:92: warning: missing initializer
ae_epoll.c:92: warning: (near initialization for ‘ee.data’)
    CC anet.o
anet.c: In function ‘anetSockName’:
anet.c:640: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:638: note: initialized from here
anet.c:644: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:642: note: initialized from here
anet.c: In function ‘anetPeerToString’:
anet.c:584: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:582: note: initialized from here
anet.c:588: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:586: note: initialized from here
anet.c: In function ‘anetTcpAccept’:
anet.c:555: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:553: note: initialized from here
anet.c:559: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:557: note: initialized from here
    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 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 geo.o
    LINK redis-server
    INSTALL redis-sentinel
    CC redis-cli.o
    LINK redis-cli
    CC redis-benchmark.o
    LINK redis-benchmark
    INSTALL redis-check-rdb
    CC redis-check-aof.o
    LINK redis-check-aof

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

make[1]: Leaving directory `/usr/local/redis/src'
[root@slaver1 redis]#

然后执行make install,貌似报错了,但是其他教程貌似不执行这条命令:

[root@slaver1 redis]# make install
cd src && make install
make[1]: Entering directory `/usr/local/redis/src'

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

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/usr/local/redis/src'
[root@slaver1 redis]# make install
cd src && make install
make[1]: Entering directory `/usr/local/redis/src'

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

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/usr/local/redis/src'
[root@slaver1 redis]# ls
00-RELEASENOTES  COPYING  Makefile   redis.conf       runtest-sentinel  tests
BUGS             deps     MANIFESTO  runtest          sentinel.conf     utils
CONTRIBUTING     INSTALL  README.md  runtest-cluster  src
[root@slaver1 redis]# cd /usr/local/bin/
[root@slaver1 bin]# ls
redis-benchmark  redis-check-aof  redis-check-rdb  redis-cli  redis-sentinel  redis-server
[root@slaver1 bin]# cd ..
[root@slaver1 local]# ls
bin  data  etc  games  include  lib  lib64  libexec  redis  sbin  share  src
[root@slaver1 local]# cd /usr/local/redis/
[root@slaver1 redis]# ls
00-RELEASENOTES  COPYING  Makefile   redis.conf       runtest-sentinel  tests
BUGS             deps     MANIFESTO  runtest          sentinel.conf     utils
CONTRIBUTING     INSTALL  README.md  runtest-cluster  src
[root@slaver1 redis]# 

 5、配置redis.conf配置文件:

[root@slaver1 redis]# cd /usr/local/redis/
[root@slaver1 redis]# ls
00-RELEASENOTES  COPYING  Makefile   redis.conf       runtest-sentinel  tests
BUGS             deps     MANIFESTO  runtest          sentinel.conf     utils
CONTRIBUTING     INSTALL  README.md  runtest-cluster  src
[root@slaver1 redis]# vim redis.conf 

这里要修改两个地方,一个bind和daemonize就行。daemonize配置是否以守护进程的方式启动Redis,dir配置可以配置Redis的工作目录,用于存放持久化文件和日志文件。logfile配置是日志文件
bind这里配置要注意,默认是只有一个127.0.0.1,这个时候只能自己连接,其他局域网内是连接不上的。所以,需要配置多个 IP ,这样就可以局域网内进行连接了。

可以使用:/bind进行搜索找到:

daemonize是设置是否后台启动 Redis,默认no,正常都需要以服务形式启动 Redis,所以这里设置为yes。

6、启动操作:

 

7、测试操作:

 这里用命令行模式连接上 Redis 进行一个简单的设置、获取缓存测试。

redis-cli #连接 Redis ,默认是本机的。
keys * #查看现在所有 key
set name mafly #设置一个key为`name`,value为`mafly`的缓存对象。
get name #获取key为`name`的缓存

8、退出

9、开始3主3从模式安装redis集群,详细过程参考https://www.cnblogs.com/mafly/p/redis_cluster.html

这里主要贴一下出现的问题即可,不再重复记录过程。


修改时间:2019-08-25 17:51:17

1 Redis的安装,redis是c语言开发的,安装redis需要c语言的编译环境。如果没有gcc,需要在线安装,安装命令yum install gcc-c++
2 安装步骤。
3 第一步、将redis的源码包上传到linux系统。
4 第二步、解压缩redis。
5 第三步、编译,进入redis源码目录。执行make命令。
6 第四步、安装。make install PREFIX=/usr/local/redis
7 PREFIX参数指定redis的安装目录。一般软件安装到/usr目录下面。

1、Redis的单节点安装,redis是c语言开发的,安装redis需要c语言的编译环境。如果没有gcc,需要在线安装,安装命令yum install gcc-c++。

  1 [root@localhost package]# yum install gcc-c++
  2 Loaded plugins: fastestmirror, refresh-packagekit, security
  3 Determining fastest mirrors
  4  * base: mirrors.tuna.tsinghua.edu.cn
  5  * extras: mirror.bit.edu.cn
  6  * updates: mirror.bit.edu.cn
  7 base                                                                                                                                                                                                     | 3.7 kB     00:00     
  8 extras                                                                                                                                                                                                   | 3.3 kB     00:00     
  9 updates                                                                                                                                                                                                  | 3.4 kB     00:00     
 10 updates/primary_db                                                                                                                                                                                       | 5.5 MB     00:08     
 11 Setting up Install Process
 12 Resolving Dependencies
 13 --> Running transaction check
 14 ---> Package gcc-c++.i686 0:4.4.7-23.el6 will be installed
 15 --> Processing Dependency: libstdc++-devel = 4.4.7-23.el6 for package: gcc-c++-4.4.7-23.el6.i686
 16 --> Processing Dependency: libstdc++ = 4.4.7-23.el6 for package: gcc-c++-4.4.7-23.el6.i686
 17 --> Processing Dependency: gcc = 4.4.7-23.el6 for package: gcc-c++-4.4.7-23.el6.i686
 18 --> Running transaction check
 19 ---> Package gcc.i686 0:4.4.7-3.el6 will be updated
 20 ---> Package gcc.i686 0:4.4.7-23.el6 will be an update
 21 --> Processing Dependency: libgomp = 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.i686
 22 --> Processing Dependency: cpp = 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.i686
 23 --> Processing Dependency: libgcc >= 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.i686
 24 ---> Package libstdc++.i686 0:4.4.7-3.el6 will be updated
 25 ---> Package libstdc++.i686 0:4.4.7-23.el6 will be an update
 26 ---> Package libstdc++-devel.i686 0:4.4.7-23.el6 will be installed
 27 --> Running transaction check
 28 ---> Package cpp.i686 0:4.4.7-3.el6 will be updated
 29 ---> Package cpp.i686 0:4.4.7-23.el6 will be an update
 30 ---> Package libgcc.i686 0:4.4.7-3.el6 will be updated
 31 ---> Package libgcc.i686 0:4.4.7-23.el6 will be an update
 32 ---> Package libgomp.i686 0:4.4.7-3.el6 will be updated
 33 ---> Package libgomp.i686 0:4.4.7-23.el6 will be an update
 34 --> Finished Dependency Resolution
 35 
 36 Dependencies Resolved
 37 
 38 ================================================================================================================================================================================================================================
 39  Package                                                     Arch                                             Version                                                    Repository                                        Size
 40 ================================================================================================================================================================================================================================
 41 Installing:
 42  gcc-c++                                                     i686                                             4.4.7-23.el6                                               base                                             4.3 M
 43 Installing for dependencies:
 44  libstdc++-devel                                             i686                                             4.4.7-23.el6                                               base                                             1.6 M
 45 Updating for dependencies:
 46  cpp                                                         i686                                             4.4.7-23.el6                                               base                                             3.4 M
 47  gcc                                                         i686                                             4.4.7-23.el6                                               base                                             8.2 M
 48  libgcc                                                      i686                                             4.4.7-23.el6                                               base                                             115 k
 49  libgomp                                                     i686                                             4.4.7-23.el6                                               base                                             137 k
 50  libstdc++                                                   i686                                             4.4.7-23.el6                                               base                                             303 k
 51 
 52 Transaction Summary
 53 ================================================================================================================================================================================================================================
 54 Install       2 Package(s)
 55 Upgrade       5 Package(s)
 56 
 57 Total download size: 18 M
 58 Is this ok [y/N]: y
 59 Downloading Packages:
 60 (1/7): cpp-4.4.7-23.el6.i686.rpm                                                                                                                                                                         | 3.4 MB     00:01     
 61 (2/7): gcc-4.4.7-23.el6.i686.rpm                                                                                                                                                                         | 8.2 MB     00:01     
 62 (3/7): gcc-c++-4.4.7-23.el6.i686.rpm                                                                                                                                                                     | 4.3 MB     00:01     
 63 (4/7): libgcc-4.4.7-23.el6.i686.rpm                                                                                                                                                                      | 115 kB     00:00     
 64 (5/7): libgomp-4.4.7-23.el6.i686.rpm                                                                                                                                                                     | 137 kB     00:00     
 65 (6/7): libstdc++-4.4.7-23.el6.i686.rpm                                                                                                                                                                   | 303 kB     00:00     
 66 (7/7): libstdc++-devel-4.4.7-23.el6.i686.rpm                                                                                                                                                             | 1.6 MB     00:00     
 67 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 68 Total                                                                                                                                                                                           2.0 MB/s |  18 MB     00:08     
 69 warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
 70 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
 71 Importing GPG key 0xC105B9DE:
 72  Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
 73  Package: centos-release-6-4.el6.centos.10.i686 (@anaconda-CentOS-201303020136.i386/6.4)
 74  From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
 75 Is this ok [y/N]: y
 76 Running rpm_check_debug
 77 Running Transaction Test
 78 Transaction Test Succeeded
 79 Running Transaction
 80   Updating   : libgcc-4.4.7-23.el6.i686                                                                                                                                                                                    1/12 
 81   Updating   : libstdc++-4.4.7-23.el6.i686                                                                                                                                                                                 2/12 
 82   Installing : libstdc++-devel-4.4.7-23.el6.i686                                                                                                                                                                           3/12 
 83   Updating   : libgomp-4.4.7-23.el6.i686                                                                                                                                                                                   4/12 
 84   Updating   : cpp-4.4.7-23.el6.i686                                                                                                                                                                                       5/12 
 85   Updating   : gcc-4.4.7-23.el6.i686                                                                                                                                                                                       6/12 
 86   Installing : gcc-c++-4.4.7-23.el6.i686                                                                                                                                                                                   7/12 
 87   Cleanup    : gcc-4.4.7-3.el6.i686                                                                                                                                                                                        8/12 
 88   Cleanup    : libstdc++-4.4.7-3.el6.i686                                                                                                                                                                                  9/12 
 89   Cleanup    : libgcc-4.4.7-3.el6.i686                                                                                                                                                                                    10/12 
 90   Cleanup    : cpp-4.4.7-3.el6.i686                                                                                                                                                                                       11/12 
 91   Cleanup    : libgomp-4.4.7-3.el6.i686                                                                                                                                                                                   12/12 
 92   Verifying  : libgcc-4.4.7-23.el6.i686                                                                                                                                                                                    1/12 
 93   Verifying  : cpp-4.4.7-23.el6.i686                                                                                                                                                                                       2/12 
 94   Verifying  : libgomp-4.4.7-23.el6.i686                                                                                                                                                                                   3/12 
 95   Verifying  : libstdc++-4.4.7-23.el6.i686                                                                                                                                                                                 4/12 
 96   Verifying  : libstdc++-devel-4.4.7-23.el6.i686                                                                                                                                                                           5/12 
 97   Verifying  : gcc-4.4.7-23.el6.i686                                                                                                                                                                                       6/12 
 98   Verifying  : gcc-c++-4.4.7-23.el6.i686                                                                                                                                                                                   7/12 
 99   Verifying  : libstdc++-4.4.7-3.el6.i686                                                                                                                                                                                  8/12 
100   Verifying  : libgomp-4.4.7-3.el6.i686                                                                                                                                                                                    9/12 
101   Verifying  : cpp-4.4.7-3.el6.i686                                                                                                                                                                                       10/12 
102   Verifying  : libgcc-4.4.7-3.el6.i686                                                                                                                                                                                    11/12 
103   Verifying  : gcc-4.4.7-3.el6.i686                                                                                                                                                                                       12/12 
104 
105 Installed:
106   gcc-c++.i686 0:4.4.7-23.el6                                                                                                                                                                                                   
107 
108 Dependency Installed:
109   libstdc++-devel.i686 0:4.4.7-23.el6                                                                                                                                                                                           
110 
111 Dependency Updated:
112   cpp.i686 0:4.4.7-23.el6                   gcc.i686 0:4.4.7-23.el6                   libgcc.i686 0:4.4.7-23.el6                   libgomp.i686 0:4.4.7-23.el6                   libstdc++.i686 0:4.4.7-23.el6                  
113 
114 Complete!
115 [root@localhost package]#

2、将redis的源码包上传到linux系统。然后进行解压缩操作。

[root@localhost package]# tar -zxvf redis-3.0.0.tar.gz -C /home/hadoop/soft/

注意:c语言编译必须有MakeFile文件。没有的话自己创建,有的话直接编译即可。

3、编译,进入redis源码目录。执行make命令。然后进行编译操作。

  1 [root@localhost soft]# ls
  2 apache-tomcat-7.0.47  jdk1.7.0_55  redis-3.0.0  zookeeper-3.4.6
  3 [root@localhost soft]# cd redis-3.0.0/
  4 [root@localhost redis-3.0.0]# ls
  5 00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Makefile  MANIFESTO  README  redis.conf  runtest  runtest-cluster  runtest-sentinel  sentinel.conf  src  tests  utils
  6 [root@localhost redis-3.0.0]# make
  7 cd src && make all
  8 make[1]: Entering directory `/home/hadoop/soft/redis-3.0.0/src'
  9 rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
 10 (cd ../deps && make distclean)
 11 make[2]: Entering directory `/home/hadoop/soft/redis-3.0.0/deps'
 12 (cd hiredis && make clean) > /dev/null || true
 13 (cd linenoise && make clean) > /dev/null || true
 14 (cd lua && make clean) > /dev/null || true
 15 (cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
 16 (rm -f .make-*)
 17 make[2]: Leaving directory `/home/hadoop/soft/redis-3.0.0/deps'
 18 (rm -f .make-*)
 19 echo STD=-std=c99 -pedantic >> .make-settings
 20 echo WARN=-Wall -W >> .make-settings
 21 echo OPT=-O2 >> .make-settings
 22 echo MALLOC=jemalloc >> .make-settings
 23 echo CFLAGS= >> .make-settings
 24 echo LDFLAGS= >> .make-settings
 25 echo REDIS_CFLAGS= >> .make-settings
 26 echo REDIS_LDFLAGS= >> .make-settings
 27 echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -Wall -W -O2 -g -ggdb   -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
 28 echo PREV_FINAL_LDFLAGS=  -g -ggdb -rdynamic >> .make-settings
 29 (cd ../deps && make hiredis linenoise lua jemalloc)
 30 make[2]: Entering directory `/home/hadoop/soft/redis-3.0.0/deps'
 31 (cd hiredis && make clean) > /dev/null || true
 32 (cd linenoise && make clean) > /dev/null || true
 33 (cd lua && make clean) > /dev/null || true
 34 (cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
 35 (rm -f .make-*)
 36 (echo "" > .make-ldflags)
 37 (echo "" > .make-cflags)
 38 MAKE hiredis
 39 cd hiredis && make static
 40 make[3]: Entering directory `/home/hadoop/soft/redis-3.0.0/deps/hiredis'
 41 cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
 42 cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  hiredis.c
 43 cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  sds.c
 44 cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  async.c
 45 ar rcs libhiredis.a net.o hiredis.o sds.o async.o
 46 make[3]: Leaving directory `/home/hadoop/soft/redis-3.0.0/deps/hiredis'
 47 MAKE linenoise
 48 cd linenoise && make
 49 make[3]: Entering directory `/home/hadoop/soft/redis-3.0.0/deps/linenoise'
 50 cc  -Wall -Os -g  -c linenoise.c
 51 make[3]: Leaving directory `/home/hadoop/soft/redis-3.0.0/deps/linenoise'
 52 MAKE lua
 53 cd lua/src && make all CFLAGS="-O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL " MYLDFLAGS="" AR="ar rcu"
 54 make[3]: Entering directory `/home/hadoop/soft/redis-3.0.0/deps/lua/src'
 55 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lapi.o lapi.c
 56 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lcode.o lcode.c
 57 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o ldebug.o ldebug.c
 58 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o ldo.o ldo.c
 59 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o ldump.o ldump.c
 60 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lfunc.o lfunc.c
 61 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lgc.o lgc.c
 62 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o llex.o llex.c
 63 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lmem.o lmem.c
 64 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lobject.o lobject.c
 65 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lopcodes.o lopcodes.c
 66 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lparser.o lparser.c
 67 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lstate.o lstate.c
 68 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lstring.o lstring.c
 69 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o ltable.o ltable.c
 70 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o ltm.o ltm.c
 71 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lundump.o lundump.c
 72 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lvm.o lvm.c
 73 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lzio.o lzio.c
 74 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o strbuf.o strbuf.c
 75 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o fpconv.o fpconv.c
 76 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lauxlib.o lauxlib.c
 77 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lbaselib.o lbaselib.c
 78 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o ldblib.o ldblib.c
 79 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o liolib.o liolib.c
 80 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lmathlib.o lmathlib.c
 81 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o loslib.o loslib.c
 82 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o ltablib.o ltablib.c
 83 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lstrlib.o lstrlib.c
 84 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o loadlib.o loadlib.c
 85 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o linit.o linit.c
 86 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lua_cjson.o lua_cjson.c
 87 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lua_struct.o lua_struct.c
 88 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lua_cmsgpack.o lua_cmsgpack.c
 89 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lua_bit.o lua_bit.c
 90 ar rcu 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
 91 ranlib liblua.a
 92 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o lua.o lua.c
 93 cc -o lua  lua.o liblua.a -lm 
 94 liblua.a(loslib.o): In function `os_tmpname':
 95 loslib.c:(.text+0x46): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
 96 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o luac.o luac.c
 97 cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL    -c -o print.o print.c
 98 cc -o luac  luac.o print.o liblua.a -lm 
 99 make[3]: Leaving directory `/home/hadoop/soft/redis-3.0.0/deps/lua/src'
100 MAKE jemalloc
101 cd jemalloc && ./configure --with-jemalloc-prefix=je_ --enable-cc-silence CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS=""
102 checking for xsltproc... /usr/bin/xsltproc
103 checking for gcc... gcc
104 checking whether the C compiler works... yes
105 checking for C compiler default output file name... a.out
106 checking for suffix of executables... 
107 checking whether we are cross compiling... no
108 checking for suffix of object files... o
109 checking whether we are using the GNU C compiler... yes
110 checking whether gcc accepts -g... yes
111 checking for gcc option to accept ISO C89... none needed
112 checking how to run the C preprocessor... gcc -E
113 checking for grep that handles long lines and -e... /bin/grep
114 checking for egrep... /bin/grep -E
115 checking for ANSI C header files... yes
116 checking for sys/types.h... yes
117 checking for sys/stat.h... yes
118 checking for stdlib.h... yes
119 checking for string.h... yes
120 checking for memory.h... yes
121 checking for strings.h... yes
122 checking for inttypes.h... yes
123 checking for stdint.h... yes
124 checking for unistd.h... yes
125 checking whether byte ordering is bigendian... no
126 checking size of void *... 4
127 checking size of int... 4
128 checking size of long... 4
129 checking size of intmax_t... 8
130 checking build system type... i686-pc-linux-gnu
131 checking host system type... i686-pc-linux-gnu
132 checking whether pause instruction is compilable... yes
133 checking whether SSE2 intrinsics is compilable... no
134 checking for ar... ar
135 checking whether __attribute__ syntax is compilable... yes
136 checking whether compiler supports -fvisibility=hidden... yes
137 checking whether compiler supports -Werror... yes
138 checking whether tls_model attribute is compilable... yes
139 checking for a BSD-compatible install... /usr/bin/install -c
140 checking for ranlib... ranlib
141 checking for ld... /usr/bin/ld
142 checking for autoconf... false
143 checking for memalign... yes
144 checking for valloc... yes
145 checking configured backtracing method... N/A
146 checking for sbrk... yes
147 checking whether utrace(2) is compilable... no
148 checking whether valgrind is compilable... no
149 checking STATIC_PAGE_SHIFT... 12
150 checking pthread.h usability... yes
151 checking pthread.h presence... yes
152 checking for pthread.h... yes
153 checking for pthread_create in -lpthread... yes
154 checking for _malloc_thread_cleanup... no
155 checking for _pthread_mutex_init_calloc_cb... no
156 checking for TLS... yes
157 checking whether a program using ffsl is compilable... yes
158 checking whether atomic(9) is compilable... no
159 checking whether Darwin OSAtomic*() is compilable... no
160 checking whether to force 32-bit __sync_{add,sub}_and_fetch()... no
161 checking whether to force 64-bit __sync_{add,sub}_and_fetch()... no
162 checking whether Darwin OSSpin*() is compilable... no
163 checking for stdbool.h that conforms to C99... yes
164 checking for _Bool... yes
165 configure: creating ./config.status
166 config.status: creating Makefile
167 config.status: creating doc/html.xsl
168 config.status: creating doc/manpages.xsl
169 config.status: creating doc/jemalloc.xml
170 config.status: creating include/jemalloc/jemalloc_macros.h
171 config.status: creating include/jemalloc/jemalloc_protos.h
172 config.status: creating include/jemalloc/internal/jemalloc_internal.h
173 config.status: creating test/test.sh
174 config.status: creating test/include/test/jemalloc_test.h
175 config.status: creating config.stamp
176 config.status: creating bin/jemalloc.sh
177 config.status: creating include/jemalloc/jemalloc_defs.h
178 config.status: creating include/jemalloc/internal/jemalloc_internal_defs.h
179 config.status: creating test/include/test/jemalloc_test_defs.h
180 config.status: executing include/jemalloc/internal/private_namespace.h commands
181 config.status: executing include/jemalloc/internal/private_unnamespace.h commands
182 config.status: executing include/jemalloc/internal/public_symbols.txt commands
183 config.status: executing include/jemalloc/internal/public_namespace.h commands
184 config.status: executing include/jemalloc/internal/public_unnamespace.h commands
185 config.status: executing include/jemalloc/internal/size_classes.h commands
186 config.status: executing include/jemalloc/jemalloc_protos_jet.h commands
187 config.status: executing include/jemalloc/jemalloc_rename.h commands
188 config.status: executing include/jemalloc/jemalloc_mangle.h commands
189 config.status: executing include/jemalloc/jemalloc_mangle_jet.h commands
190 config.status: executing include/jemalloc/jemalloc.h commands
191 ===============================================================================
192 jemalloc version   : 3.6.0-0-g46c0af68bd248b04df75e4f92d5fb804c3d75340
193 library revision   : 1
194 
195 CC                 : gcc
196 CPPFLAGS           :  -D_GNU_SOURCE -D_REENTRANT
197 CFLAGS             : -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -fvisibility=hidden
198 LDFLAGS            : 
199 EXTRA_LDFLAGS      : 
200 LIBS               :  -lpthread
201 RPATH_EXTRA        : 
202 
203 XSLTPROC           : /usr/bin/xsltproc
204 XSLROOT            : 
205 
206 PREFIX             : /usr/local
207 BINDIR             : /usr/local/bin
208 INCLUDEDIR         : /usr/local/include
209 LIBDIR             : /usr/local/lib
210 DATADIR            : /usr/local/share
211 MANDIR             : /usr/local/share/man
212 
213 srcroot            : 
214 abs_srcroot        : /home/hadoop/soft/redis-3.0.0/deps/jemalloc/
215 objroot            : 
216 abs_objroot        : /home/hadoop/soft/redis-3.0.0/deps/jemalloc/
217 
218 JEMALLOC_PREFIX    : je_
219 JEMALLOC_PRIVATE_NAMESPACE
220                    : je_
221 install_suffix     : 
222 autogen            : 0
223 experimental       : 1
224 cc-silence         : 1
225 debug              : 0
226 code-coverage      : 0
227 stats              : 1
228 prof               : 0
229 prof-libunwind     : 0
230 prof-libgcc        : 0
231 prof-gcc           : 0
232 tcache             : 1
233 fill               : 1
234 utrace             : 0
235 valgrind           : 0
236 xmalloc            : 0
237 mremap             : 0
238 munmap             : 0
239 dss                : 0
240 lazy_lock          : 0
241 tls                : 1
242 ===============================================================================
243 cd jemalloc && make CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS="" lib/libjemalloc.a
244 make[3]: Entering directory `/home/hadoop/soft/redis-3.0.0/deps/jemalloc'
245 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/jemalloc.o src/jemalloc.c
246 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/arena.o src/arena.c
247 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/atomic.o src/atomic.c
248 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/base.o src/base.c
249 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/bitmap.o src/bitmap.c
250 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk.o src/chunk.c
251 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk_dss.o src/chunk_dss.c
252 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/chunk_mmap.o src/chunk_mmap.c
253 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ckh.o src/ckh.c
254 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/ctl.o src/ctl.c
255 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/extent.o src/extent.c
256 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/hash.o src/hash.c
257 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/huge.o src/huge.c
258 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mb.o src/mb.c
259 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/mutex.o src/mutex.c
260 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/prof.o src/prof.c
261 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/quarantine.o src/quarantine.c
262 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/rtree.o src/rtree.c
263 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/stats.o src/stats.c
264 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/tcache.o src/tcache.c
265 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/util.o src/util.c
266 gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops  -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -o src/tsd.o src/tsd.c
267 ar crus lib/libjemalloc.a src/jemalloc.o src/arena.o src/atomic.o src/base.o src/bitmap.o src/chunk.o src/chunk_dss.o src/chunk_mmap.o src/ckh.o src/ctl.o src/extent.o src/hash.o src/huge.o src/mb.o src/mutex.o src/prof.o src/quarantine.o src/rtree.o src/stats.o src/tcache.o src/util.o src/tsd.o
268 make[3]: Leaving directory `/home/hadoop/soft/redis-3.0.0/deps/jemalloc'
269 make[2]: Leaving directory `/home/hadoop/soft/redis-3.0.0/deps'
270     CC adlist.o
271     CC ae.o
272     CC anet.o
273 anet.c: In function ‘anetSockName’:
274 anet.c:605: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
275 anet.c:603: note: initialized from here
276 anet.c:609: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
277 anet.c:607: note: initialized from here
278 anet.c: In function ‘anetPeerToString’:
279 anet.c:566: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
280 anet.c:564: note: initialized from here
281 anet.c:570: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
282 anet.c:568: note: initialized from here
283 anet.c: In function ‘anetTcpAccept’:
284 anet.c:537: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
285 anet.c:535: note: initialized from here
286 anet.c:541: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
287 anet.c:539: note: initialized from here
288     CC dict.o
289     CC redis.o
290     CC sds.o
291     CC zmalloc.o
292     CC lzf_c.o
293     CC lzf_d.o
294     CC pqsort.o
295     CC zipmap.o
296     CC sha1.o
297     CC ziplist.o
298     CC release.o
299     CC networking.o
300     CC util.o
301     CC object.o
302     CC db.o
303 db.c: In function ‘scanGenericCommand’:
304 db.c:428: warning: ‘pat’ may be used uninitialized in this function
305 db.c:429: warning: ‘patlen’ may be used uninitialized in this function
306     CC replication.o
307     CC rdb.o
308     CC t_string.o
309     CC t_list.o
310     CC t_set.o
311     CC t_zset.o
312     CC t_hash.o
313     CC config.o
314     CC aof.o
315     CC pubsub.o
316     CC multi.o
317     CC debug.o
318     CC sort.o
319     CC intset.o
320     CC syncio.o
321     CC cluster.o
322     CC crc16.o
323     CC endianconv.o
324     CC slowlog.o
325     CC scripting.o
326     CC bio.o
327     CC rio.o
328     CC rand.o
329     CC memtest.o
330     CC crc64.o
331     CC bitops.o
332     CC sentinel.o
333     CC notify.o
334     CC setproctitle.o
335     CC blocked.o
336     CC hyperloglog.o
337     CC latency.o
338     CC sparkline.o
339     LINK redis-server
340     INSTALL redis-sentinel
341     CC redis-cli.o
342     LINK redis-cli
343     CC redis-benchmark.o
344     LINK redis-benchmark
345     CC redis-check-dump.o
346     LINK redis-check-dump
347     CC redis-check-aof.o
348     LINK redis-check-aof
349 
350 Hint: It's a good idea to run 'make test' ;)
351 
352 make[1]: Leaving directory `/home/hadoop/soft/redis-3.0.0/src'
353 [root@localhost redis-3.0.0]#

4、安装。make install PREFIX=/usr/local/redis
PREFIX参数指定redis的安装目录。一般软件安装到/usr目录下面。指定参数将redis安装到/usr/local目录下面。

 1 [root@localhost redis-3.0.0]# make install PREFIX=/usr/local/redis
 2 cd src && make install
 3 make[1]: Entering directory `/home/hadoop/soft/redis-3.0.0/src'
 4 
 5 Hint: It's a good idea to run 'make test' ;)
 6 
 7     INSTALL install
 8     INSTALL install
 9     INSTALL install
10     INSTALL install
11     INSTALL install
12 make[1]: Leaving directory `/home/hadoop/soft/redis-3.0.0/src'
13 [root@localhost redis-3.0.0]#

启动redis服务。

redis-server服务端,redis-cli客户端。
启动redis(前端启动模式,会占用一个终端,Port: 6379,一般使用后端启动模式,关闭前端启动模式ctrl+c):
[root@localhost bin]# ./redis-server

 1 # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
 2 # 是否在后台运行,默认是no不在后台运行,修改成了yes,在后台运行即可。
 3 daemonize yes
 4 
 5 后台运行启动命令:
 6 [root@localhost bin]# ./redis-server redis.conf
 7 
 8 查看是否后台运行redis:
 9 [root@localhost bin]# ps aux | grep redis
10 
11 连接redis服务:
12 [root@localhost bin]# ./redis-cli 
13 127.0.0.1:6379> 
14 
15 连接其他ip地址的redis如下所示:
16 [root@localhost bin]# ./redis-cli -h 192.168.110.140 -p 6379
17 192.168.110.140:6379> ping
18 PONG
19 192.168.110.140:6379>
20 
21 检测redis是否联通:
22 127.0.0.1:6379> ping
23 PONG

操作如下所示:

 1 [root@localhost bin]# ./redis-server 
 2 5638:C 25 Aug 03:32:58.331 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
 3 5638:M 25 Aug 03:32:58.332 * Increased maximum number of open files to 10032 (it was originally set to 1024).
 4 5638:M 25 Aug 03:32:58.339 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.
 5                 _._                                                  
 6            _.-``__ ''-._                                             
 7       _.-``    `.  `_.  ''-._           Redis 3.0.0 (00000000/0) 32 bit
 8   .-`` .-```.  ```\/    _.,_ ''-._                                   
 9  (    '      ,       .-`  | `,    )     Running in standalone mode
10  |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
11  |    `-._   `._    /     _.-'    |     PID: 5638
12   `-._    `-._  `-./  _.-'    _.-'                                   
13  |`-._`-._    `-.__.-'    _.-'_.-'|                                  
14  |    `-._`-._        _.-'_.-'    |           http://redis.io        
15   `-._    `-._`-.__.-'_.-'    _.-'                                   
16  |`-._`-._    `-.__.-'    _.-'_.-'|                                  
17  |    `-._`-._        _.-'_.-'    |                                  
18   `-._    `-._`-.__.-'_.-'    _.-'                                   
19       `-._    `-.__.-'    _.-'                                       
20           `-._        _.-'                                           
21               `-.__.-'                                               
22 
23 5638:M 25 Aug 03:32:58.348 # Server started, Redis version 3.0.0
24 5638:M 25 Aug 03:32:58.348 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. 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.
25 5638:M 25 Aug 03:32:58.349 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
26 5638:M 25 Aug 03:32:58.349 * The server is now ready to accept connections on port 6379
27 ^C5638:signal-handler (1566729356) Received SIGINT scheduling shutdown...
28 5638:M 25 Aug 03:35:56.243 # User requested shutdown...
29 5638:M 25 Aug 03:35:56.243 * Saving the final RDB snapshot before exiting.
30 5638:M 25 Aug 03:35:56.267 * DB saved on disk
31 5638:M 25 Aug 03:35:56.267 # Redis is now ready to exit, bye bye...
32 [root@localhost bin]# cp /home/hadoop/soft/redis-3.0.0/redis.conf ./
33 You have new mail in /var/spool/mail/root
34 [root@localhost bin]# ls
35 dump.rdb  redis-benchmark  redis-check-aof  redis-check-dump  redis-cli  redis.conf  redis-sentinel  redis-server
36 [root@localhost bin]# vim redis.conf 
37 [root@localhost bin]# ./redis-server redis.conf 
38 [root@localhost bin]# ps aux | grep redis
39 root      6378  0.2  0.1  33936  1708 ?        Ssl  03:40   0:00 ./redis-server *:6379    
40 root      6383  0.0  0.0   4356   728 pts/0    S+   03:40   0:00 grep redis
41 [root@localhost bin]# ./redis-cli 
42 127.0.0.1:6379> ping
43 PONG
44 127.0.0.1:6379>
 1 [root@localhost redis]# cd bin/
 2 [root@localhost bin]# ls
 3 dump.rdb  redis-benchmark  redis-check-aof  redis-check-dump  redis-cli  redis.conf  redis-sentinel  redis-server
 4 [root@localhost bin]# clear
 5 [root@localhost bin]# ls
 6 dump.rdb  redis-benchmark  redis-check-aof  redis-check-dump  redis-cli  redis.conf  redis-sentinel  redis-server
 7 [root@localhost bin]# ./redis-cli -h 192.168.110.140 -p 6379
 8 192.168.110.140:6379> ping
 9 PONG
10 192.168.110.140:6379>

修改时间:2019-10-16  16:11:33

1、Redis集群的搭建。
Redis集群中至少应该有三个节点。要保证集群的高可用,需要每个节点有一个备份机。

Redis集群至少需要6台服务器(三主三从,三从是备份机,保障高可用,redis槽的完整性)。

这里搭建伪分布式,可以使用一台虚拟机运行6个redis实例。需要修改redis的端口号7001-7006(记住关闭防火墙)。

注意:因为上面已经搭建好一个redis节点了,所以这里直接拷贝,在一台机器上面进行了模拟redis集群,记得删除dump.rdb,这个东西,它是一个快照,保存了那个redis节点的数据,这里是拷贝的,搭建集群,保证没有数据。

 1 [root@localhost local]# ls
 2 bin  etc  games  include  lib  libexec  redis  sbin  share  src
 3 [root@localhost local]# mkdir redis-cluster
 4 [root@localhost local]# ls
 5 bin  etc  games  include  lib  libexec  redis  redis-cluster  sbin  share  src
 6 [root@localhost local]# cp -r redis/bin/ redis-cluster/redis01
 7 [root@localhost local]# ls
 8 bin  etc  games  include  lib  libexec  redis  redis-cluster  sbin  share  src
 9 [root@localhost local]# cd redis-cluster/
10 [root@localhost redis-cluster]# ls
11 redis01
12 [root@localhost redis-cluster]# cd redis01/
13 [root@localhost redis01]# ls
14 dump.rdb  redis-benchmark  redis-check-aof  redis-check-dump  redis-cli  redis.conf  redis-sentinel  redis-server
15 [root@localhost redis01]# l
16 -bash: l: command not found
17 [root@localhost redis01]# ll
18 total 13896
19 -rw-r--r--. 1 root root      39 Aug 28 01:03 dump.rdb
20 -rwxr-xr-x. 1 root root 4168098 Aug 28 01:03 redis-benchmark
21 -rwxr-xr-x. 1 root root   16471 Aug 28 01:03 redis-check-aof
22 -rwxr-xr-x. 1 root root   37703 Aug 28 01:03 redis-check-dump
23 -rwxr-xr-x. 1 root root 4256876 Aug 28 01:03 redis-cli
24 -rw-r--r--. 1 root root   41404 Aug 28 01:03 redis.conf
25 lrwxrwxrwx. 1 root root      12 Aug 28 01:03 redis-sentinel -> redis-server
26 -rwxr-xr-x. 1 root root 5686857 Aug 28 01:03 redis-server
27 [root@localhost redis01]# rm -rf dump.rdb 
28 [root@localhost redis01]#

拷贝完毕以后开始修改端口号。搭建集群,要开启集群模式。将cluster-enabled yes修改为yes。

[root@localhost redis01]# vim redis.conf

1 port 7001
2 cluster-enabled yes

然后将复制的第一个节点redis01复制六个,分别为redis02、redis03、redis04、redis05、redis06搭建伪分布式集群。依次将redis02、redis03、redis04、redis05、redis06端口号修改为7002、7003、7004、7005、7006。

然后启动你的集群,记得将可以执行的权限加上哦。

 1 [root@localhost redis-cluster]# chmod 777 redis-cluster-start.sh 
 2 [root@localhost redis-cluster]# ls
 3 redis01  redis02  redis03  redis04  redis05  redis06  redis-cluster-start.sh
 4 [root@localhost redis-cluster]# ll
 5 total 28
 6 drwxr-xr-x. 2 root root 4096 Aug 28 01:09 redis01
 7 drwxr-xr-x. 2 root root 4096 Aug 28 01:12 redis02
 8 drwxr-xr-x. 2 root root 4096 Aug 28 01:12 redis03
 9 drwxr-xr-x. 2 root root 4096 Aug 28 01:12 redis04
10 drwxr-xr-x. 2 root root 4096 Aug 28 01:13 redis05
11 drwxr-xr-x. 2 root root 4096 Aug 28 01:13 redis06
12 -rwxrwxrwx. 1 root root  259 Aug 28 01:17 redis-cluster-start.sh
13 [root@localhost redis-cluster]# ./redis-cluster-start.sh 
14 [root@localhost redis-cluster]# ps aux | grep redis
15 root      2345  0.1  0.1  33936  1748 ?        Ssl  Aug27   0:29 ./redis-server *:6379    
16 root      2842  0.4  0.1  33936  1960 ?        Ssl  01:21   0:00 ./redis-server *:7001 [cluster]
17 root      2844  0.2  0.1  33936  1960 ?        Ssl  01:21   0:00 ./redis-server *:7002 [cluster]
18 root      2846  0.3  0.1  33936  1956 ?        Ssl  01:21   0:00 ./redis-server *:7003 [cluster]
19 root      2852  0.4  0.1  33936  1956 ?        Ssl  01:21   0:00 ./redis-server *:7004 [cluster]
20 root      2856  0.1  0.1  33936  1960 ?        Ssl  01:21   0:00 ./redis-server *:7005 [cluster]
21 root      2858  0.0  0.1  33936  1960 ?        Ssl  01:21   0:00 ./redis-server *:7006 [cluster]
22 root      2866  0.0  0.0   4356   728 pts/0    S+   01:21   0:00 grep redis
23 [root@localhost redis-cluster]#

 2、redis集群环境搭建。
实例都启动起来以后就可以开始搭建集群了。
ruby脚本语言,运行ruby需要ruby的运行环境,所以先安装ruby。使用ruby脚本搭建集群,需要ruby的运行环境。
安装ruby。
yum install ruby
yum install rubygems
安装ruby脚本运行使用的包。
gem install redis-3.0.0.gem

  1 [root@localhost package]# ls
  2 apache-tomcat-7.0.47.tar.gz  dubbo-admin-2.5.4.war  gnome-terminal.desktop  jdk-7u55-linux-i586.tar.gz  redis-3.0.0.gem  redis-3.0.0.tar.gz  solr-4.10.3.tgz.tgz  zookeeper-3.4.6.tar.gz
  3 [root@localhost package]# yum install ruby
  4 Loaded plugins: fastestmirror, refresh-packagekit, security
  5 Loading mirror speeds from cached hostfile
  6  * base: mirror.bit.edu.cn
  7  * extras: mirrors.tuna.tsinghua.edu.cn
  8  * updates: mirror.bit.edu.cn
  9 base                                                                                                              | 3.7 kB     00:00     
 10 extras                                                                                                            | 3.3 kB     00:00     
 11 updates                                                                                                           | 3.4 kB     00:00     
 12 Setting up Install Process
 13 Resolving Dependencies
 14 --> Running transaction check
 15 ---> Package ruby.i686 0:1.8.7.374-5.el6 will be installed
 16 --> Processing Dependency: ruby-libs = 1.8.7.374-5.el6 for package: ruby-1.8.7.374-5.el6.i686
 17 --> Processing Dependency: libruby.so.1.8 for package: ruby-1.8.7.374-5.el6.i686
 18 --> Running transaction check
 19 ---> Package ruby-libs.i686 0:1.8.7.374-5.el6 will be installed
 20 --> Processing Dependency: libssl.so.10(libssl.so.10) for package: ruby-libs-1.8.7.374-5.el6.i686
 21 --> Processing Dependency: libreadline.so.5 for package: ruby-libs-1.8.7.374-5.el6.i686
 22 --> Processing Dependency: libcrypto.so.10(libcrypto.so.10) for package: ruby-libs-1.8.7.374-5.el6.i686
 23 --> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.1_EC) for package: ruby-libs-1.8.7.374-5.el6.i686
 24 --> Running transaction check
 25 ---> Package compat-readline5.i686 0:5.2-17.1.el6 will be installed
 26 ---> Package openssl.i686 0:1.0.0-27.el6 will be updated
 27 ---> Package openssl.i686 0:1.0.1e-58.el6_10 will be an update
 28 --> Finished Dependency Resolution
 29 
 30 Dependencies Resolved
 31 
 32 =========================================================================================================================================
 33  Package                              Arch                     Version                                 Repository                   Size
 34 =========================================================================================================================================
 35 Installing:
 36  ruby                                 i686                     1.8.7.374-5.el6                         base                        538 k
 37 Installing for dependencies:
 38  compat-readline5                     i686                     5.2-17.1.el6                            base                        128 k
 39  ruby-libs                            i686                     1.8.7.374-5.el6                         base                        1.6 M
 40 Updating for dependencies:
 41  openssl                              i686                     1.0.1e-58.el6_10                        updates                     1.5 M
 42 
 43 Transaction Summary
 44 =========================================================================================================================================
 45 Install       3 Package(s)
 46 Upgrade       1 Package(s)
 47 
 48 Total download size: 3.8 M
 49 Is this ok [y/N]: y
 50 Downloading Packages:
 51 (1/4): compat-readline5-5.2-17.1.el6.i686.rpm                                                                                                                                                            | 128 kB     00:00     
 52 (2/4): openssl-1.0.1e-58.el6_10.i686.rpm                                                                                                                                                                 | 1.5 MB     00:00     
 53 (3/4): ruby-1.8.7.374-5.el6.i686.rpm                                                                                                                                                                     | 538 kB     00:00     
 54 (4/4): ruby-libs-1.8.7.374-5.el6.i686.rpm                                                                                                                                                                | 1.6 MB     00:01     
 55 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 56 Total                                                                                                                                                                                           1.6 MB/s | 3.8 MB     00:02     
 57 Running rpm_check_debug
 58 Running Transaction Test
 59 Transaction Test Succeeded
 60 Running Transaction
 61   Updating   : openssl-1.0.1e-58.el6_10.i686                                                                                                                                                                                1/5 
 62   Installing : compat-readline5-5.2-17.1.el6.i686                                                                                                                                                                           2/5 
 63   Installing : ruby-libs-1.8.7.374-5.el6.i686                                                                                                                                                                               3/5 
 64   Installing : ruby-1.8.7.374-5.el6.i686                                                                                                                                                                                    4/5 
 65   Cleanup    : openssl-1.0.0-27.el6.i686                                                                                                                                                                                    5/5 
 66   Verifying  : compat-readline5-5.2-17.1.el6.i686                                                                                                                                                                           1/5 
 67   Verifying  : openssl-1.0.1e-58.el6_10.i686                                                                                                                                                                                2/5 
 68   Verifying  : ruby-1.8.7.374-5.el6.i686                                                                                                                                                                                    3/5 
 69   Verifying  : ruby-libs-1.8.7.374-5.el6.i686                                                                                                                                                                               4/5 
 70   Verifying  : openssl-1.0.0-27.el6.i686                                                                                                                                                                                    5/5 
 71 
 72 Installed:
 73   ruby.i686 0:1.8.7.374-5.el6                                                                                                                                                                                                   
 74 
 75 Dependency Installed:
 76   compat-readline5.i686 0:5.2-17.1.el6                                                                             ruby-libs.i686 0:1.8.7.374-5.el6                                                                            
 77 
 78 Dependency Updated:
 79   openssl.i686 0:1.0.1e-58.el6_10                                                                                                                                                                                               
 80 
 81 Complete!
 82 [root@localhost package]# yum install rubygems
 83 Loaded plugins: fastestmirror, refresh-packagekit, security
 84 Loading mirror speeds from cached hostfile
 85  * base: mirror.bit.edu.cn
 86  * extras: mirrors.tuna.tsinghua.edu.cn
 87  * updates: mirror.bit.edu.cn
 88 Setting up Install Process
 89 Resolving Dependencies
 90 --> Running transaction check
 91 ---> Package rubygems.noarch 0:1.3.7-5.el6 will be installed
 92 --> Processing Dependency: ruby-rdoc for package: rubygems-1.3.7-5.el6.noarch
 93 --> Running transaction check
 94 ---> Package ruby-rdoc.i686 0:1.8.7.374-5.el6 will be installed
 95 --> Processing Dependency: ruby-irb = 1.8.7.374-5.el6 for package: ruby-rdoc-1.8.7.374-5.el6.i686
 96 --> Running transaction check
 97 ---> Package ruby-irb.i686 0:1.8.7.374-5.el6 will be installed
 98 --> Finished Dependency Resolution
 99 
100 Dependencies Resolved
101 
102 =========================================================================================================================================
103  Package                          Arch                          Version                                Repository                   Size
104 =========================================================================================================================================
105 Installing:
106  rubygems                         noarch                        1.3.7-5.el6                            base                        207 k
107 Installing for dependencies:
108  ruby-irb                         i686                          1.8.7.374-5.el6                        base                        318 k
109  ruby-rdoc                        i686                          1.8.7.374-5.el6                        base                        381 k
110 
111 Transaction Summary
112 =========================================================================================================================================
113 Install       3 Package(s)
114 
115 Total download size: 905 k
116 Installed size: 3.0 M
117 Is this ok [y/N]: y
118 Downloading Packages:
119 (1/3): ruby-irb-1.8.7.374-5.el6.i686.rpm                                                                          | 318 kB     00:00     
120 (2/3): ruby-rdoc-1.8.7.374-5.el6.i686.rpm                                                                         | 381 kB     00:01     
121 (3/3): rubygems-1.3.7-5.el6.noarch.rpm                                                                            | 207 kB     00:00     
122 -----------------------------------------------------------------------------------------------------------------------------------------
123 Total                                                                                                    359 kB/s | 905 kB     00:02     
124 Running rpm_check_debug
125 Running Transaction Test
126 Transaction Test Succeeded
127 Running Transaction
128   Installing : ruby-irb-1.8.7.374-5.el6.i686                                                                                         1/3 
129   Installing : ruby-rdoc-1.8.7.374-5.el6.i686                                                                                                                                                                               2/3 
130   Installing : rubygems-1.3.7-5.el6.noarch                                                                                                                                                                                  3/3 
131   Verifying  : ruby-rdoc-1.8.7.374-5.el6.i686                                                                                                                                                                               1/3 
132   Verifying  : rubygems-1.3.7-5.el6.noarch                                                                                                                                                                                  2/3 
133   Verifying  : ruby-irb-1.8.7.374-5.el6.i686                                                                                                                                                                                3/3 
134 
135 Installed:
136   rubygems.noarch 0:1.3.7-5.el6                                                                                                                                                                                                 
137 
138 Dependency Installed:
139   ruby-irb.i686 0:1.8.7.374-5.el6                                                                                ruby-rdoc.i686 0:1.8.7.374-5.el6                                                                               
140 
141 Complete!
142 [root@localhost package]# gem install redis-3.0.0.gem 
143 Successfully installed redis-3.0.0
144 1 gem installed
145 Installing ri documentation for redis-3.0.0...
146 Installing RDoc documentation for redis-3.0.0...
147 [root@localhost package]#

 ruby安装成功以后,就开始执行ruby的脚本文件。

 1 [root@localhost package]# cd /home/hadoop/soft/redis-3.0.0/
 2 [root@localhost redis-3.0.0]# ls
 3 00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Makefile  MANIFESTO  README  redis.conf  runtest  runtest-cluster  runtest-sentinel  sentinel.conf  src  tests  utils
 4 [root@localhost redis-3.0.0]# cd src/
 5 [root@localhost src]# ls
 6 adlist.c     anet.c       bitops.o   crc16.o  dict.o         intset.o   Makefile         notify.o  rand.o             redis-check-aof.c   redis-sentinel  rio.o           sha1.c          sparkline.h  t_set.o       ziplist.c
 7 adlist.h     anet.h       blocked.c  crc64.c  endianconv.c   latency.c  Makefile.dep     object.c  rdb.c              redis-check-aof.o   redis-server    scripting.c     sha1.h          sparkline.o  t_string.c    ziplist.h
 8 adlist.o     anet.o       blocked.o  crc64.h  endianconv.h   latency.h  memtest.c        object.o  rdb.h              redis-check-dump    redis-trib.rb   scripting.o     sha1.o          syncio.c     t_string.o    ziplist.o
 9 ae.c         aof.c        cluster.c  crc64.o  endianconv.o   latency.o  memtest.o        pqsort.c  rdb.o              redis-check-dump.c  release.c       sds.c           slowlog.c       syncio.o     t_zset.c      zipmap.c
10 ae_epoll.c   aof.o        cluster.h  db.c     fmacros.h      lzf_c.c    mkreleasehdr.sh  pqsort.h  redisassert.h      redis-check-dump.o  release.h       sds.h           slowlog.h       testhelp.h   t_zset.o      zipmap.h
11 ae_evport.c  asciilogo.h  cluster.o  db.o     help.h         lzf_c.o    multi.c          pqsort.o  redis-benchmark    redis-cli           release.o       sds.o           slowlog.o       t_hash.c     util.c        zipmap.o
12 ae.h         bio.c        config.c   debug.c  hyperloglog.c  lzf_d.c    multi.o          pubsub.c  redis-benchmark.c  redis-cli.c         replication.c   sentinel.c      solarisfixes.h  t_hash.o     util.h        zmalloc.c
13 ae_kqueue.c  bio.h        config.h   debug.o  hyperloglog.o  lzf_d.o    networking.c     pubsub.o  redis-benchmark.o  redis-cli.o         replication.o   sentinel.o      sort.c          t_list.c     util.o        zmalloc.h
14 ae.o         bio.o        config.o   dict.c   intset.c       lzf.h      networking.o     rand.c    redis.c            redis.h             rio.c           setproctitle.c  sort.o          t_list.o     valgrind.sup  zmalloc.o
15 ae_select.c  bitops.c     crc16.c    dict.h   intset.h       lzfP.h     notify.c         rand.h    redis-check-aof    redis.o             rio.h           setproctitle.o  sparkline.c     t_set.c      version.h
16 [root@localhost src]# cp *.rb /usr/local/redis-cluster/
17 [root@localhost src]# cd /usr/local/redis-cluster/
18 [root@localhost redis-cluster]# ls
19 redis01  redis02  redis03  redis04  redis05  redis06  redis-cluster-shutdown.sh  redis-cluster-start.sh  redis-trib.rb
20 [root@localhost redis-cluster]#

redis集群搭建详细步骤如下所示:

第一步,创建6个redis实例,每个实例运行在不同的端口。需要修改redis.conf配置文件。配置文件中还需要把cluster-enabled yes前的注释去掉。
第二步,启动每个redis实例。
第三步,使用ruby脚本搭建集群。执行下面的命令。
./redis-trib.rb create --replicas 1 192.168.110.140:7001 192.168.110.140:7002 192.168.110.140:7003 192.168.110.140:7004 192.168.110.140:7005 192.168.110.140:7006
创建关闭集群的脚本。vim redis-cluster-shutdown.sh

 1 [root@localhost redis-cluster]# cat redis-cluster-shutdown.sh 
 2 cd redis01
 3 ./redis-cli -p 7001 shutdown
 4 cd ..
 5 cd redis02
 6 ./redis-cli -p 7002 shutdown
 7 cd ..
 8 cd redis03
 9 ./redis-cli -p 7003 shutdown
10 cd ..
11 cd redis04
12 ./redis-cli -p 7004 shutdown
13 cd ..
14 cd redis05
15 ./redis-cli -p 7005 shutdown
16 cd ..
17 cd redis06
18 ./redis-cli -p 7006 shutdown
19 cd ..

 执行./redis-trib.rb create --replicas 1 192.168.110.140:7001 192.168.110.140:7002 192.168.110.140:7003 192.168.110.140:7004 192.168.110.140:7005 192.168.110.140:7006如下所示:

注意:记得启动你的6个redis实例哦。

 1 [root@localhost redis-cluster]# ./redis-trib.rb create --replicas 1 192.168.110.140:7001 192.168.110.140:7002 192.168.110.140:7003 192.168.110.140:7004 192.168.110.140:7005 192.168.110.140:7006
 2 >>> Creating cluster
 3 Connecting to node 192.168.110.140:7001: OK
 4 Connecting to node 192.168.110.140:7002: OK
 5 Connecting to node 192.168.110.140:7003: OK
 6 Connecting to node 192.168.110.140:7004: OK
 7 Connecting to node 192.168.110.140:7005: OK
 8 Connecting to node 192.168.110.140:7006: OK
 9 >>> Performing hash slots allocation on 6 nodes...
10 Using 3 masters:
11 192.168.110.140:7001
12 192.168.110.140:7002
13 192.168.110.140:7003
14 Adding replica 192.168.110.140:7004 to 192.168.110.140:7001
15 Adding replica 192.168.110.140:7005 to 192.168.110.140:7002
16 Adding replica 192.168.110.140:7006 to 192.168.110.140:7003
17 M: 68fe9475169a3542c126d9b19a7e60452e4eb009 192.168.110.140:7001
18    slots:0-5460 (5461 slots) master
19 M: 47b64edee869fa173574267e655515ac95fa8b01 192.168.110.140:7002
20    slots:5461-10922 (5462 slots) master
21 M: ff3813dec92ba0a9f333362e5fdc2c33a7d3c45e 192.168.110.140:7003
22    slots:10923-16383 (5461 slots) master
23 S: bb3946e5d3473fe20364b3f4bd5297e96ce0243f 192.168.110.140:7004
24    replicates 68fe9475169a3542c126d9b19a7e60452e4eb009
25 S: db2d6fd06b5a40723fe739eacc7e882fdf268f2c 192.168.110.140:7005
26    replicates 47b64edee869fa173574267e655515ac95fa8b01
27 S: dcfa84e8a9c53e364b7caa519b7d2bff40cdb1db 192.168.110.140:7006
28    replicates ff3813dec92ba0a9f333362e5fdc2c33a7d3c45e
29 Can I set the above configuration? (type 'yes' to accept): yes
30 >>> Nodes configuration updated
31 >>> Assign a different config epoch to each node
32 >>> Sending CLUSTER MEET messages to join the cluster
33 Waiting for the cluster to join.....
34 >>> Performing Cluster Check (using node 192.168.110.140:7001)
35 M: 68fe9475169a3542c126d9b19a7e60452e4eb009 192.168.110.140:7001
36    slots:0-5460 (5461 slots) master
37 M: 47b64edee869fa173574267e655515ac95fa8b01 192.168.110.140:7002
38    slots:5461-10922 (5462 slots) master
39 M: ff3813dec92ba0a9f333362e5fdc2c33a7d3c45e 192.168.110.140:7003
40    slots:10923-16383 (5461 slots) master
41 M: bb3946e5d3473fe20364b3f4bd5297e96ce0243f 192.168.110.140:7004
42    slots: (0 slots) master
43    replicates 68fe9475169a3542c126d9b19a7e60452e4eb009
44 M: db2d6fd06b5a40723fe739eacc7e882fdf268f2c 192.168.110.140:7005
45    slots: (0 slots) master
46    replicates 47b64edee869fa173574267e655515ac95fa8b01
47 M: dcfa84e8a9c53e364b7caa519b7d2bff40cdb1db 192.168.110.140:7006
48    slots: (0 slots) master
49    replicates ff3813dec92ba0a9f333362e5fdc2c33a7d3c45e
50 [OK] All nodes agree about slots configuration.
51 >>> Check for open slots...
52 >>> Check slots coverage...
53 [OK] All 16384 slots covered.
54 [root@localhost redis-cluster]#

集群的启动和停止,以及操作如下所示:

redis集群的配置如下所示:

 如上配置出现了一点问题。就是服务器操作是没有问题的,但是远程代码,连不上服务器,调整了一下bind的ip顺序解决了问题。bind 192.168.110.140 127.0.0.1

操作如下所示:

 1 [root@localhost ~]# cd /usr/local/
 2 [root@localhost local]# ls
 3 bin  etc  games  include  lib  libexec  redis  redis-cluster  sbin  share  src
 4 [root@localhost local]# cd redis-cluster/
 5 [root@localhost redis-cluster]# ls
 6 redis01  redis02  redis03  redis04  redis05  redis06  redis-cluster-shutdown.sh  redis-cluster-start.sh  redis-trib.rb
 7 [root@localhost redis-cluster]# ./redis-cluster-start.sh 
 8 [root@localhost redis-cluster]# ps -aux | grep redis
 9 Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
10 root      2347  0.2  0.2  33936  2140 ?        Ssl  05:07   0:00 ./redis-server 127.0.0.1:7001 [cluster]
11 root      2351  0.1  0.2  33936  2156 ?        Ssl  05:07   0:00 ./redis-server 127.0.0.1:7002 [cluster]
12 root      2355  0.3  0.2  33936  2156 ?        Ssl  05:07   0:00 ./redis-server 127.0.0.1:7003 [cluster]
13 root      2359  0.1  0.2  33936  2156 ?        Ssl  05:07   0:00 ./redis-server 127.0.0.1:7004 [cluster]
14 root      2363  0.2  0.2  33936  2148 ?        Ssl  05:07   0:00 ./redis-server 127.0.0.1:7005 [cluster]
15 root      2367  0.2  0.2  33936  2144 ?        Ssl  05:07   0:00 ./redis-server 127.0.0.1:7006 [cluster]
16 root      2375  0.0  0.0   4356   728 pts/0    S+   05:07   0:00 grep redis
17 [root@localhost redis-cluster]# redis01/redis-cli -p 7006 -c
18 127.0.0.1:7006> set key1 123
19 -> Redirected to slot [9189] located at 127.0.0.1:7002
20 OK
21 127.0.0.1:7002> set key2 123
22 -> Redirected to slot [4998] located at 127.0.0.1:7001
23 OK
24 127.0.0.1:7001> set key3 123
25 OK
26 127.0.0.1:7001> set key4 123
27 -> Redirected to slot [13120] located at 127.0.0.1:7003
28 OK
29 127.0.0.1:7003> exit
30 [root@localhost redis-cluster]# ./redis-cluster-shutdown.sh 
31 [root@localhost redis-cluster]# ps -aux | grep redis
32 Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
33 root      2390  0.0  0.0   4356   732 pts/0    S+   05:09   0:00 grep redis
34 [root@localhost redis-cluster]#

 查看集群的状态和信息:

 1 [root@localhost redis-cluster]# ./redis-cluster-start.sh 
 2 [root@localhost redis-cluster]# ps -aux | grep redis
 3 Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
 4 root      2407  0.5  0.2  33936  2128 ?        Ssl  05:11   0:00 ./redis-server 127.0.0.1:7001 [cluster]
 5 root      2409  0.0  0.2  33936  2132 ?        Ssl  05:11   0:00 ./redis-server 127.0.0.1:7002 [cluster]
 6 root      2411  0.0  0.2  33936  2132 ?        Ssl  05:11   0:00 ./redis-server 127.0.0.1:7003 [cluster]
 7 root      2417  0.0  0.2  33936  2116 ?        Ssl  05:11   0:00 ./redis-server 127.0.0.1:7004 [cluster]
 8 root      2423  0.0  0.2  33936  2104 ?        Ssl  05:11   0:00 ./redis-server 127.0.0.1:7005 [cluster]
 9 root      2427  0.0  0.2  33936  2108 ?        Ssl  05:11   0:00 ./redis-server 127.0.0.1:7006 [cluster]
10 root      2434  0.0  0.0   4356   732 pts/0    S+   05:11   0:00 grep redis
11 [root@localhost redis-cluster]# ls
12 redis01  redis02  redis03  redis04  redis05  redis06  redis-cluster-shutdown.sh  redis-cluster-start.sh  redis-trib.rb
13 [root@localhost redis-cluster]# redis01/redis-cli -p 7006 -c
14 127.0.0.1:7006> cluster info
15 cluster_state:ok
16 cluster_slots_assigned:16384
17 cluster_slots_ok:16384
18 cluster_slots_pfail:0
19 cluster_slots_fail:0
20 cluster_known_nodes:6
21 cluster_size:3
22 cluster_current_epoch:6
23 cluster_my_epoch:3
24 cluster_stats_messages_sent:63
25 cluster_stats_messages_received:63
26 127.0.0.1:7006> cluster nodes
27 68fe9475169a3542c126d9b19a7e60452e4eb009 127.0.0.1:7001 master - 0 1567080758341 1 connected 0-5460
28 47b64edee869fa173574267e655515ac95fa8b01 127.0.0.1:7002 master - 0 1567080757332 2 connected 5461-10922
29 ff3813dec92ba0a9f333362e5fdc2c33a7d3c45e 127.0.0.1:7003 master - 0 1567080760505 3 connected 10923-16383
30 dcfa84e8a9c53e364b7caa519b7d2bff40cdb1db 192.168.110.140:7006 myself,slave ff3813dec92ba0a9f333362e5fdc2c33a7d3c45e 0 0 6 connected
31 db2d6fd06b5a40723fe739eacc7e882fdf268f2c 127.0.0.1:7005 slave 47b64edee869fa173574267e655515ac95fa8b01 0 1567080761579 5 connected
32 bb3946e5d3473fe20364b3f4bd5297e96ce0243f 127.0.0.1:7004 slave 68fe9475169a3542c126d9b19a7e60452e4eb009 0 1567080759348 4 connected
33 127.0.0.1:7006>

注意1:redis作为缓存的时候,查询操作,如是方案,先去redis缓存中查询数据,如果redis缓存中存在就直接返回。否则去数据库中查询数据,如果有数据,接下来执行将数据放入到缓存中,切记redis作为缓存保存的都是字符串类型的,如果是集合类型,要记得转换为json串进行保存。还有就是切记,将执行操作redis的代码进行try/catch,捕获异常,避免干扰正常程序的执行哦。

注意2:redis作为缓存的时候,对数据库进行增删改操作的时候,方案一,暴力方案,可以将redis数据库里面的数据进行清空,然后再次查询的时候会将数据重新保存到redis中的哦,实现redis缓存的效果。方案二,精细化方案,删除数据库的时候,一点点删除redis里面的数据。假如redis保存的是集合,如果删除数据库中数据的话,对redis的实际操作是修改操作,将保存到redis中的json字符串找到(查询操作),然后修改redis中指定的json(修改),然后再放入到redis中,完成redis和数据库的同步。
即a、删除数据中的数据。b、判断redis中是否有缓存数据。c、如果有缓存数据,修改缓存数据即可。

待续......

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!