Production environment -- system setup v1--Consul -- cluster mode installation -- 11

premise

use hd User login

Server mode

1, Server node cluster deployment

It is assumed that the number of nodes in the Consul Server cluster is 3 and the node ip is respectively

leader: 
	60.205.188.229
server:
	47.105.93.27
	47.115.49.148

  1. The number of cluster nodes should be odd, at least 3

2, Deploy cluster Leader node 1 (consult-node01)

2.1, deploy the first mock exam of Server cluster nodes according to single mode deployment.

2.2. Modify config JSON configuration file

  1. Stop service
  2. Delete the original config JSON configuration file
  3. And add a new config JSON configuration file
sudo /etc/init.d/consul-node01 stop
rm -r ./consul-node01/consul01
rm ./consul-node01/consul.log
rm ./consul-node01/config.json


vim ./consul-node01/config.json


{
  "datacenter": "dc1",
  "data_dir": "consul01",
  "node_name": "consul-node1",
  "server": true,
  "bootstrap_expect": 2,
  "bind_addr": "0.0.0.0",
  "client_addr": "0.0.0.0",
  "ui": true,
  "skip_leave_on_interrupt": true,
  "retry_join": ["0.0.0.0"],
  "advertise_addr": "60.205.188.229"
}


be careful:
  1. node_ The name attribute value cannot be the same as other consumer nodes

  2. 10.1.2.1 of the related attribute values needs to be modified to the deployment machine ip

2.3. Restart the service

sudo /etc/init.d/consul-node01 start

cat /home/hd/consul-node01/consul.log


3, Deploy cluster node 2 (consumer-node02)

3.1, deploy the first mock exam of Server cluster nodes according to single mode deployment.

3.2. Modify config JSON configuration file

  1. Stop service
  2. Delete the original config JSON configuration file
  3. And add a new config JSON configuration file
sudo /etc/init.d/consul-node01 stop
rm -r ./consul-node01/consul01
rm ./consul-node01/consul.log
rm ./consul-node01/config.json


vi ./consul-node01/config.json

{
  "datacenter": "dc1",
  "data_dir": "consul01",
  "node_name": "consul-node2",
  "server": true,
  "bootstrap_expect": 2,
  "bind_addr": "0.0.0.0",
  "client_addr": "0.0.0.0",
  "ui": true,
  "skip_leave_on_interrupt": true,
  "retry_join": ["60.205.188.229"],
  "advertise_addr": "47.105.93.27"
}

be careful:
  1. node_name: the value cannot be the same as other consumer nodes
  2. Related attribute values
    1. 60.205.188.229
      1. Modify the ip address of the Leader node of the Consul Server cluster
    2. 47.105.93.27
      1. Modify to deployment machine ip

3.3 restart the service

sudo /etc/init.d/consul-node01 start

cat /home/hd/consul-node01/consul.log

4, Deploy cluster node 3 (consumer-node03)

4.1, deploy the first mock exam of Server cluster nodes according to single mode deployment.

4.2. Modify config JSON configuration file

  1. Stop service
  2. Delete the original config JSON configuration file
  3. And add a new config JSON configuration file
sudo /etc/init.d/consul-node01 stop
rm -r ./consul-node01/consul01
rm ./consul-node01/consul.log
rm ./consul-node01/config.json

vim ./consul-node01/config.json
 
{
  "datacenter": "dc1",
  "data_dir": "consul01",
  "node_name": "consul-node3",
  "server": true,
  "bootstrap_expect": 2,
  "bind_addr":  "0.0.0.0",
  "client_addr":  "0.0.0.0",
  "ui": true,
  "skip_leave_on_interrupt": true,
  "retry_join": ["60.205.188.229"],
  "advertise_addr": "47.115.49.148"
}

be careful:
  1. node_ The name attribute value cannot be the same as other consumer nodes

  2. Related attribute values

    1. 60.205.188.229
      1. Modify the ip address of the Leader node of the Consul Server cluster
    2. 47.115.49.148
      1. Modify to deployment machine ip

4.3 restart service

sudo /etc/init.d/consul-node01 start

cat /home/hd/consul-node01/consul.log

4.4. View cluster members

/home/hd/consul-node01/consul members -http-addr http://60.205.188.229:8500

Client mode

5, Consul Client service deployment

  1. Install a consult client service for each microservice physical node machine
  2. The following installation assumes that the ip of one of the physical nodes is: 10.1.2.4. Similarly, install the consult client service on other microservice physical node machines.

6, Deploy

6.1. Deploy the first mock exam Consul Client service.

6.2. Modify config JSON configuration file

  1. Stop service
  2. Delete the original config JSON configuration file
  3. And add a new config JSON configuration file
sudo /etc/init.d/consul-node01 stop
rm -r ./consul-node01/consul01
rm ./consul-node01/consul.log
rm ./consul-node01/config.json

vim ./consul-node01/config.json


{
  "datacenter": "dc1",
  "data_dir": "consul01",
  "node_name": "consul-node4",
  "bind_addr": "0.0.0.0",
  "client_addr": "0.0.0.0",
  "ui": true,
  "leave_on_terminate": true,
  "retry_join": ["60.205.188.229"],
  "advertise_addr": "60.205.188.330"
}

be careful:

  1. The datacenter property value needs to be set to be consistent with the datacenter property value of the Consul Server cluster node

  2. node_ The name attribute value cannot be the same as other consumer nodes

  3. Related attribute values

    1. "60.205.188.229
      1. Modify the ip address of the Leader node of the Consul Server cluster
    2. 60.205.188.330
      1. Modify to deployment machine ip

6.3 restart service

sudo /etc/init.d/consul-node01 start

cat /home/hd/consul-node01/consul.log

6.4. View cluster members

/home/hd/consul-node01/consul members -http-addr http://60.205.188.229:8500

Added by bbxrider on Sun, 23 Jan 2022 09:39:45 +0200