Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
309 views
in Technique[技术] by (71.8m points)

stackexchange.redis - Running multiple instance of Redis on Centos

I want to run multiple instance of Redis on Centos 7. Can anyone point me to proper link or post steps here.

I googled for the information but I didn't find any relevant information.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can run multiple instances of Redis using different ports on a single machine. If this what concerns you then you can follow the below steps.

By installing the first Redis instance, it listens on localhost:6379 by default.

For Second Instance create a new working directory

The default Redis instance uses /var/lib/redis as its working directory, dumped memory content is saved under this directory with name dump.rdb if you did not change it. To avoid runtime conflicts, we need to create a new working directory.

mkdir -p /var/lib/redis2/
chown redis /var/lib/redis2/
chgrp redis /var/lib/redis2/

Generate configurations

Create a new configuration file by copying /etc/redis.conf

cp /etc/redis.conf /etc/redis2.conf
chown redis /etc/redis2.conf

Edit following settings to avoid conflicts

logfile "/var/log/redis/redis2.log"
dir "/var/lib/redis2"
pidfile "/var/run/redis/redis2.pid"
port 6380

Create service file

cp /usr/lib/systemd/system/redis.service /usr/lib/systemd/system/redis2.service

Modify the settings under Service section

[Service]
ExecStart=/usr/bin/redis-server /etc/redis2.conf --daemonize no
ExecStop=/usr/bin/redis-shutdown redis2

Set to start with boot

systemctl enable redis2

Start 2nd Redis

service redis2 start

Check Status

lsof -i:6379
lsof -i:6380

By Following this you can start two Redis servers. If you want more repeat the steps again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...