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./
[hadoop@slaver1 redis-3.2.]$ ls
-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.]$ make
cd src && make all
make[]: Entering directory `/home/hadoop/soft/redis-3.2./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[]: Entering directory `/home/hadoop/soft/redis-3.2./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[]: Leaving directory `/home/hadoop/soft/redis-3.2./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[]: Entering directory `/home/hadoop/soft/redis-3.2./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[]: Entering directory `/home/hadoop/soft/redis-3.2./deps/hiredis'
gcc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
make[]: gcc: Command not found
make[]: *** [net.o] Error
make[]: Leaving directory `/home/hadoop/soft/redis-3.2./deps/hiredis'
make[]: *** [hiredis] Error
make[]: Leaving directory `/home/hadoop/soft/redis-3.2./deps'
make[]: [persist-settings] Error (ignored)
CC adlist.o
/bin/sh: cc: command not found
make[]: *** [adlist.o] Error
make[]: Leaving directory `/home/hadoop/soft/redis-3.2./src'
make: *** [all] Error
[hadoop@slaver1 redis-3.2.]$ make install
cd src && make install
make[]: Entering directory `/home/hadoop/soft/redis-3.2./src'
CC adlist.o
/bin/sh: cc: command not found
make[]: *** [adlist.o] Error
make[]: Leaving directory `/home/hadoop/soft/redis-3.2./src'
make: *** [install] Error
[hadoop@slaver1 redis-3.2.]$ ls
-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.]$ cd ..
[hadoop@slaver1 soft]$ ls
apache-maven-3.5. flume-1.5.-cdh5.3.6-bin kafka_2.9.2-0.8. sqoop-1.4.-cdh5.3.6
apache-tomcat-7.0. hadoop-2.5.-cdh5.3.6 oozie-4.0.-cdh5.3.6 zookeeper-3.4.-cdh5.3.6
azkaban hbase-0.98.-cdh5.3.6 redis-3.2.
eclipse hive-0.13.-cdh5.3.6 scala-2.11.
export jdk1..0_79 spark-1.5.-bin-hadoop2.
[hadoop@slaver1 soft]$ cd redis-3.2./
[hadoop@slaver1 redis-3.2.]$ ls
-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.]$ make
cd src && make all
make[]: Entering directory `/home/hadoop/soft/redis-3.2./src'
CC adlist.o
/bin/sh: cc: command not found
make[]: *** [adlist.o] Error
make[]: Leaving directory `/home/hadoop/soft/redis-3.2./src'
make: *** [all] Error
[hadoop@slaver1 redis-3.2.]$

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

