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
- 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
- Stop service
- Delete the original config JSON configuration file
- 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:
-
node_ The name attribute value cannot be the same as other consumer nodes
-
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
- Stop service
- Delete the original config JSON configuration file
- 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:
- node_name: the value cannot be the same as other consumer nodes
- Related attribute values
- 60.205.188.229
- Modify the ip address of the Leader node of the Consul Server cluster
- 47.105.93.27
- Modify to deployment machine ip
- 60.205.188.229
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
- Stop service
- Delete the original config JSON configuration file
- 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:
-
node_ The name attribute value cannot be the same as other consumer nodes
-
Related attribute values
- 60.205.188.229
- Modify the ip address of the Leader node of the Consul Server cluster
- 47.115.49.148
- Modify to deployment machine ip
- 60.205.188.229
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
- Install a consult client service for each microservice physical node machine
- 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
- Stop service
- Delete the original config JSON configuration file
- 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:
-
The datacenter property value needs to be set to be consistent with the datacenter property value of the Consul Server cluster node
-
node_ The name attribute value cannot be the same as other consumer nodes
-
Related attribute values
- "60.205.188.229
- Modify the ip address of the Leader node of the Consul Server cluster
- 60.205.188.330
- Modify to deployment machine ip
- "60.205.188.229
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