Installing Redis on Linux

Pre-installation Tasks

Redis has dependencies on the third-party package logrotate. Before you install the Redis, run the rpm -qa|grep logrotate command to check whether it has been installed on the server. If it has not been installed yet, you can choose either option below to install the dependencies.

oOnline Install: run the yum -y install logrotate command to install it online.

oOffline Install: refer to Offline Installing Third-party Dependencies for more details.

Note: If the Service Monitor Agent was not previously installed, it will be installed with Redis. You'll need to use the interactive command line to install it. See Installing MongoDB on Linux for more details. You can also install the Service Monitor Agent separately before installing Redis.

Installing Redis on Linux

1.Log in to the Linux server as the root user.

2.Run the mkdir command to create a directory under the /opt directory to place the installation package. For example, netbraintemp10.0a.

3.Run the cd /opt/netbraintemp10.0a command to navigate to the /opt/netbraintemp10.0a directory.

4.Download the installation package.

Option 1: If the Linux server has no access to the Internet, obtain the redis-linux-x86_64-rhel-6.0.13-10.0a.tar.gz file from NetBrain and then upload it to the /opt/netbraintemp10.0a directory by using a file transfer tool.  

Option 2: If the Linux server has access to the Internet, run the
wget <download link> command under the /opt/netbraintemp10.0a directory to directly download the redis-linux-x86_64-rhel-6.0.13-10.0a.tar.gz file from NetBrain official download site.

Note: Contact NetBrain Support Team to get the download link. The download link is case-sensitive.

Tip: Run the yum -y install wget command to install the wget command if it has not been installed on the server.

5.Run the tar -zxvf redis-linux-x86_64-rhel-6.0.13-10.0a.tar.gz command under the /opt/netbraintemp10.0a directory to extract installation files.

[[email protected] netbraintemp10.0a]# tar -zxvf redis-linux-x86_64-rhel-6.0.13-10.0a.tar.gz
redis/
redis/sources/
...
redis/include/source.sh
...
redis/config/setup.conf
...

6.Run the cd redis/config command to navigate to the config directory.

7.Modify the parameters in the setup.conf file located under the config directory and save the changes. For how to modify the configuration file, refer to Editing a File with VI Editor.

[[email protected] config]# vi setup.conf
#Redis configuration file
 
#Note: Entries other than the password
can only contain letters or numbers, and should start with a letter.
 
#Account info.
#Password should not contain: {}[]:",'|<>@&^%\ or a space. The password should be the same 
in all nodes if the mode is a cluster.
Password=Admin1.# 
 
# Mode use 'standalone' if single installation, use 'cluster' if HA mode
Mode=standalone
 
# Port is used to start the redis service on specified port. We use default port 6379.
# Please enter the same Port for all nodes that belong to the same cluster
Port=6379
 
# Data Path is used to store redis files. Default path /var/lib/redis.
DataPath=/var/lib/redis 
 
# Log Path is used to store redis log files. Default path /var/log/redis.
LogPath=/var/log/redis 
 
# Role (NodeRole can only be 'master', 'slave' 'sentinel' or 'dr-sentinel')
# sentinel - start the redis in sentinel mode so that it can monitor a cluster
# dr-sentinel - start the redis in sentinel mode so that it can monitor a DR cluster for a multi-DC on same node where you have redis already installed
 
NodeRole=master
#Master Node (Master Node can support ip address, hostname or FQDN and is used if the Mode is cluster) 
MasterNode=
# Sentinel Port is used to start the redis sentinel service on specified port. We use default port 6380. 
# For a multi-DC DR cluster there will be 2 instances of sentinel on same arbiter node so user should change this value to default port 6381 
or any other port which is not used by other service.
# Please enter the same sentinelPort for all nodes that belong to the same cluster
SentinelPort=6380
 
# Resource limitation. It can only be 'yes' or 'no'
ResourceLimit=no
# CPU Limit. It should end with %. Range is 1% to 100%
CPULimit=100%
#Memory Limit. It should end with %. Range is 1% to 100%
MemmoryLimit=100%
 
