Consul.io - how to run multiple servers on one machine

This is probably a very simple question for you, but I just get to the consul and for testing, I want to run several servers on my PC. For example, I start the first server with

consul agent -server -bootstrap-expect=1 -dc=dev -data-dir=/tmp/consul -ui-dir="c:/consul 0.5.2/dist" 

and then I try to start the second server using

 consul agent -server -data-dir=/tmp/consul2 -dc=dc2 

but he returns

 ==> Error starting agent: Failed to start Consul server: Failed to start RPC lay er: listen tcp 0.0.0.0:8300: bind: Only one usage of each socket address (protoc ol/network address/port) is normally permitted. 

What am I missing in my team?

+4
source share
2 answers

You start two consul servers, using mostly default values. In this case, the problem is that you are using the default ports.

When you read the error message, you will notice that your second consul server is trying to bind port 8300. But your first server is already using this port, causing the second server to fail at startup. (note: consul binds to different ports, each with a different purpose and default setting. Take a look at the documentation ).

As suggested by LenW, you can use Vagrant to customize your environment. You can follow the tutorial .

If you do not want to use a stroller or configure any virtual machines yourself. You can change the default settings for the second server.

+4
source

If you are trying to simulate a production topology on your dev machine, I would look at using Vagrant in conjunction with VirtualBox to simulate a couple of machines for testing.

+1
source

All Articles