I'm using kue which uses node_redis, but I'm also already using node_redis
for my sessions, so I'd like to have kue
create a server on a specific port say the default 6379
and then kue
listen on port 1234
.
How would I be able to do this? I found this article which talks about something similar, but I don't really want to have to create an init script to do this.
Launch redis-server and supply a different argument for 'port' which can be done on the command-line:
edd@max:~$ redis-server -h
Usage: ./redis-server [/path/to/redis.conf] [options]
./redis-server - (read config from stdin)
./redis-server -v or --version
./redis-server -h or --help
./redis-server --test-memory <megabytes>
Examples:
./redis-server (run the server with default conf)
./redis-server /etc/redis/6379.conf
./redis-server --port 7777
./redis-server --port 7777 --slaveof 127.0.0.1 8888
./redis-server /etc/myredis.conf --loglevel verbose
Sentinel mode:
./redis-server /etc/sentinel.conf --sentinel
edd@max:~$
You can do this from, say, /etc/rc.local
as well so that this happens at startup.
But maybe you can also rethink your approach. Redis is so good at handling writes that you may just get by with a second database?
You can run multiple redis instance with different ports in a single machine.this concern is right mean 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 manually.to avoid runtime conflict, 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 server.If you want more repeat the steps again.
来源:https://stackoverflow.com/questions/24600544/how-can-i-run-redis-on-a-single-server-on-different-ports