# TLS. It can only be 'yes' or 'no'
UseSSL=no
Certificate=/etc/ssl/cert.pem
PrivateKey=/etc/ssl/key.pem
CertAuth=/etc/ssl/cacert.pem

8.Run the cd .. command to navigate to the redis directory.

9.Run the ./install.sh script under the redis directory to install Redis.

[[email protected] redis]# ./install.sh
INFO: Checking root
INFO: Checking date
INFO: Starting to check Linux OS info
INFO: Starting to check required CPU
INFO: Starting to check minimum memory
INFO: Creating installation log file SUCCEEDED
INFO: Starting to check crontab
INFO: Component Name: Redis
INFO: RPM name: redis
INFO: Service name: redis
INFO: RPM package list: redis-6.0.13-1.x86_64.rpm
INFO: Config path: /etc/redis
INFO: Preprocessing SUCCEEDED
INFO: Starting to check system
INFO: Collecting system information SUCCEEDED. 
INFO: Starting to check if rpm exists
INFO: Starting to check systemd
INFO: System checking SUCCEEDED
...
 redis.service - Redis
   Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2020-07-14 00:38:49 EST; 37min ago
   Main PID: 36704 (redis-server)
   Memory: 1.2M
   CGroup: /system.slice/redis.service
           56299 /sbin/redis-server *:6379
...
INFO: Checking redis Status
INFO: Verification SUCCEEDED
INFO: Backup uninstall.sh SUCCEEDED
INFO: Backup fix_releaseinfo.json SUCCEEDED
INFO: Successfully installed Redis

10. Run the systemctl status redis command to verify whether its service starts successfully.

[[email protected] ~]# systemctl status redis
 redis.service - Redis
   Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2020-07-13 15:47:04 EDT; 10min ago
 Main PID: 52318 (redis-server)
 Memory: 7.7M
...

Note: When your disk space is insufficient for large amounts of logs, you can modify the log settings in the redis.conf file under the /etc/logrotate directory.

Parameters

The following table describes the parameters that can be configured when installing Redis.

Parameter

Default Value

Description

Password

Admin1.#

Specify the admin password used to connect to Redis.

Note: The password cannot contain any of the following special characters, and its length cannot exceed 64 characters.
{ } [ ] : " , ' | < > @ & ^ % \ and spaces

Note: Each member in a cluster must have the same password.

Mode

standalone

Set whether to enable cluster deployment. Keep the default value for a standalone deployment.

If you plan to deploy a cluster, modify it to cluster.

Port

6379

Specify the port number that the master Redis node listens to.

DataPath

/var/lib/redis/

Specify the storage path for all data files of Redis.

LogPath

/var/log/redis/

Specify the storage path for all log files of Redis.

NodeRole

master

Set the role for the current node. Available options are master, slave, sentinel and dr-sentinel . Keep the default value for a standalone deployment. If you plan to deploy a cluster, modify it to slave and sentinel on the other nodes.

MasterNode

 

This parameter is only required for cluster deployments.

Enter the IP address of the master node when you configure the setting for the master, slave, and sentinel (or dr-sentinel) node.

SentinelPort

6380

The port number that the sentinel or dr-sentinel node listens to.

Note: Use alternative port such as 6381 when deploying the dr-sentinel node.

ResourceLimit

no

Set whether to limit the system resource usage for Redis.

CPULimit

100%

The maximum CPU utilization of the machine that can be consumed by Redis.

MemoryLimit

100%

The maximum memory capacity of the machine that can be consumed by Redis.

UseSSL

no

Set whether to enable the encrypted connections to Redis by using SSL.

Note: Redis itself does not support SSL. It uses stunnel as an SSL service agent. Stunnel will be automatically installed together with Redis.

Certificate

/etc/ssl/cert.pem

Specify the storage path for all the certificates and key files used for SSL authentication.

Note: It is required only if UseSSL is enabled.

PrivateKey

/etc/ssl/key.pem

Specify the name of SSL private key file.

Note: It is required only if UseSSL is enabled.

CertAuth

/etc/ssl/cacert.pem

Specify the name of the SSL certificate chain or intermediate certificate (class 2 or class 3 certificate).

Note: It is required only if UseSSL is enabled.