Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run redis on a single server on different ports?

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.

like image 682
bob_cobb Avatar asked Jul 06 '14 21:07

bob_cobb


People also ask

What ports can I use for Redis?

By default, the Redis server runs on TCP Port 6379. If the GE Digital APM server and the Redis server are on same machine, then connections are allowed from the local server. If the GE Digital APM server and the Redis server are on different machines, then Port 6379 must be accessible between the Client and the Server.

Can I change Redis port?

Running redis-cli followed by a command name and its arguments will send this command to the Redis instance running on localhost at port 6379. You can change the host and port used by redis-cli - just try the --help option to check the usage information.


2 Answers

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?

like image 145
Dirk Eddelbuettel Avatar answered Oct 04 '22 15:10

Dirk Eddelbuettel


Very easy command:

echo "port 4000" | redis-server -

echo "port 4001" | redis-server -

like image 39
Amulya Kashyap Avatar answered Oct 04 '22 14:10

Amulya Kashyap