在Centos上运行Redis的多个实例 [英] Running multiple instance of Redis on Centos
问题描述
我想在Centos 7上运行Redis的多个实例. 谁能指出我正确的链接或在此处发布步骤.
I want to run multiple instance of Redis on Centos 7. Can anyone point me to proper link or post steps here.
我在Google上搜索了该信息,但没有找到任何相关信息.
I googled for the information but I didn't find any relevant information.
推荐答案
您可以在单台计算机上使用不同的端口运行Redis的多个实例.如果这与您有关,则可以按照以下步骤操作.
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.
通过安装第一个Redis实例,默认情况下它会监听
localhost:6379
.
为第二实例创建一个新的工作目录
默认Redis实例使用/var/lib/redis
作为其工作目录,如果不进行更改,转储的内存内容将以名称dump.rdb
保存在该目录下.为了避免运行时冲突,我们需要创建一个新的工作目录.
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/
生成配置
通过复制/etc/redis.conf
cp /etc/redis.conf /etc/redis2.conf
chown redis /etc/redis2.conf
编辑以下设置以避免冲突
logfile "/var/log/redis/redis2.log"
dir "/var/lib/redis2"
pidfile "/var/run/redis/redis2.pid"
port 6380
创建服务文件
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
设置为从启动开始
systemctl enable redis2
开始第二次Redis
service redis2 start
检查状态
lsof -i:6379
lsof -i:6380
通过此操作,您可以启动两个Redis服务器.如果您想要更多,请再次重复这些步骤.
By Following this you can start two Redis servers. If you want more repeat the steps again.
这篇关于在Centos上运行Redis的多个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!