If you haven't already started a Redis instance on the new port (e.g., 6382), you'll need to do that. You can start Redis on a specific port using a configuration file or directly via the command line.
redis-server --port 6382Alternatively, if you have a custom Redis configuration file, use it like this.
redis-server /path/to/redis_6382.confAfter starting Redis on the new port, verify it's running using the following command.
redis-cli -p 6382 pingIf Redis is running correctly, it should return PONG.
Now, you will not always run redis-server --port 6382 command, as you close your terminal, your Redis Instance on port 6382 will be disable. So you need to run new instance a service, that on reboot your machine have running this new instance of Redis.
Execute the command below.
sudo cp /etc/redis/redis.conf /etc/redis/redis_6382.confBefore copying the conf file, you had only one file at /etc/redis/ directory, named redis.conf, after the copy, you have another file named redis_6382.conf.
Now, you need to edit the port number of the new conf file. Open the file.
sudo nano /etc/redis/redis_6382.confNow, find the line with port and it is possible to be port 6379, update this line into port 6382, and make sure supervised is systemd, means supervised systemd then save and exit.
Create a new systemd service file for the Redis instance on port 6382. You can create a new service file using the command below.
sudo nano /etc/systemd/system/redis_6382.serviceAdd the following instructions.
[Unit]
Description=Redis In-Memory Data Store for Port 6382
After=network.target
[Service]
ExecStart=/usr/bin/redis-server /etc/redis/redis_6382.conf --supervised systemd --daemonize no
ExecStop=/usr/bin/redis-cli -p 6382 shutdown
Restart=always
[Install]
WantedBy=multi-user.targetOr you can copy redis.service file. To do so, execute the command below.
sudo cp /etc/systemd/system/redis.service /etc/systemd/system/redis_6832.serviceAnd now need to edit a few lines, first open the file.
sudo nano /etc/sytemd/system/redis_6832.serviceThen edit ExecStart
ExecStart=/usr/bin/redis-server /etc/redis/redis_6382.conf --supervised systemd --daemonize noAnd edit PIDFile
PIDFile=/run/redis/redis-6832.pidAnd edit Alias
Alias=redis_6832.serviceThen save and exit.
Make sure PIDFile is unique. To do so, open the redis_6832.conf file.
sudo nano /etc/redis/redis_6382.confAnd then update pidfile
pidfile /var/run/redis/redis-6382.pidThen save and exit.
sudo systemctl daemon-reloadsudo systemctl enable redis_6382sudo systemctl start redis_6382sudo systemctl status redis_6382If everything looks good, execute the command to verify.
redis-cli -p 6382 ping