[hadoop@slaver1 package]$ mv redis-3.2. /usr/local/redis
mv: cannot move `redis-3.2.' 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..tgz
azkaban-executor-server-2.5..tar.gz redis-3.2.
azkaban-sql-script-2.5..tar.gz redis-3.2..tar.gz
azkaban-web-server-2.5..tar.gz slf4j-1.7.
greenplum-db-4.3.8.2-build--RHEL5-x86_64.7z slf4j-1.7..zip
greenplum-db-4.3.8.2-build--RHEL5-x86_64.zip
[root@slaver1 package]# ll
total
-rw-r--r-- root root Jun : all_host
-rwxrw-rw-. hadoop hadoop Oct azkaban-executor-server-2.5..tar.gz
-rwxrw-rw-. hadoop hadoop Oct azkaban-sql-script-2.5..tar.gz
-rwxrw-rw-. hadoop hadoop Oct azkaban-web-server-2.5..tar.gz
-rw-rw-r--. hadoop hadoop Jun : greenplum-db-4.3.8.2-build--RHEL5-x86_64.7z
-rw-rw-r--. hadoop hadoop Jun : greenplum-db-4.3.8.2-build--RHEL5-x86_64.zip
-rw-rw-r--. hadoop hadoop Apr : kafka_2.9.2-0.8..tgz
drwxrwxr-x hadoop hadoop Oct redis-3.2.
-rw-rw-r-- hadoop hadoop Oct redis-3.2..tar.gz
drwxrwxrwx. hadoop hadoop Feb slf4j-1.7.
-rw-rw-r--. hadoop hadoop Apr : slf4j-1.7..zip
[root@slaver1 package]# mv redis-3.2. /usr/local/redis
[root@slaver1 package]# ls
all_host greenplum-db-4.3.8.2-build--RHEL5-x86_64.7z slf4j-1.7.
azkaban-executor-server-2.5..tar.gz greenplum-db-4.3.8.2-build--RHEL5-x86_64.zip slf4j-1.7..zip
azkaban-sql-script-2.5..tar.gz kafka_2.9.2-0.8..tgz
azkaban-web-server-2.5..tar.gz redis-3.2..tar.gz
[root@slaver1 package]# cd /usr/local/redis/
[root@slaver1 redis]# ls
-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[]: 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[]: 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[]: 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[]: 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[]: 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[]: Leaving directory `/usr/local/redis/deps/hiredis'
MAKE linenoise
cd linenoise && make
make[]: Entering directory `/usr/local/redis/deps/linenoise'
cc -Wall -Os -g -c linenoise.c
make[]: 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[]: 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:: 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[]: Leaving directory `/usr/local/redis/deps/lua/src'
MAKE geohash-int
cd geohash-int && make
make[]: Entering directory `/usr/local/redis/deps/geohash-int'
cc -Wall -O2 -g -c geohash.c
cc -Wall -O2 -g -c geohash_helper.c
make[]: Leaving directory `/usr/local/redis/deps/geohash-int'
MAKE jemalloc
cd jemalloc && ./configure --with-lg-quantum= --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 *...
checking size of int...
checking size of long...
checking size of intmax_t...
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() is compilable... no
checking whether valgrind is compilable... no
checking whether a program using __builtin_ffsl is compilable... yes
checking LG_PAGE...
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() is compilable... no
checking whether Darwin OSAtomic*() is compilable... no
checking whether madvise() is compilable... yes
checking whether to force -bit __sync_{add,sub}_and_fetch()... no
checking whether to force -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.--ge9192eacf8935e29fc62fddc2701f7942b1cc02c
library revision : CONFIG : --with-lg-quantum= --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 :
cc-silence :
debug :
code-coverage :
stats :
prof :
prof-libunwind :
prof-libgcc :
prof-gcc :
tcache :
fill :
utrace :
valgrind :
xmalloc :
munmap :
lazy_lock :
tls :
cache-oblivious :
===============================================================================
cd jemalloc && make CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS="" lib/libjemalloc.a
make[]: 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[]: Leaving directory `/usr/local/redis/deps/jemalloc'
make[]: Leaving directory `/usr/local/redis/deps'
CC adlist.o
CC quicklist.o
CC ae.o
In file included from ae.c::
ae_epoll.c: In function ‘aeApiAddEvent’:
ae_epoll.c:: warning: missing initializer
ae_epoll.c:: warning: (near initialization for ‘ee.data’)
ae_epoll.c: In function ‘aeApiDelEvent’:
ae_epoll.c:: warning: missing initializer
ae_epoll.c:: warning: (near initialization for ‘ee.data’)
CC anet.o
anet.c: In function ‘anetSockName’:
anet.c:: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:: note: initialized from here
anet.c:: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:: note: initialized from here
anet.c: In function ‘anetPeerToString’:
anet.c:: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:: note: initialized from here
anet.c:: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:: note: initialized from here
anet.c: In function ‘anetTcpAccept’:
anet.c:: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:: note: initialized from here
anet.c:: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:: 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[]: Leaving directory `/usr/local/redis/src'
[root@slaver1 redis]#

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

[root@slaver1 redis]# make install
cd src && make install
make[]: 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[]: Leaving directory `/usr/local/redis/src'
[root@slaver1 redis]# make install
cd src && make install
make[]: 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[]: Leaving directory `/usr/local/redis/src'
[root@slaver1 redis]# ls
-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
-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
-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

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

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

 [root@localhost package]# yum install gcc-c++
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
base | 3.7 kB :
extras | 3.3 kB :
updates | 3.4 kB :
updates/primary_db | 5.5 MB :
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.i686 :4.4.-.el6 will be installed
--> Processing Dependency: libstdc++-devel = 4.4.-.el6 for package: gcc-c++-4.4.-.el6.i686
--> Processing Dependency: libstdc++ = 4.4.-.el6 for package: gcc-c++-4.4.-.el6.i686
--> Processing Dependency: gcc = 4.4.-.el6 for package: gcc-c++-4.4.-.el6.i686
--> Running transaction check
---> Package gcc.i686 :4.4.-.el6 will be updated
---> Package gcc.i686 :4.4.-.el6 will be an update
--> Processing Dependency: libgomp = 4.4.-.el6 for package: gcc-4.4.-.el6.i686
--> Processing Dependency: cpp = 4.4.-.el6 for package: gcc-4.4.-.el6.i686
--> Processing Dependency: libgcc >= 4.4.-.el6 for package: gcc-4.4.-.el6.i686
---> Package libstdc++.i686 :4.4.-.el6 will be updated
---> Package libstdc++.i686 :4.4.-.el6 will be an update
---> Package libstdc++-devel.i686 :4.4.-.el6 will be installed
--> Running transaction check
---> Package cpp.i686 :4.4.-.el6 will be updated
---> Package cpp.i686 :4.4.-.el6 will be an update
---> Package libgcc.i686 :4.4.-.el6 will be updated
---> Package libgcc.i686 :4.4.-.el6 will be an update
---> Package libgomp.i686 :4.4.-.el6 will be updated
---> Package libgomp.i686 :4.4.-.el6 will be an update
--> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================================================================================================
Installing:
gcc-c++ i686 4.4.-.el6 base 4.3 M
Installing for dependencies:
libstdc++-devel i686 4.4.-.el6 base 1.6 M
Updating for dependencies:
cpp i686 4.4.-.el6 base 3.4 M
gcc i686 4.4.-.el6 base 8.2 M
libgcc i686 4.4.-.el6 base k
libgomp i686 4.4.-.el6 base k
libstdc++ i686 4.4.-.el6 base k Transaction Summary
================================================================================================================================================================================================================================
Install Package(s)
Upgrade Package(s) Total download size: M
Is this ok [y/N]: y
Downloading Packages:
(/): cpp-4.4.-.el6.i686.rpm | 3.4 MB :
(/): gcc-4.4.-.el6.i686.rpm | 8.2 MB :
(/): gcc-c++-4.4.-.el6.i686.rpm | 4.3 MB :
(/): libgcc-4.4.-.el6.i686.rpm | kB :
(/): libgomp-4.4.-.el6.i686.rpm | kB :
(/): libstdc++-4.4.-.el6.i686.rpm | kB :
(/): libstdc++-devel-4.4.-.el6.i686.rpm | 1.6 MB :
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 2.0 MB/s | MB :
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS- Key (CentOS Official Signing Key) <centos--key@centos.org>
Package: centos-release--.el6.centos..i686 (@anaconda-CentOS-.i386/6.4)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : libgcc-4.4.-.el6.i686 /
Updating : libstdc++-4.4.-.el6.i686 /
Installing : libstdc++-devel-4.4.-.el6.i686 /
Updating : libgomp-4.4.-.el6.i686 /
Updating : cpp-4.4.-.el6.i686 /
Updating : gcc-4.4.-.el6.i686 /
Installing : gcc-c++-4.4.-.el6.i686 /
Cleanup : gcc-4.4.-.el6.i686 /
Cleanup : libstdc++-4.4.-.el6.i686 /
Cleanup : libgcc-4.4.-.el6.i686 /
Cleanup : cpp-4.4.-.el6.i686 /
Cleanup : libgomp-4.4.-.el6.i686 /
Verifying : libgcc-4.4.-.el6.i686 /
Verifying : cpp-4.4.-.el6.i686 /
Verifying : libgomp-4.4.-.el6.i686 /
Verifying : libstdc++-4.4.-.el6.i686 /
Verifying : libstdc++-devel-4.4.-.el6.i686 /
Verifying : gcc-4.4.-.el6.i686 /
Verifying : gcc-c++-4.4.-.el6.i686 /
Verifying : libstdc++-4.4.-.el6.i686 /
Verifying : libgomp-4.4.-.el6.i686 /
Verifying : cpp-4.4.-.el6.i686 /
Verifying : libgcc-4.4.-.el6.i686 /
Verifying : gcc-4.4.-.el6.i686 / Installed:
gcc-c++.i686 :4.4.-.el6 Dependency Installed:
libstdc++-devel.i686 :4.4.-.el6 Dependency Updated:
cpp.i686 :4.4.-.el6 gcc.i686 :4.4.-.el6 libgcc.i686 :4.4.-.el6 libgomp.i686 :4.4.-.el6 libstdc++.i686 :4.4.-.el6 Complete!
[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命令。然后进行编译操作。

 [root@localhost soft]# ls
apache-tomcat-7.0. jdk1..0_55 redis-3.0. zookeeper-3.4.
[root@localhost soft]# cd redis-3.0./
[root@localhost redis-3.0.]# ls
-RELEASENOTES BUGS CONTRIBUTING COPYING deps INSTALL Makefile MANIFESTO README redis.conf runtest runtest-cluster runtest-sentinel sentinel.conf src tests utils
[root@localhost redis-3.0.]# make
cd src && make all
make[]: Entering directory `/home/hadoop/soft/redis-3.0./src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[]: Entering directory `/home/hadoop/soft/redis-3.0./deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[]: Leaving directory `/home/hadoop/soft/redis-3.0./deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic >> .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 -Wall -W -O2 -g -ggdb -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 jemalloc)
make[]: Entering directory `/home/hadoop/soft/redis-3.0./deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-ldflags)
(echo "" > .make-cflags)
MAKE hiredis
cd hiredis && make static
make[]: Entering directory `/home/hadoop/soft/redis-3.0./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[]: Leaving directory `/home/hadoop/soft/redis-3.0./deps/hiredis'
MAKE linenoise
cd linenoise && make
make[]: Entering directory `/home/hadoop/soft/redis-3.0./deps/linenoise'
cc -Wall -Os -g -c linenoise.c
make[]: Leaving directory `/home/hadoop/soft/redis-3.0./deps/linenoise'
MAKE lua
cd lua/src && make all CFLAGS="-O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL " MYLDFLAGS="" AR="ar rcu"
make[]: Entering directory `/home/hadoop/soft/redis-3.0./deps/lua/src'
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lapi.o lapi.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lcode.o lcode.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o ldebug.o ldebug.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o ldo.o ldo.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o ldump.o ldump.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lfunc.o lfunc.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lgc.o lgc.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o llex.o llex.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lmem.o lmem.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lobject.o lobject.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lopcodes.o lopcodes.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lparser.o lparser.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lstate.o lstate.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lstring.o lstring.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o ltable.o ltable.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o ltm.o ltm.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lundump.o lundump.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lvm.o lvm.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lzio.o lzio.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o strbuf.o strbuf.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o fpconv.o fpconv.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lauxlib.o lauxlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lbaselib.o lbaselib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o ldblib.o ldblib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o liolib.o liolib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lmathlib.o lmathlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o loslib.o loslib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o ltablib.o ltablib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lstrlib.o lstrlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o loadlib.o loadlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o linit.o linit.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lua_cjson.o lua_cjson.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lua_struct.o lua_struct.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o lua_cmsgpack.o lua_cmsgpack.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -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 -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+0x46): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o luac.o luac.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -c -o print.o print.c
cc -o luac luac.o print.o liblua.a -lm
make[]: Leaving directory `/home/hadoop/soft/redis-3.0./deps/lua/src'
MAKE jemalloc
cd jemalloc && ./configure --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 *...
checking size of int...
checking size of long...
checking size of intmax_t...
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking whether pause instruction is compilable... yes
checking whether SSE2 intrinsics is compilable... no
checking for ar... ar
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 for a BSD-compatible install... /usr/bin/install -c
checking for ranlib... ranlib
checking for ld... /usr/bin/ld
checking for autoconf... false
checking for memalign... yes
checking for valloc... yes
checking configured backtracing method... N/A
checking for sbrk... yes
checking whether utrace() is compilable... no
checking whether valgrind is compilable... no
checking STATIC_PAGE_SHIFT...
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for pthread_create in -lpthread... yes
checking for _malloc_thread_cleanup... no
checking for _pthread_mutex_init_calloc_cb... no
checking for TLS... yes
checking whether a program using ffsl is compilable... yes
checking whether atomic() is compilable... no
checking whether Darwin OSAtomic*() is compilable... no
checking whether to force -bit __sync_{add,sub}_and_fetch()... no
checking whether to force -bit __sync_{add,sub}_and_fetch()... no
checking whether Darwin OSSpin*() is compilable... no
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
configure: creating ./config.status
config.status: creating Makefile
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/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.sh
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 : 3.6.--g46c0af68bd248b04df75e4f92d5fb804c3d75340
library revision : CC : gcc
CPPFLAGS : -D_GNU_SOURCE -D_REENTRANT
CFLAGS : -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -fvisibility=hidden
LDFLAGS :
EXTRA_LDFLAGS :
LIBS : -lpthread
RPATH_EXTRA : XSLTPROC : /usr/bin/xsltproc
XSLROOT : PREFIX : /usr/local
BINDIR : /usr/local/bin
INCLUDEDIR : /usr/local/include
LIBDIR : /usr/local/lib
DATADIR : /usr/local/share
MANDIR : /usr/local/share/man srcroot :
abs_srcroot : /home/hadoop/soft/redis-3.0./deps/jemalloc/
objroot :
abs_objroot : /home/hadoop/soft/redis-3.0./deps/jemalloc/ JEMALLOC_PREFIX : je_
JEMALLOC_PRIVATE_NAMESPACE
: je_
install_suffix :
autogen :
experimental :
cc-silence :
debug :
code-coverage :
stats :
prof :
prof-libunwind :
prof-libgcc :
prof-gcc :
tcache :
fill :
utrace :
valgrind :
xmalloc :
mremap :
munmap :
dss :
lazy_lock :
tls :
===============================================================================
cd jemalloc && make CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS="" lib/libjemalloc.a
make[]: Entering directory `/home/hadoop/soft/redis-3.0./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/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/prof.o src/quarantine.o src/rtree.o src/stats.o src/tcache.o src/util.o src/tsd.o
make[]: Leaving directory `/home/hadoop/soft/redis-3.0./deps/jemalloc'
make[]: Leaving directory `/home/hadoop/soft/redis-3.0./deps'
CC adlist.o
CC ae.o
CC anet.o
anet.c: In function ‘anetSockName’:
anet.c:: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:: note: initialized from here
anet.c:: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:: note: initialized from here
anet.c: In function ‘anetPeerToString’:
anet.c:: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:: note: initialized from here
anet.c:: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:: note: initialized from here
anet.c: In function ‘anetTcpAccept’:
anet.c:: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:: note: initialized from here
anet.c:: warning: dereferencing pointer ‘s’ does break strict-aliasing rules
anet.c:: note: initialized from here
CC dict.o
CC redis.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
db.c: In function ‘scanGenericCommand’:
db.c:: warning: ‘pat’ may be used uninitialized in this function
db.c:: warning: ‘patlen’ may be used uninitialized in this function
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
LINK redis-server
INSTALL redis-sentinel
CC redis-cli.o
LINK redis-cli
CC redis-benchmark.o
LINK redis-benchmark
CC redis-check-dump.o
LINK redis-check-dump
CC redis-check-aof.o
LINK redis-check-aof Hint: It's a good idea to run 'make test' ;) make[]: Leaving directory `/home/hadoop/soft/redis-3.0./src'
[root@localhost redis-3.0.]#

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

 [root@localhost redis-3.0.]# make install PREFIX=/usr/local/redis
