简体   繁体   English

如何使用 redis.conf 在 ubuntu 上启动多个 redis 服务

[英]how to start multiple redis service on ubuntu with redis.conf

I have installed redis on ubuntu, in its working nicely.我已经在 ubuntu 上安装了 redis,它运行良好。

then i need to make multiple service run on same machine, some of them master, and another slave.然后我需要在同一台机器上运行多个服务,其中一些是主服务器,另一个是从服务器。

i then make several redis.conf, with different port assigned and run it with然后我制作了几个 redis.conf,分配了不同的端口并运行它

sudo /usr/bin/redis-server /etc/redis/redis.conf

sudo /usr/bin/redis-server /etc/redis/redisSlave.conf

sudo /usr/bin/redis-server /etc/redis/redisSlave2.conf

everything work fine, i can even start a sentinel and it work like a charm一切正常,我什至可以启动一个哨兵,它就像一个魅力

then i want to auto start them on startup, i already do the same with kafka from here with step that Jakub Krhovják explained.然后我想在启动时自动启动它们,我已经从这里用 Jakub Krhovják 解释的步骤对 kafka 做了同样的事情。

there we make a service file, and do sudo systemctl enable redis-slave.service在那里我们制作了一个服务文件,并执行sudo systemctl enable redis-slave.service

here is my redis-slave.service这是我的 redis-slave.service

Unit]
Requires=redis-server.service
After=redis-server.service

[Service]
Type=simple
User=root
ExecStart=/usr/bin/redis-server /etc/redis/redisSlave.conf
Restart=on-abnormal

[Install]
WantedBy=multi-user.target

then i try to restart my vm, but when i check it with sudo systemctl status redis-slave.service i got然后我尝试重新启动我sudo systemctl status redis-slave.service ,但是当我使用sudo systemctl status redis-slave.service检查它时,我得到了

systemctl 状态

when i check it with $ss -nlt i cant find port that should be running.当我用$ss -nlt检查它时,我找不到应该运行的端口。 i even do sudo systemctl start redis-slave.service , and got same status when check it.我什至做sudo systemctl start redis-slave.service ,并在检查时得到相同的状态。

is there anything wrong with may redis-slave.service may redis-slave.service 有什么问题吗

i have to change my redis-slave.service to make it works我必须更改我的 redis-slave.service 以使其正常工作

[Unit]
Description=redis resque 6380
After=network.target

[Service]
Type=notify
User=root
ExecStart=/usr/bin/redis-server /etc/redis/redisSlave.conf --supervised systemd
ExecStop=/usr/bin/redis-cli -h 192.168.56.101 -p 6380 shutdown

[Install]
WantedBy=multi-user.target

i found it from here , the article is explaining about how to make redis cluster, great to read.我是从这里找到的,这篇文章解释了如何制作 redis 集群,非常适合阅读。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM