Step 1:
cd / git clone https://github.com/antirez/redis.git
Result:
[root@tutorialspots ~]# cd / [root@tutorialspots /]# git clone https://github.com/antirez/redis.git Cloning into 'redis'... remote: Counting objects: 50039, done. remote: Total 50039 (delta 0), reused 0 (delta 0), pack-reused 50039 Receiving objects: 100% (50039/50039), 69.90 MiB | 19.60 MiB/s, done. Resolving deltas: 100% (35357/35357), done.
Step 2:
With redis 4.0: https://github.com/antirez/redis/blob/4.0/src/redis-trib.rb, do this step, with redis 5.0 you don’t do this step.
Edit file /redis/src/redis-trib.rb
class ClusterNode def initialize(addr) s = addr.split("@")[0].split(":") if s.length < 2 puts "Invalid IP or Port (given as #{addr}) - use IP:Port format" exit 1 end # new add start pwd = nil if s.length == 3 pwd = s.pop end # new add end port = s.pop # removes port from split array ip = s.join(":") # if s.length > 1 here, it's IPv6, so restore address @r = nil @info = {} @info[:host] = ip @info[:port] = port @info[:slots] = {} @info[:migrating] = {} @info[:importing] = {} @info[:replicate] = false # new add start @info[:password] = pwd # new add end @dirty = false # True if we need to flush slots info into node. @friends = [] end def friends @friends end def slots @info[:slots] end def has_flag?(flag) @info[:flags].index(flag) end def to_s "#{@info[:host]}:#{@info[:port]}" end def connect(o={}) return if @r print "Connecting to node #{self}: " if $verbose STDOUT.flush begin # new add start if @info[:password] != nil @r = Redis.new(:host => @info[:host], :port => @info[:port], :timeout => 60, :password=>@info[:password]) else @r = Redis.new(:host => @info[:host], :port => @info[:port], :timeout => 60) end # new add end #delete this line: @r = Redis.new(:host => @info[:host], :port => @info[:port], :timeout => 60) @r.ping rescue xputs "[ERR] Sorry, can't connect to node #{self}" exit 1 if o[:abort] @r = nil end xputs "OK" if $verbose end
Note: add in # new add start/end comments
Install more to use redis-trib:
install ruby >=2.2.2
gem install redis
Step 3:
cd /redis make
Result:
... 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... none required checking for secure_getenv... yes checking for issetugid... no checking for _malloc_thread_cleanup... no checking for _pthread_mutex_init_calloc_cb... no checking for TLS... yes checking whether C11 atomics is compilable... no checking whether 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 command s 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 : 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 : /redis/deps/jemalloc/ objroot : abs_objroot : /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 " LDFL AGS="" lib/libjemalloc.a make[3]: Entering directory `/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/e xtent.o src/hash.o src/huge.o src/mb.o src/mutex.o src/pages.o src/prof.o src/qu arantine.o src/rtree.o src/stats.o src/tcache.o src/util.o src/tsd.o make[3]: Leaving directory `/redis/deps/jemalloc' make[2]: Leaving directory `/redis/deps' CC adlist.o CC quicklist.o CC ae.o CC anet.o CC dict.o CC server.o CC sds.o CC zmalloc.o CC lzf_c.o CC lzf_d.o CC pqsort.o CC zipmap.o CC sha1.o CC ziplist.o CC release.o CC networking.o CC util.o CC object.o CC db.o CC replication.o CC rdb.o CC t_string.o CC t_list.o CC t_set.o CC t_zset.o CC t_hash.o CC config.o CC aof.o CC pubsub.o CC multi.o CC debug.o CC sort.o CC intset.o CC syncio.o CC cluster.o CC crc16.o CC endianconv.o CC slowlog.o CC scripting.o CC bio.o CC rio.o CC rand.o CC memtest.o CC crc64.o CC bitops.o CC sentinel.o CC notify.o CC setproctitle.o CC blocked.o CC hyperloglog.o CC latency.o CC sparkline.o CC redis-check-rdb.o CC redis-check-aof.o CC geo.o CC lazyfree.o CC module.o CC evict.o CC expire.o CC geohash.o CC geohash_helper.o CC childinfo.o CC defrag.o CC siphash.o CC rax.o CC t_stream.o t_stream.c: In function `xreadCommand': t_stream.c:1166:37: warning: format `%s' expects argument of type `char *', but argument 3 has type `void *' [-Wformat=] key->ptr,groupname->ptr); ^ t_stream.c:1166:37: warning: format `%s' expects argument of type `char *', but argument 4 has type `void *' [-Wformat=] t_stream.c: In function `xgroupCommand': t_stream.c:1425:36: warning: format `%s' expects argument of type `char *', but argument 4 has type `void *' [-Wformat=] grpname, c->argv[2]->ptr); ^ t_stream.c: In function `xpendingCommand': t_stream.c:1548:32: warning: format `%s' expects argument of type `char *', but argument 3 has type `void *' [-Wformat=] key->ptr,groupname->ptr); ^ t_stream.c:1548:32: warning: format `%s' expects argument of type `char *', but argument 4 has type `void *' [-Wformat=] t_stream.c: In function `xclaimCommand': t_stream.c:1725:31: warning: format `%s' expects argument of type `char *', but argument 3 has type `void *' [-Wformat=] c->argv[2]->ptr); ^ t_stream.c:1725:31: warning: format `%s' expects argument of type `char *', but argument 4 has type `void *' [-Wformat=] t_stream.c:1887:36: warning: format `%s' expects argument of type `char *', but argument 3 has type `void *' [-Wformat=] c->argv[3]->ptr, c->argv[1]->ptr); ^ t_stream.c:1887:36: warning: format `%s' expects argument of type `char *', but argument 4 has type `void *' [-Wformat=] t_stream.c: In function `xreadCommand': t_stream.c:1190:25: warning: `group' may be used uninitialized in this function [-Wmaybe-uninitialized] ids[id_idx] = group->last_id; ^ LINK redis-server INSTALL redis-sentinel CC redis-cli.o LINK redis-cli CC redis-benchmark.o LINK redis-benchmark INSTALL redis-check-rdb INSTALL redis-check-aof Hint: It's a good idea to run 'make test' 😉 make[1]: Leaving directory `/redis/src'
Done!
Create symlink
ln -s /redis/src/redis-cli /usr/bin/redis-cli ln -s /redis/src/redis-server /usr/bin/redis-server ln -s /redis/src/redis-sentinel /usr/bin/redis-sentinel ln -s /redis/src/redis-benchmark /usr/bin/redis-benchmark ln -s /redis/src/redis-check-rdb /usr/bin/redis-check-rdb ln -s /redis/src/redis-check-aof /usr/bin/redis-check-aof ln -s /redis/src/redis-trib.rb /usr/bin/redis-trib
Run redis
redis-server /path/to/redis.conf
Play with redis:
[root@tutorialspots ~]# redis-cli 127.0.0.1:6379> ping hello "hello" 127.0.0.1:6379> set website tutorialspots.com OK 127.0.0.1:6379> get website "tutorialspots.com" 127.0.0.1:6379> incr someCounter (integer) 1 127.0.0.1:6379> get someCounter "1" 127.0.0.1:6379> incr someCounter (integer) 2 127.0.0.1:6379> get someCounter "2" 127.0.0.1:6379>