cd src && make install
make[]: Entering directory `/home/hadoop/soft/redis-3.0./src' Hint: It's a good idea to run 'make test' ;) INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
make[]: Leaving directory `/home/hadoop/soft/redis-3.0./src'
[root@localhost redis-3.0.]#

启动redis服务。

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

 # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
# 是否在后台运行,默认是no不在后台运行,修改成了yes,在后台运行即可。
daemonize yes 后台运行启动命令:
[root@localhost bin]# ./redis-server redis.conf 查看是否后台运行redis:
[root@localhost bin]# ps aux | grep redis 连接redis服务:
[root@localhost bin]# ./redis-cli
127.0.0.1:> 连接其他ip地址的redis如下所示:
[root@localhost bin]# ./redis-cli -h 192.168.110.140 -p
192.168.110.140:> ping
PONG
192.168.110.140:> 检测redis是否联通:
127.0.0.1:> ping
PONG

操作如下所示:

 [root@localhost bin]# ./redis-server
:C Aug ::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
:M Aug ::58.332 * Increased maximum number of open files to (it was originally set to ).
:M Aug ::58.339 # Warning: bit instance detected but no memory limit set. Setting GB maxmemory limit with 'noeviction' policy now.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0. (/) bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port:
| `-._ `._ / _.-' | PID: 5638
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-' :M Aug ::58.348 # Server started, Redis version 3.0.
:M Aug ::58.348 # WARNING overcommit_memory is set to ! 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.
:M Aug ::58.349 # WARNING: The TCP backlog setting of cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of .
:M Aug ::58.349 * The server is now ready to accept connections on port
^C5638:signal-handler () Received SIGINT scheduling shutdown...
:M Aug ::56.243 # User requested shutdown...
:M Aug ::56.243 * Saving the final RDB snapshot before exiting.
:M Aug ::56.267 * DB saved on disk
:M Aug ::56.267 # Redis is now ready to exit, bye bye...
[root@localhost bin]# cp /home/hadoop/soft/redis-3.0./redis.conf ./
You have new mail in /var/spool/mail/root
[root@localhost bin]# ls
dump.rdb redis-benchmark redis-check-aof redis-check-dump redis-cli redis.conf redis-sentinel redis-server
[root@localhost bin]# vim redis.conf
[root@localhost bin]# ./redis-server redis.conf
[root@localhost bin]# ps aux | grep redis
root 0.2 0.1 ? Ssl : : ./redis-server *:
root 0.0 0.0 pts/ S+ : : grep redis
[root@localhost bin]# ./redis-cli
127.0.0.1:> ping
PONG
127.0.0.1:>
 [root@localhost redis]# cd bin/
