Installing Redis on Linux

Log in to the Linux server as the root user.

1.Run the mkdir command to create a directory under the /opt directory to place the installation package. For example, netbraintemp8.0.3.

3.Run the cd /opt/netbraintemp8.0.3 command to navigate to the /opt/netbraintemp8.0.3 directory.

4.Download the installation package.

Option 1: If the Linux server has no access to the Internet, obtain the redis-linux-x86_64-rhel7-6.0.4-8.0.3.tar.gz file from NetBrain and then upload it to the /opt/netbraintemp8.0.3 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/netbraintemp8.0.3 directory to directly download the redis-linux-x86_64-rhel7-6.0.4-8.0.3.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-rhel7-6.0.4-8.0.3.tar.gz command under the /opt/netbraintemp8.0.3 directory to extract installation files.

[[email protected] netbraintemp8.0.3]# tar -zxvf redis-linux-x86_64-rhel7-6.0.4-8.0.3.tar.gz
redis/
redis/config/
...
redis/config/setup.conf
...
redis/install.sh
...

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= Other than the username and password, other entries 
#can only contain letters and numbers, and should start with a letter.
 
#Account info.Password should not contain: {}[]:",'|<>@&^%\ or a space. Password should be same 
in all nodes if the mode is cluster.
Password=admin
 
# 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.
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' or 'slave')
NodeRole=master
# This option will be used to install sentinel on master node. It can only be 'yes' or 'no'
MasterInstallSentinel=no
# Master Node (Master Node can support ip address, hostname or FQDN and is used if the Mode is cluster and 
used in slave node)
MasterNode=
# Sentinel Port is used to start the redis sentinel service on specified port. We use default port 6380.
SentinelPort=6380
 
# Resource limitation. It can only be 'yes' or 'no'
ResourceLimit=no
# CPU Limit. should be specified as %. Range is 1% to 100%
CPULimit=100%
#Memory Limit. should be specified as %. 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
# Stunnel Port is used to start the stunnel service on specified port. We use default port 7000.
StunnelPort=7000
# Stunnel Sentinel Port is used to start the redis sentinel service on specified port.
We use default port 7001 for SSL. this is needed only for slave node.
StunnelSentinelPort=7001

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: Creating log file
INFO: checking date
INFO: Preprocessing SUCCEEDED
INFO: Starting to check system
...
  Collecting system information SUCCEEDED.
...
INFO: System checking SUCCEEDED
INFO: Dependent packages checking SUCCEEDED
...
INFO: Configuration parameters checking SUCCEEDED
INFO: Installing /opt/netbraintemp8.0.3/redis/sources/redis-6.0.4-1.e17.x86_64.rpm
Preparing...                          ########################################
Updating / installing...
redis-6.0.4-1.el7                     ########################################
INFO: Official rpm package installing SUCCEEDED
INFO: Configuration parameters updating SUCCEEDED
INFO: Permission assigning SUCCEEDED
...
   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: 56299 (redis-server)
   Memory: 1.2M
   CGroup: /system.slice/redis.service
           56299 /sbin/redis-server *:6379
 
Jul 13 15:47:04 netbrain_data_server systemd[1]: Started Redis.
INFO: Checking redis Status
INFO: Verification SUCCEEDED
INFO: Successfully installed Redis
INFO: Backup uninstall.sh SUCCEEDED
INFO: Backup fix_releaseinfo.json SUCCEEDED

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.

Tip: It is highly recommended to run the rm -rf /opt/netbraintemp8.0.3/redis/config/setup.conf command to delete the setup.conf file from the server after Redis is successfully installed because the file may cause security vulnerability.

Parameters

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

Parameter

Default Value

Description

Password

admin

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, and 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.

MasterInstallSentinel

no

Keep the default value.

MasterNode

 

This parameter is only required for cluster deployments.

Enter the IP address of the master node when you configure the setting for the slave and sentinel node.

SentinelPort

6380

The port number that the slave or sentinel Redis node listens to.

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.

StunnelPort

7000

Specify the port number for stunnel to establish an SSL encrypted tunnel on the master and slave Redis node.

Note: It is required only if UseSSL is enabled.

StunnelSentinelPort

7001

Specify the port number for stunnel to establish an SSL encrypted tunnel on the sentinel Redis node.

Note: It is required only if UseSSL is enabled.