1. 程式人生 > >Ubuntu install consul cluster

Ubuntu install consul cluster

unzip the package

unzip consul_1.2.2_linux_386.zip

Copied the unziped file consul* to /usr/bin/

mv consul /usr/bin/consul

Start the consul server agent

mkdir -p /tmp/consul
nohup consul agent -server -data-dir=/tmp/consul -node=server1 -bind=192.168.1.103 -bootstrap-expect 1 -client 0.0.0.0 -ui &
Parameter Comments
consul agent it will start a consul agent
-server means the agent is a server agent,it is client agent it we do not define this parameter
-data-dir client agent:service info,healthy info,server agent:cluster info
-node the agent name, must unique, it will default to host if not defined
-bind the ip for the agent
-bootstrap-expect 1 to inform consul that how many server agent will be joined, it aims to lazy start replication
-client 0.0.0.0 -ui start consul UI and all IPs can access the UI

Start the consul client agent

mkdir -p /tmp/consul
nohup consul agent -data
-dir=/tmp/consul -node=client-11 -bind=192.168.1.102 -join=192.168.1.103 &
Parameter Comments
-join add this client agent to agent server cluster

We can use below command to view all the nodes

consul members

We can access consul UI use below address

http://192.168.1.103:8500

spring-boot integrate with service register and discover