[root@localhost bin]# ls
dump.rdb redis-benchmark redis-check-aof redis-check-dump redis-cli redis.conf redis-sentinel redis-server
[root@localhost bin]# clear
[root@localhost bin]# ls
dump.rdb redis-benchmark redis-check-aof redis-check-dump redis-cli redis.conf redis-sentinel redis-server
[root@localhost bin]# ./redis-cli -h 192.168.110.140 -p
192.168.110.140:> ping
PONG
192.168.110.140:>

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

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

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

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

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

 [root@localhost local]# ls
bin etc games include lib libexec redis sbin share src
[root@localhost local]# mkdir redis-cluster
[root@localhost local]# ls
bin etc games include lib libexec redis redis-cluster sbin share src
[root@localhost local]# cp -r redis/bin/ redis-cluster/redis01
[root@localhost local]# ls
bin etc games include lib libexec redis redis-cluster sbin share src
[root@localhost local]# cd redis-cluster/
[root@localhost redis-cluster]# ls
redis01
[root@localhost redis-cluster]# cd redis01/
[root@localhost redis01]# ls
dump.rdb redis-benchmark redis-check-aof redis-check-dump redis-cli redis.conf redis-sentinel redis-server
[root@localhost redis01]# l
-bash: l: command not found
[root@localhost redis01]# ll
total
-rw-r--r--. root root Aug : dump.rdb
-rwxr-xr-x. root root Aug : redis-benchmark
-rwxr-xr-x. root root Aug : redis-check-aof
-rwxr-xr-x. root root Aug : redis-check-dump
-rwxr-xr-x. root root Aug : redis-cli
-rw-r--r--. root root Aug : redis.conf
lrwxrwxrwx. root root Aug : redis-sentinel -> redis-server
-rwxr-xr-x. root root Aug : redis-server
[root@localhost redis01]# rm -rf dump.rdb
[root@localhost redis01]#

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

