在 Centos 上运行多个 Redis 实例 [英] Running multiple instance of Redis on Centos
问题描述
我想在 Centos 7 上运行多个 Redis 实例.谁能指出我正确的链接或在此处发布步骤.
我在谷歌上搜索了相关信息,但没有找到任何相关信息.
您可以在一台机器上使用不同的端口运行多个 Redis 实例.如果您对此感到担忧,那么您可以按照以下步骤操作.
<块引用>通过安装第一个 Redis 实例,它默认监听 localhost:6379
.
为第二个实例创建一个新的工作目录
默认Redis实例使用/var/lib/redis
作为它的工作目录,如果你没有,转储的内存内容保存在这个目录下,名称为dump.rdb
更改.为了避免运行时冲突,我们需要创建一个新的工作目录.
mkdir -p/var/lib/redis2/chown redis/var/lib/redis2/chgrp redis/var/lib/redis2/
生成配置
通过复制/etc/redis.conf
cp/etc/redis.conf/etc/redis2.confchown redis/etc/redis2.conf
编辑以下设置以避免冲突
日志文件/var/log/redis/redis2.log"目录/var/lib/redis2"pidfile "/var/run/redis/redis2.pid"6380端口
创建服务文件
cp/usr/lib/systemd/system/redis.service/usr/lib/systemd/system/redis2.service
修改服务部分下的设置
[服务]ExecStart=/usr/bin/redis-server/etc/redis2.conf --daemonize noExecStop=/usr/bin/redis-shutdown redis2
设置为开机启动
systemctl enable redis2
开始第二个Redis
service redis2 start
检查状态
lsof -i:6379lsof -i:6380
<块引用>
通过执行此操作,您可以启动两个 Redis 服务器.如果您想要更多,请再次重复这些步骤.
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.
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.
这篇关于在 Centos 上运行多个 Redis 实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!