...
Introduction
Redis is an in-memory data storage that is used by the CoreOne Suite. This how-to gives you a brief overview on how to install a redis cluster on Ubuntu.For supported versions see: Next-Gen Workflows - Redis
Step 1 - Check your prerequisits
Redis has to be installed on a Linux OS (Ubuntu, Redhat, Centos, etc.).
To install Redis, at least 3 instances are needed. The instances can be distributed across different servers, or concentrated on one (best practice will be shown in the examples below).
If the servers for Redis are in different network-zones, the servers must be able to communicate with eachother.
The following Firewall-Ports must be open:
6379
16384
16379
7001 (Cluster)
7002 (Cluster)
7003 (Cluster)
7004 (Cluster)
7006 (FClusterCluster)
Example
In our example we got 3 virtual Ubuntu-Servers.
Redis HA 1 (192.168.17.134)
Redis HA 2 (192.168.17.135)
Redis HA 3 (192.168.17.136)
On Redis HA1 is a Master Instance 7001 and a Slave Instance 7004
On Redis HA2 is a Master Instance 7002 and a Slave Instance 7005
On Redis HA3 is a Master Instance 7003 and a Slave Instance 7006
For the Master 7001 the Slave is 7006
For the Master 7002 the Slave is 7006
For the Master 7003 the Slave is 7004
...
Step 2 - Installation
General installation for all 3 servers:
Switch to root user:
Code Block |
---|
sudo su |
...
Code Block |
---|
cd /etc/redis/redis-6.2.6/ sudo make test |
Step 3 - Configuration VM 1
In our example we have multiple redis instanced on one server. This means we need multiple config-files on the server as well.
...
Code Block |
---|
port 7004 cluster-enabled yes cluster-config-file cluster-node-4.conf cluster-node-timeout 5000 appendonly yes appendfilename node-4.aof dbfilename dump-4.rdb |
Step 4 - Configuration VM 2
In our example we have multiple redis instanced on one server. This means we need multiple config-files on the server as well.
...
Code Block |
---|
port 7005 cluster-enabled yes cluster-config-file cluster-node-5.conf cluster-node-timeout 5000 appendonly yes appendfilename node-5.aof dbfilename dump-5.rdb |
Step 5 - Configuration VM 3
In our example we have multiple redis instanced on one server. This means we need multiple config-files on the server as well.
...
Code Block |
---|
port 7006 cluster-enabled yes cluster-config-file cluster-node-6.conf cluster-node-timeout 5000 appendonly yes appendfilename node-6.aof dbfilename dump-6.rdb |
Step 6 - Start Redis
We can start Redis now on each VM through the config-files we created.
...
Server | Instanz | Befehl | ||||
---|---|---|---|---|---|---|
HA1 (192.168.17.134) | Node 01 - Port 7001 Node 04 - Port 7004 |
| ||||
HA 2 (192.168.17.135) | Node 02 - Port 7002 Node 05 - Port 7005 |
| ||||
HA 3 (192.168.17.136) | Node 03 - Port 7003 Node 06 - Port 7006 |
|
Step 7 - Connect Redis
We can now connect on each instace with the Redis-CLI
Server | Instanz | Befehl | ||
---|---|---|---|---|
HA1 (192.168.17.134) | Node 01 - Port 7001 Node 04 - Port 7004 |
| ||
HA 2 (192.168.17.135) | Node 02 - Port 7002 Node 05 - Port 7005 |
| ||
HA 3 (192.168.17.136) | Node 03 - Port 7003 Node 06 - Port 7006 |
|
Step 8 - Configure Redis Cluster
Since the instaces are local at the moment, we need to connect them to the cluster.
...
Check the config and confirm with: Y
Step 9 - Redis-CLI
Open Redis-CLI:
Info |
---|
-p = Port -c = Cluster |
Code Block |
---|
./redis-6.2.6/src/redis-cli -c -p 7001 |
ping
Code Block |
---|
ping |
The different nodes can be pinged:
info
Code Block |
---|
info |
Shows all information on the cluster
...
cluster nodes
Code Block |
---|
cluster nodes |
Shows all nodes and if they are master or slave.
...
info replication
Code Block |
---|
info replication |
Shows if the server is master or slave. Shows the depending slaves.
...
Step 10 - Failover
We will terminate Master 7003 for this example. This will prompt the Slave 7004 to become the new master:
...