[root@localhost redis01]# vim redis.conf

 port
cluster-enabled yes

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

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

 [root@localhost redis-cluster]# chmod  redis-cluster-start.sh
[root@localhost redis-cluster]# ls
redis01 redis02 redis03 redis04 redis05 redis06 redis-cluster-start.sh
[root@localhost redis-cluster]# ll
total
drwxr-xr-x. root root Aug : redis01
drwxr-xr-x. root root Aug : redis02
drwxr-xr-x. root root Aug : redis03
drwxr-xr-x. root root Aug : redis04
drwxr-xr-x. root root Aug : redis05
drwxr-xr-x. root root Aug : redis06
-rwxrwxrwx. root root Aug : redis-cluster-start.sh
[root@localhost redis-cluster]# ./redis-cluster-start.sh
[root@localhost redis-cluster]# ps aux | grep redis
root 0.1 0.1 ? Ssl Aug27 : ./redis-server *:
root 0.4 0.1 ? Ssl : : ./redis-server *: [cluster]
root 0.2 0.1 ? Ssl : : ./redis-server *: [cluster]
root 0.3 0.1 ? Ssl : : ./redis-server *: [cluster]
root 0.4 0.1 ? Ssl : : ./redis-server *: [cluster]
root 0.1 0.1 ? Ssl : : ./redis-server *: [cluster]
root 0.0 0.1 ? Ssl : : ./redis-server *: [cluster]
root 0.0 0.0 pts/ S+ : : grep redis
[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

 [root@localhost package]# ls
apache-tomcat-7.0..tar.gz dubbo-admin-2.5..war gnome-terminal.desktop jdk-7u55-linux-i586.tar.gz redis-3.0..gem redis-3.0..tar.gz solr-4.10..tgz.tgz zookeeper-3.4..tar.gz
[root@localhost package]# yum install ruby
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirror.bit.edu.cn
base | 3.7 kB :
extras | 3.3 kB :
updates | 3.4 kB :
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ruby.i686 :1.8.7.374-.el6 will be installed
--> Processing Dependency: ruby-libs = 1.8.7.374-.el6 for package: ruby-1.8.7.374-.el6.i686
--> Processing Dependency: libruby.so.1.8 for package: ruby-1.8.7.374-.el6.i686
--> Running transaction check
---> Package ruby-libs.i686 :1.8.7.374-.el6 will be installed
--> Processing Dependency: libssl.so.(libssl.so.) for package: ruby-libs-1.8.7.374-.el6.i686
--> Processing Dependency: libreadline.so. for package: ruby-libs-1.8.7.374-.el6.i686
--> Processing Dependency: libcrypto.so.(libcrypto.so.) for package: ruby-libs-1.8.7.374-.el6.i686
--> Processing Dependency: libcrypto.so.(OPENSSL_1..1_EC) for package: ruby-libs-1.8.7.374-.el6.i686
--> Running transaction check
---> Package compat-readline5.i686 :5.2-17.1.el6 will be installed
---> Package openssl.i686 :1.0.-.el6 will be updated
---> Package openssl.i686 :1.0.1e-.el6_10 will be an update
--> Finished Dependency Resolution Dependencies Resolved =========================================================================================================================================
Package Arch Version Repository Size
=========================================================================================================================================
Installing:
ruby i686 1.8.7.374-.el6 base k
Installing for dependencies:
compat-readline5 i686 5.2-17.1.el6 base k
ruby-libs i686 1.8.7.374-.el6 base 1.6 M
Updating for dependencies:
openssl i686 1.0.1e-.el6_10 updates 1.5 M Transaction Summary
=========================================================================================================================================
Install Package(s)
Upgrade Package(s) Total download size: 3.8 M
Is this ok [y/N]: y
Downloading Packages:
(/): compat-readline5-5.2-17.1.el6.i686.rpm | kB :
(/): openssl-1.0.1e-.el6_10.i686.rpm | 1.5 MB :
(/): ruby-1.8.7.374-.el6.i686.rpm | kB :
(/): ruby-libs-1.8.7.374-.el6.i686.rpm | 1.6 MB :
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.6 MB/s | 3.8 MB :
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : openssl-1.0.1e-.el6_10.i686 /
Installing : compat-readline5-5.2-17.1.el6.i686 /
Installing : ruby-libs-1.8.7.374-.el6.i686 /
Installing : ruby-1.8.7.374-.el6.i686 /
Cleanup : openssl-1.0.-.el6.i686 /
Verifying : compat-readline5-5.2-17.1.el6.i686 /
Verifying : openssl-1.0.1e-.el6_10.i686 /
Verifying : ruby-1.8.7.374-.el6.i686 /
Verifying : ruby-libs-1.8.7.374-.el6.i686 /
Verifying : openssl-1.0.-.el6.i686 / Installed:
ruby.i686 :1.8.7.374-.el6 Dependency Installed:
compat-readline5.i686 :5.2-17.1.el6 ruby-libs.i686 :1.8.7.374-.el6 Dependency Updated:
openssl.i686 :1.0.1e-.el6_10 Complete!
[root@localhost package]# yum install rubygems
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirror.bit.edu.cn
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package rubygems.noarch :1.3.-.el6 will be installed
--> Processing Dependency: ruby-rdoc for package: rubygems-1.3.-.el6.noarch
--> Running transaction check
---> Package ruby-rdoc.i686 :1.8.7.374-.el6 will be installed
--> Processing Dependency: ruby-irb = 1.8.7.374-.el6 for package: ruby-rdoc-1.8.7.374-.el6.i686
--> Running transaction check
---> Package ruby-irb.i686 :1.8.7.374-.el6 will be installed
--> Finished Dependency Resolution Dependencies Resolved =========================================================================================================================================
Package Arch Version Repository Size
=========================================================================================================================================
Installing:
rubygems noarch 1.3.-.el6 base k
Installing for dependencies:
ruby-irb i686 1.8.7.374-.el6 base k
ruby-rdoc i686 1.8.7.374-.el6 base k Transaction Summary
=========================================================================================================================================
Install Package(s) Total download size: k
Installed size: 3.0 M
Is this ok [y/N]: y
Downloading Packages:
(/): ruby-irb-1.8.7.374-.el6.i686.rpm | kB :
(/): ruby-rdoc-1.8.7.374-.el6.i686.rpm | kB :
(/): rubygems-1.3.-.el6.noarch.rpm | kB :
-----------------------------------------------------------------------------------------------------------------------------------------
Total kB/s | kB :
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : ruby-irb-1.8.7.374-.el6.i686 /
Installing : ruby-rdoc-1.8.7.374-.el6.i686 /
Installing : rubygems-1.3.-.el6.noarch /
Verifying : ruby-rdoc-1.8.7.374-.el6.i686 /
Verifying : rubygems-1.3.-.el6.noarch /
Verifying : ruby-irb-1.8.7.374-.el6.i686 / Installed:
rubygems.noarch :1.3.-.el6 Dependency Installed:
ruby-irb.i686 :1.8.7.374-.el6 ruby-rdoc.i686 :1.8.7.374-.el6 Complete!
[root@localhost package]# gem install redis-3.0..gem
Successfully installed redis-3.0.
gem installed
Installing ri documentation for redis-3.0....
Installing RDoc documentation for redis-3.0....
[root@localhost package]#

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

 [root@localhost package]# cd /home/hadoop/soft/redis-3.0./
[root@localhost redis-3.0.]# ls
-RELEASENOTES BUGS CONTRIBUTING COPYING deps INSTALL Makefile MANIFESTO README redis.conf runtest runtest-cluster runtest-sentinel sentinel.conf src tests utils
[root@localhost redis-3.0.]# cd src/
[root@localhost src]# ls
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
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
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
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
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
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
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
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
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
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
[root@localhost src]# cp *.rb /usr/local/redis-cluster/
[root@localhost src]# cd /usr/local/redis-cluster/
[root@localhost redis-cluster]# ls
redis01 redis02 redis03 redis04 redis05 redis06 redis-cluster-shutdown.sh redis-cluster-start.sh redis-trib.rb
[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

 [root@localhost redis-cluster]# cat redis-cluster-shutdown.sh
cd redis01
./redis-cli -p shutdown
cd ..
cd redis02
./redis-cli -p shutdown
cd ..
cd redis03
./redis-cli -p shutdown
cd ..
cd redis04
./redis-cli -p shutdown
cd ..
cd redis05
./redis-cli -p shutdown
cd ..
cd redis06
./redis-cli -p shutdown
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实例哦。

 [root@localhost redis-cluster]# ./redis-trib.rb create --replicas  192.168.110.140: 192.168.110.140: 192.168.110.140: 192.168.110.140: 192.168.110.140: 192.168.110.140:
>>> Creating cluster
Connecting to node 192.168.110.140:: OK
Connecting to node 192.168.110.140:: OK
Connecting to node 192.168.110.140:: OK
Connecting to node 192.168.110.140:: OK
Connecting to node 192.168.110.140:: OK
Connecting to node 192.168.110.140:: OK
>>> Performing hash slots allocation on nodes...
Using masters:
192.168.110.140:
192.168.110.140:
192.168.110.140:
Adding replica 192.168.110.140: to 192.168.110.140:
Adding replica 192.168.110.140: to 192.168.110.140:
Adding replica 192.168.110.140: to 192.168.110.140:
M: 68fe9475169a3542c126d9b19a7e60452e4eb009 192.168.110.140:
slots:- ( slots) master
M: 47b64edee869fa173574267e655515ac95fa8b01 192.168.110.140:
slots:- ( slots) master
M: ff3813dec92ba0a9f333362e5fdc2c33a7d3c45e 192.168.110.140:
slots:- ( slots) master
S: bb3946e5d3473fe20364b3f4bd5297e96ce0243f 192.168.110.140:
replicates 68fe9475169a3542c126d9b19a7e60452e4eb009
S: db2d6fd06b5a40723fe739eacc7e882fdf268f2c 192.168.110.140:
replicates 47b64edee869fa173574267e655515ac95fa8b01
S: dcfa84e8a9c53e364b7caa519b7d2bff40cdb1db 192.168.110.140:
replicates ff3813dec92ba0a9f333362e5fdc2c33a7d3c45e
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join.....
>>> Performing Cluster Check (using node 192.168.110.140:)
M: 68fe9475169a3542c126d9b19a7e60452e4eb009 192.168.110.140:
slots:- ( slots) master
M: 47b64edee869fa173574267e655515ac95fa8b01 192.168.110.140:
slots:- ( slots) master
M: ff3813dec92ba0a9f333362e5fdc2c33a7d3c45e 192.168.110.140:
slots:- ( slots) master
M: bb3946e5d3473fe20364b3f4bd5297e96ce0243f 192.168.110.140:
slots: ( slots) master
replicates 68fe9475169a3542c126d9b19a7e60452e4eb009
M: db2d6fd06b5a40723fe739eacc7e882fdf268f2c 192.168.110.140:
slots: ( slots) master
replicates 47b64edee869fa173574267e655515ac95fa8b01
M: dcfa84e8a9c53e364b7caa519b7d2bff40cdb1db 192.168.110.140:
slots: ( slots) master
replicates ff3813dec92ba0a9f333362e5fdc2c33a7d3c45e
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All slots covered.
[root@localhost redis-cluster]#

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

redis集群的配置如下所示:

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

操作如下所示:

 [root@localhost ~]# cd /usr/local/
[root@localhost local]# ls
bin etc games include lib libexec redis redis-cluster sbin share src
[root@localhost local]# cd redis-cluster/
[root@localhost redis-cluster]# ls
redis01 redis02 redis03 redis04 redis05 redis06 redis-cluster-shutdown.sh redis-cluster-start.sh redis-trib.rb
[root@localhost redis-cluster]# ./redis-cluster-start.sh
[root@localhost redis-cluster]# ps -aux | grep redis
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2./FAQ
root 0.2 0.2 ? Ssl : : ./redis-server 127.0.0.1: [cluster]
root 0.1 0.2 ? Ssl : : ./redis-server 127.0.0.1: [cluster]
root 0.3 0.2 ? Ssl : : ./redis-server 127.0.0.1: [cluster]
root 0.1 0.2 ? Ssl : : ./redis-server 127.0.0.1: [cluster]
root 0.2 0.2 ? Ssl : : ./redis-server 127.0.0.1: [cluster]
root 0.2 0.2 ? Ssl : : ./redis-server 127.0.0.1: [cluster]
root 0.0 0.0 pts/ S+ : : grep redis
[root@localhost redis-cluster]# redis01/redis-cli -p -c
127.0.0.1:> set key1
-> Redirected to slot [] located at 127.0.0.1:
OK
127.0.0.1:> set key2
-> Redirected to slot [] located at 127.0.0.1:
OK
127.0.0.1:> set key3
OK
127.0.0.1:> set key4
-> Redirected to slot [] located at 127.0.0.1:
OK
127.0.0.1:> exit
[root@localhost redis-cluster]# ./redis-cluster-shutdown.sh
[root@localhost redis-cluster]# ps -aux | grep redis
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2./FAQ
root 0.0 0.0 pts/ S+ : : grep redis
[root@localhost redis-cluster]#

查看集群的状态和信息:

 [root@localhost redis-cluster]# ./redis-cluster-start.sh
[root@localhost redis-cluster]# ps -aux | grep redis
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2./FAQ
root 0.5 0.2 ? Ssl : : ./redis-server 127.0.0.1: [cluster]
root 0.0 0.2 ? Ssl : : ./redis-server 127.0.0.1: [cluster]
root 0.0 0.2 ? Ssl : : ./redis-server 127.0.0.1: [cluster]
root 0.0 0.2 ? Ssl : : ./redis-server 127.0.0.1: [cluster]
root 0.0 0.2 ? Ssl : : ./redis-server 127.0.0.1: [cluster]
root 0.0 0.2 ? Ssl : : ./redis-server 127.0.0.1: [cluster]
root 0.0 0.0 pts/ S+ : : grep redis
[root@localhost redis-cluster]# ls
redis01 redis02 redis03 redis04 redis05 redis06 redis-cluster-shutdown.sh redis-cluster-start.sh redis-trib.rb
[root@localhost redis-cluster]# redis01/redis-cli -p -c
127.0.0.1:> cluster info
cluster_state:ok
cluster_slots_assigned:
cluster_slots_ok:
cluster_slots_pfail:
cluster_slots_fail:
cluster_known_nodes:
cluster_size:
cluster_current_epoch:
cluster_my_epoch:
cluster_stats_messages_sent:
cluster_stats_messages_received:
127.0.0.1:> cluster nodes
68fe9475169a3542c126d9b19a7e60452e4eb009 127.0.0.1: master - connected -
47b64edee869fa173574267e655515ac95fa8b01 127.0.0.1: master - connected -
ff3813dec92ba0a9f333362e5fdc2c33a7d3c45e 127.0.0.1: master - connected -
dcfa84e8a9c53e364b7caa519b7d2bff40cdb1db 192.168.110.140: myself,slave ff3813dec92ba0a9f333362e5fdc2c33a7d3c45e connected
db2d6fd06b5a40723fe739eacc7e882fdf268f2c 127.0.0.1: slave 47b64edee869fa173574267e655515ac95fa8b01 connected
bb3946e5d3473fe20364b3f4bd5297e96ce0243f 127.0.0.1: slave 68fe9475169a3542c126d9b19a7e60452e4eb009 connected
127.0.0.1:>

注意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、如果有缓存数据,修改缓存数据即可。

待续......

Redis的搭建和Redis的集群搭建的更多相关文章

  1. redhat6.5 redis单节点多实例3A集群搭建

    在进行搭建redis3M 集群之前,首先要明白如何在单节点上完成redis的搭建. 单节点单实例搭建可以参看这个网:https://www.cnblogs.com/butterflies/p/9628 ...

  2. redis 5.0.3 讲解、集群搭建

    REDIS 一 .redis 介绍 不管你是从事Python.Java.Go.PHP.Ruby等等... Redis都应该是一个比较熟悉的中间件.而大部分经常写业务代码的程序员,实际工作中或许只用到了 ...

  3. Redis学习笔记(5)—— Redis的持久化方案&Redis的集群搭建

    一.Redis的持久化方案 Redis的高性能是由于其将所有数据都存储在了内存中,为了使Redis在重启之后仍能保证数据不丢失,需要将数据从内存中同步到硬盘中,这一过程就是持久化. Redis支持两种 ...

  4. redis5集群搭建步骤

    通常情况下为了redis的高可用,我们一般不会使用redis的单实例去运行,一般都会搭建一个 redis 的集群去运行.此处记录一下 redis5 以后 cluster 集群的搭建. 一.需求 red ...

  5. redis5.0.0集群搭建【实战经历】

    redis集群搭建 作者:陈土锋 时间:2020年6月2日 目录 一.环境介绍... 1 1.机器准备... 1 2.关闭防护墙和selinux. 1 3.时间同步... 1 二.Redis Clus ...

  6. (转)MongoDB分片实战 集群搭建

    环境准备 Linux环境 主机 OS 备注 192.168.32.13 CentOS6.3 64位 普通PC 192.168.71.43 CentOS6.2 64位 服务器,NUMA CPU架构 Mo ...

  7. 大数据中HBase集群搭建与配置

    hbase是分布式列式存储数据库,前提条件是需要搭建hadoop集群,需要Zookeeper集群提供znode锁机制,hadoop集群已经搭建,参考 Hadoop集群搭建 ,该文主要介绍Zookeep ...

  8. 基于 ZooKeeper 搭建 Spark 高可用集群

    一.集群规划 二.前置条件 三.Spark集群搭建         3.1 下载解压         3.2 配置环境变量         3.3 集群配置         3.4 安装包分发 四.启 ...

  9. Spark —— 高可用集群搭建

    一.集群规划 这里搭建一个3节点的Spark集群,其中三台主机上均部署Worker服务.同时为了保证高可用,除了在hadoop001上部署主Master服务外,还在hadoop002和hadoop00 ...

  10. Spark学习之路(七)—— 基于ZooKeeper搭建Spark高可用集群

    一.集群规划 这里搭建一个3节点的Spark集群,其中三台主机上均部署Worker服务.同时为了保证高可用,除了在hadoop001上部署主Master服务外,还在hadoop002和hadoop00 ...

随机推荐

  1. delphi 的插件机制与自动更新

    delphi 的插件机制与自动更新 : 1.https://download.csdn.net/download/cxp_2008/2226978   参考 2.https://download.cs ...

  2. liunx 安装Zabbix的心酸历程

    作者:邓聪聪 为了工作之需要,在系统服务方面不断的摸爬打滚,有了这样点点滴滴的经验,留后在使用!  插件网盘取. 链接: https://pan.baidu.com/s/1i5u0ed3 密码: rx ...

  3. 18春季训练01-3/11 2015 ACM Amman Collegiate Programming Contest

    Solved A Gym 100712A Who Is The Winner Solved B Gym 100712B Rock-Paper-Scissors Solved C Gym 100712C ...

  4. 函数-->指定函数--->默认函数--->动态函数--> 动态参数实现字符串格式化-->lambda表达式,简单函数的表示

    #一个函数何以接受多个参数#无参数#show(): ---> 执行:show() #传入一个参数 def show(arg): print(arg) #执行 show(123) #传入两个参数 ...

  5. php OpenSSL 加解密

    2018-1-6 17:10:19 星期六 $data = '123456'; $openssl_method = 'AES-256-CBC'; $openssl_iv_length = openss ...

  6. codecs and formats of digital media

    A codec is a device or software that is used to compress or decompress a digital media file, such as ...

  7. 进程命令ps/top/kill

    进程: 通俗的说就是 当前正在执行的一个程序 命令: ps 英文: process status 作用: 查看进程的详细状况 选项: a:显示终端上的所有进程,包括其他用户的进程 u:显示进程的详细状 ...

  8. oracle存储大文本clob、blob

    oracle存储大文本clob.blob 1 package cn.itcast.web.oracle.util; 2 3 import java.sql.Connection; 4 import j ...

  9. Linux端BaiduPCS-Go使用方法

    下载https://pan.baidu.com/s/1RFHTRE1c_JlP8rrZiERsTg 运行 ./BaiduPCS-Go 可能更新:update 登录:login 下载: d xxx 更多 ...

  10. 将Maven项目打包成可执行jar文件(引用第三方jar)

    方法一. mvn assembly 或 mvn package (一个jar包) 把依赖包和自己项目的文件打包如同一个jar包(这种方式对spring的项目不支持) <build>     ...