HashiCorp Certified: Consul Associate Certification

Deploy a Single Datacenter

Start the Consul Process

This guide walks you through the essential workflow for getting Consul up and running on your machine or server. You’ll learn how to:

  1. Download and install the Consul CLI
  2. Create configuration files
  3. Launch the Consul agent (service or manual)
  4. Run Consul in development mode

1. Download and Install Consul

Visit the Consul releases page to download the appropriate binaries for your operating system:

Consul Releases

Note

If you have a Consul Enterprise license, be sure to select the enterprise package instead of the open-source edition.

  1. Unzip the downloaded archive.
  2. Move the consul binary into your $PATH. For example, on Linux:
sudo mv consul /usr/local/bin/
  1. Verify the installation:
consul version

2. Create Consul Configuration

Consul supports HCL files and CLI flags. You can use a single file or a directory of files.

Single File vs. Configuration Directory

MethodCommandDescription
Single file-config-file=/etc/consul.d/config.hclLoad one HCL file
Configuration folder-config-dir=/etc/consul.d/Load all .hcl files in the directory

Example directory structure when using a folder:

/etc/consul.d
├── config.hcl
├── metadata.hcl
└── service.hcl

Warning

Mixing CLI flags and configuration files can lead to unexpected overrides. Prefer HCL files for production setups.


3. Start the Consul Agent

In production environments, run Consul under a service manager (e.g., systemd on Linux). Create a unit file like this:

[Unit]
Description=Consul Agent
After=network.target

[Service]
ExecStart=/usr/local/bin/consul agent -config-dir=/etc/consul.d/
Restart=on-failure

[Install]
WantedBy=multi-user.target

The image is a slide titled "Starting the Consul Process," explaining how to start a Consul agent using a service manager like systemctl or Windows Service Manager, with configurations via command line or configuration files.

Alternatively, launch the agent manually with custom flags:

consul agent \
  -datacenter="aws" \
  -bind="10.0.10.42" \
  -data-dir="/opt/consul" \
  -encrypt="<key>" \
  -retry-join="10.0.10.64,10.4.23.98"
FlagDescriptionExample
-datacenterName of your datacenteraws
-bindAddress for RPC and gossip10.0.10.42
-data-dirPath to store Consul data/opt/consul
-encryptGossip encryption key<key>
-retry-joinPeers for initial join10.0.10.64,10.4.23.98

4. Development Mode

For quick testing or demos, start Consul in development mode. This is not recommended for production.

consul agent -dev
  • Runs entirely in memory (no disk persistence)
  • Enables Connect (service mesh) on port 8502
  • Suitable for single-node experiments

To stop the dev agent, press Ctrl+C.


Now you have the basics: installing Consul, writing configurations, and starting the agent in both production and development modes. Next up: service registration and health checks.


Watch Video

Watch video content

Previous
Objective 2 Section Overview