In this tutorial, you will learn what Redis is, the uses and where Redis is being used. you will also learn how to install Redis, the latest version of Redis.
UNDERSTANDING THE SUBJECT MATTER
Redis, which stands for (remote dictionary server), is an open-source, extremely fast and powerful MEMORY caching system. In other words, Redis stores data in the memory, as such, it is an in-memory data structure system.
Take, for example, the traditional database system, where the database is stored on HDD or SSD, when the database is queried, by default, the method of retrieving information is to go all the way to the hard drive to get the queried information.
On the contrary, for Redis, data is stored in the memory by default, hence, when information is queried, the result is gotten extremely fast because the data is already in the memory as a cache. However, Redis also gives the option of storing data on the hard drive.
Redis is a data-store in itself, it can be used as a database, an in-memory, and a no-SQL database and uses data structure in storing data as key-value pairs. For example,
site = tekneed.com
The “site” is the key while “tekneed.com” is the value.
The data structure it supports are strings, hashes, lists, sets, etc, which makes Redis very easy to use software. It is written in C language, as such very fast and the response time is in sub-millisecond. It can also allow millions of simultaneous requests per second.
Other programming languages Redis supports are Python, Java, PHP, Perl, Go, Ruby and Node.js
Redis can be used as a cache and a message broker/queue, to mention a few. Redis message broker capability is called Pubsub.
To interact with Redis, you use the redis-cli tool.
redis-cli
redis>
Going forward, Redis should be shut down properly because the data-set is stored in the memory, if it is not properly done, there is a big tendency that you may lose information. So, when you want to shut down Redis, it is proper to always do a graceful shutdown.
An alternative to Redis is the Memcached software. Memcached is also a very good MEMORY caching system but Redis over time has been proven better than Memcached because Redis was built after Memcached, hence, rode on Memecahed shortcomings and a lot of features that Memchaced didn’t have was added to Redis.
Companies that are using Redis are Pinterest, Github, Twitter, etc. Twiter uses Redis for caching and some other stuff.
Enough of what Redis is, let’s get to know how to install it on RHEL system
ACTION TIME
1. Download the latest Redis versiom from Redis site.
[root@HQPRD2 ~]# cd /tmp
[root@HQPRD2 tmp]# wget http://download.redis.io/releases/redis-5.0.7.tar.gz
--2020-03-10 07:43:27-- http://download.redis.io/releases/redis-5.0.7.tar.gz
Resolving download.redis.io (download.redis.io)... 109.74.203.151
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connec ted.
HTTP request sent, awaiting response... 200 OK
Length: 1984203 (1.9M) [application/x-gzip]
Saving to: ‘redis-5.0.7.tar.gz’
100%[=====================================================>] 1,984,203 78.6KB/s in 18s
2020-03-10 07:43:45 (110 KB/s) - ‘redis-5.0.7.tar.gz’ saved [1984203/1984203]
2. Extract the file
[root@HQPRD2 tmp]# tar xzfv redis-5.0.7.tar.gz
redis-5.0.7/
redis-5.0.7/.gitignore
redis-5.0.7/00-RELEASENOTES
redis-5.0.7/BUGS
redis-5.0.7/CONTRIBUTING
redis-5.0.7/COPYING
redis-5.0.7/INSTALL
redis-5.0.7/MANIFESTO
redis-5.0.7/Makefile
redis-5.0.7/README.md
redis-5.0.7/deps/
redis-5.0.7/deps/Makefile
redis-5.0.7/deps/README.md
redis-5.0.7/deps/hiredis/
redis-5.0.7/deps/hiredis/.gitignore
redis-5.0.7/deps/hiredis/.travis.yml
redis-5.0.7/deps/hiredis/CHANGELOG.md
redis-5.0.7/deps/hiredis/COPYING
redis-5.0.7/deps/hiredis/Makefile
redis-5.0.7/deps/hiredis/README.md
redis-5.0.7/deps/hiredis/adapters/
redis-5.0.7/deps/hiredis/adapters/ae.h
redis-5.0.7/deps/hiredis/adapters/glib.h
redis-5.0.7/deps/hiredis/adapters/ivykis.h
redis-5.0.7/deps/hiredis/adapters/libev.h
redis-5.0.7/deps/hiredis/adapters/libevent.h
redis-5.0.7/deps/hiredis/adapters/libuv.h
redis-5.0.7/deps/hiredis/adapters/macosx.h
redis-5.0.7/deps/hiredis/adapters/qt.h
redis-5.0.7/deps/hiredis/appveyor.yml
redis-5.0.7/deps/hiredis/async.c
redis-5.0.7/deps/hiredis/async.h
redis-5.0.7/deps/hiredis/dict.c
redis-5.0.7/deps/hiredis/dict.h
redis-5.0.7/deps/hiredis/examples/
redis-5.0.7/deps/hiredis/examples/example-ae.c
redis-5.0.7/deps/hiredis/examples/example-glib.c
redis-5.0.7/deps/hiredis/examples/example-ivykis.c
redis-5.0.7/deps/hiredis/examples/example-libev.c
redis-5.0.7/deps/hiredis/examples/example-libevent.c
redis-5.0.7/deps/hiredis/examples/example-libuv.c
redis-5.0.7/deps/hiredis/examples/example-macosx.c
redis-5.0.7/deps/hiredis/examples/example-qt.cpp
redis-5.0.7/deps/hiredis/examples/example-qt.h
3. compile Redis
[root@HQPRD2 tmp]# cd redis-5.0.7
[root@HQPRD2 redis-5.0.7]# make
cd src && make all
make[1]: Entering directory `/tmp/redis-5.0.7/src'
CC Makefile.dep
make[1]: Leaving directory `/tmp/redis-5.0.7/src'
make[1]: Entering directory `/tmp/redis-5.0.7/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep dict-benchmark
(cd ../deps && make distclean)
make[2]: Entering directory `/tmp/redis-5.0.7/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[2]: Leaving directory `/tmp/redis-5.0.7/deps'
(rm -f .make-*)
MAKE hiredis
cd hiredis && make static
make[3]: Entering directory `/tmp/redis-5.0.7/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
make[3]: Entering directory `/tmp/redis-5.0.7/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
checking for secure_getenv... yes
checking for sched_getcpu... yes
checking for sched_setaffinity... yes
checking for issetugid... no
checking for _malloc_thread_cleanup... no
checking for _pthread_mutex_init_calloc_cb... no
checking for TLS... yes
checking whether C11 atomics is compilable... no
checking whether GCC __atomic atomics is compilable... yes
checking whether GCC __sync atomics is compilable... yes
checking whether Darwin OSAtomic*() is compilable... no
checking whether madvise(2) is compilable... yes
checking whether madvise(..., MADV_FREE) is compilable... no
checking whether madvise(..., MADV_DONTNEED) is compilable... yes
checking whether madvise(..., MADV_DO[NT]DUMP) is compilable... yes
checking whether madvise(..., MADV_[NO]HUGEPAGE) is compilable... yes
checking whether to force 32-bit __sync_{add,sub}_and_fetch()... no
install_suffix :
malloc_conf :
autogen : 0
debug : 0
stats : 1
prof : 0
prof-libunwind : 0
prof-libgcc : 0
prof-gcc : 0
fill : 1
utrace : 0
xmalloc : 0
log : 0
lazy_lock : 0
cache-oblivious : 1
cxx : 0
===============================================================================
cd jemalloc && make CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS="" lib/libjemalloc.a
src/arena.sym.o src/arena.c
nm -a src/arena.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/arena.sym
CC geo.o
CC lazyfree.o
CC module.o
CC evict.o
CC expire.o
CC geohash.o
CC geohash_helper.o
CC childinfo.o
CC defrag.o
CC siphash.o
CC rax.o
CC t_stream.o
CC listpack.o
CC localtime.o
CC lolwut.o
CC lolwut5.o
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 `/tmp/redis-5.0.7/src'
[root@HQPRD2 redis-5.0.7]#
4. copy both redis server and the command line interface into the proper places manually or by using the command,
[root@HQPRD2 redis-5.0.7]# make install
cd src && make install
make[1]: Entering directory `/tmp/redis-5.0.7/src'
CC Makefile.dep
make[1]: Leaving directory `/tmp/redis-5.0.7/src'
make[1]: Entering directory `/tmp/redis-5.0.7/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 `/tmp/redis-5.0.7/src'
5. Start Redis server
[root@HQPRD2 redis-5.0.7]# redis-server
you can see the “Ready to accept connections” status
6. Test the connection.
open a new terminal and use the command,
[root@HQPRD2 ~]# redis-cli
127.0.0.1:6379>
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>
127.0.0.1:6379> set key test1
OK
127.0.0.1:6379>
127.0.0.1:6379> get key
"test1"
127.0.0.1:6379>
7. Secure Redis server
By default, redis binds to all interfaces and has no iota of authentication.
If Redis server is configured in an isolated and dmz network that is not internet facing and generally protected from brute force attacks, Redis is secured, but if otherwise, it is a very big concern as regards to security.
The server needs to be secured after installation.
You can look into redis official site for more on redis secutity configuration and application relations
Your feedback is welcomed. If you love others, you will share with others
Leave a Reply