vmware-marketplaceconsul

Create a Consul cluster

This section describes the creation of a Consul cluster with servers located on different hosts. Follow the instructions below to create a cluster comprised of three instances.

To begin:

  • Launch as many Consul instances as you need for the cluster (in this example, three instances).
  • Connect them using VPC Network Peering.

The first instance does not require any special configuration.

Configure the other Consul instances

On each of the other instances, perform the steps below:

  • Edit the /opt/bitnami/consul/conf/consul.json file and set the following parameter:

      "bootstrap_expect":0,
    
  • Restart the Consul service:

      $ sudo /opt/bitnami/ctlscript.sh restart consul
    
  • Run the following command to join to the cluster. Remember to replace IP_ADDRESS_SERVER1 with the internal IP address of the first Consul instance.

      $ consul join IP_ADDRESS_SERVER1
    

Your Consul cluster is now operational. To test it, see the steps in the following section.

Test the cluster

To view the members of the cluster, execute the following commands:

$ consul members
$ consul operator raft list-peers

You should see output similar to the below:

$ consul members
Node          Address          Status  Type    Build  Protocol  DC   Segment
7a09a3f508af  XX.XX.XX.XX:8301  alive   server  1.2.0  2         dc1  <all>
ca24bba7fe91  XX.XX.XX.XX:8301  alive   server  1.2.0  2         dc1  <all>
ee418517cbb5  XX.XX.XX.XX:8301  alive   server  1.2.0  2         dc1  <all>

$ consul operator raft list-peers
Node          ID                                    Address          State     Voter  RaftProtocol
ca24bba7fe91  04f8464f-ae77-af99-6d76-829928f67e82  XX.XX.XX.XX:8300  leader    true   3
ee418517cbb5  484d857e-894f-4351-ee99-b6d51aa7e481  XX.XX.XX.XX:8300  follower  true   3
7a09a3f508af  5a7b8c4a-d074-1051-56d4-d0e442e713c6  XX.XX.XX.XX:8300  follower  true   3

To test data replication, follow these steps:

  • On the first Consul instance, create a key-value pair. The example below create a key named example/data with value test.

      $ consul kv put example/data test
    
  • On any other Consul instance, retrieve the value of the key by executing the following:

      $ consul kv get example/data
    

If you see the value test, this indicates that data is successfully replicating across the cluster.

Last modification December 21, 2022