Redis Install and Configure: Your Database and Cache System

Introduction

This tutorial is a Step-by-Step Guide to Redis Install and Configure. Now, let’s go Redis Install and Configure.

Dive into the efficient world of Redis with this detailed guide on installation and configuration on Linux systems. Whether you’re setting up Redis for the first time or optimizing an existing installation, this tutorial offers clear, step-by-step instructions to get Redis up and running smoothly on your server.

Redis

  • It is an Open Source.
  • In-memory data structure store.
  • Used as Database.
  • Cache and message broker.
  • Redis is a key-value pair cache and store

Redis is perfect for storing sessions. All operations are performed in memory, so reading and writing will be fast

Redis Install and Configure

Download Redis

Link latest Redis home here

$ cd /opt
$ wget http://download.redis.io/releases/redis-5.0.5.tar.gz
$ sudo tar zxvf redis-5.0.5.tar.gz
$ cd redis-5.0.5

Install Redis

$ sudo make test
$ sudo make
$ sudo make install

If the following error is in make test command as below.

You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] Error 1
make[1]: Leaving directory `/opt/redis-5.0.5/src'
make: *** [test] Error 2

You need to install tcl

$ sudo yum install -y tcl

Again install Redis

$ sudo make test

Error

Executing test client: couldn’t execute “src/redis-benchmark”: no such file or directory.

Then perform the following steps

$ sudo make distclean
$ sudo make
$ sudo make install

Configure Redis

$ sudo mkdir /etc/redis
$ sudo cp redis.conf /etc/redis/6379.conf
$ sudo vi /etc/redis/6379.conf

The information content 6379.conf file

$ cat /etc/redis/6379.conf | grep -v "#" | sed /^$/d
 bind 127.0.0.1
 protected-mode yes
 port 6379
 tcp-backlog 511
 timeout 0
 tcp-keepalive 300
 daemonize yes
 supervised no
 pidfile /var/run/redis_6379.pid
 loglevel notice
 logfile "/var/log/redis_6379.log"
 databases 16
 always-show-logo yes
 save 900 1
 save 300 10
 save 60 10000
 stop-writes-on-bgsave-error yes
 rdbcompression yes
 rdbchecksum yes
 dbfilename dump.rdb
 dir /etc/redis/
 replica-serve-stale-data yes
 replica-read-only yes
 repl-diskless-sync no
 repl-diskless-sync-delay 5
 repl-disable-tcp-nodelay no
 replica-priority 100
 maxmemory 10240000
 lazyfree-lazy-eviction no
 lazyfree-lazy-expire no
 lazyfree-lazy-server-del no
 replica-lazy-flush no
 appendonly no
 appendfilename "appendonly.aof"
 appendfsync everysec
 no-appendfsync-on-rewrite no
 auto-aof-rewrite-percentage 100
 auto-aof-rewrite-min-size 64mb
 aof-load-truncated yes
 aof-use-rdb-preamble yes
 lua-time-limit 5000
 slowlog-log-slower-than 10000
 slowlog-max-len 128
 latency-monitor-threshold 0
 notify-keyspace-events ""
 hash-max-ziplist-entries 512
 hash-max-ziplist-value 64
 list-max-ziplist-size -2
 list-compress-depth 0
 set-max-intset-entries 512
 zset-max-ziplist-entries 128
 zset-max-ziplist-value 64
 hll-sparse-max-bytes 3000
 stream-node-max-bytes 4096
 stream-node-max-entries 100
 activerehashing yes
 client-output-buffer-limit normal 0 0 0
 client-output-buffer-limit replica 256mb 64mb 60
 client-output-buffer-limit pubsub 32mb 8mb 60
 hz 10
 dynamic-hz yes
 aof-rewrite-incremental-fsync yes
 rdb-save-incremental-fsync yes

Create Deamon for Redis

$ sudo cp utils/redis_init_script /etc/init.d/redis
$ sudo chkconfig --add redis
$ sudo chkconfig redis on
$ sudo /etc/init.d/redis start

The Redis server has been installed on your system.

$ sudo netstat -nplt | grep 6379                                            
 tcp        0      0 127.0.0.1:6379              0.0.0.0:*                   LISTEN      11567/redis-server

For more advanced details the “redis.conf” file configuration item is described as follows:

When the client is idle for a long time, close the connection

timeout 300

Specify the logging level. Redis supports four levels: debug, verbose, notice, and warning. The default is verbose.

loglevel verbose

Set the number of databases, the default database is 0, you can use the “select DBID from v$database;” command to specify the database ID on the connection

databases 16

Set the IP address and port of the master service when the machine is slav service. When Redis starts, it will automatically synchronize data from the master.

slaveof <masterip> <masterport>

When the master service is password protected, the slav service connects to the master password.

masterauth <master-password>

Set the Redis connection password. If the connection password is configured, the client needs to provide the password through the AUTH command when connecting to Redis. The default is off.

requirepass abc

Set the maximum number of client connections at the same time. The default is unlimited.

maxclients 128

Specify the maximum memory limit of Redis. Redis will load the data into the memory at startup. After the maximum memory is reached, Redis will first try to clear the expired or expired Key. When this method is processed, the maximum memory setting is still reached. The write operation will no longer be possible, but the read operation will still be possible. Redis’ new VM mechanism will store the Key in memory and the value will be stored in the swap area.

maxmemory <bytes>

You can use the same configuration file between multiple Redis instances on the same host, and each instance has its own specific configuration file.

include /path/to/local.conf
Redis Install and Configure

Conclusion

Successfully installing and configuring Redis enhances your application’s performance by providing rapid data access. This guide aims to equip you with the knowledge to seamlessly integrate Redis into your system, ensuring optimal setup for a robust data management solution. Thank you for reading the DevopsRoles page!

, ,

About HuuPV

My name is Huu. I love technology, especially Devops Skill such as Docker, vagrant, git, and so forth. I like open-sources, so I created DevopsRoles.com to share the knowledge I have acquired. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.