Building Consul - linux-on-ibm-z/docs GitHub Wiki
Building Consul
The following version of Consul are available in the respective distribution at the time of creation of these build instructions:
- Ubuntu 22.04 has
1.8.7
The instructions provided below specify the steps to build Consul version 2.0.1 on Linux on IBM Z for following distributions:
- RHEL (8.10, 9.6, 9.7, 10.0, 10.1)
- SLES (15 SP7, 16)
- Ubuntu (22.04, 24.04, 25.10)
General Notes:
- When following the steps below please use a standard permission user unless otherwise specified.
- A directory
/<source_root>/will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.
1. Build and Install Consul
1.1. Build using script
If you want to build consul using manual steps, go to STEP 1.2.
Use the following commands to build consul using the build script. Please make sure you have wget installed.
wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Consul/2.0.1/build_consul.sh
# Build consul
bash build_consul.sh [Provide -t option for executing build with tests]
If the build completes successfully, go to STEP 3. In case of error, check logs for more details or go to STEP 1.2 to follow manual build steps.
1.2. Install dependencies
export SOURCE_ROOT=/<source_root>/
-
RHEL (8.10, 9.6, 9.7, 10.0, 10.1)
sudo yum install -y curl gcc git make wget diffutils procps-ng tar python3 python3-pip -
SLES (15 SP7, 16)
sudo zypper install -y which curl gzip gcc git-core make wget awk unzip tar python3 python3-pip -
Ubuntu (22.04, 24.04, 25.10)
sudo apt-get update sudo apt-get install -y curl gcc git make wget unzip tar libc6-dev -
Add user binary path(Only for SLES)
export PATH="${SOURCE_ROOT}/.local/bin:${PATH}" -
Install Go version
1.26.4cd $SOURCE_ROOT export GO_VERSION="1.26.4" export INSTALL_DIR="${SOURCE_ROOT}/${GO_VERSION}" export GOROOT=${INSTALL_DIR} sudo mkdir -p "${INSTALL_DIR}" wget -q https://go.dev/dl/go"$GO_VERSION".linux-s390x.tar.gz chmod ugo+r go"$GO_VERSION".linux-s390x.tar.gz sudo tar -C "${INSTALL_DIR}" --strip-components=1 -xzf go"$GO_VERSION".linux-s390x.tar.gz export PATH="$GOROOT/bin:$PATH" sudo update-alternatives --install /usr/bin/s390x-linux-gnu-gcc s390x-linux-gnu-gcc /usr/bin/gcc 100 # (Only on RHEL and SLES) go version
1.3. Get the source code and build Consul
export GOPATH=$SOURCE_ROOT
mkdir -p $GOPATH/src/github.com/hashicorp
cd $GOPATH/src/github.com/hashicorp
git clone -b v2.0.1 https://github.com/hashicorp/consul.git
cd consul
make tools
make dev
export PATH="$GOPATH/bin/:$PATH"
1.4. Verifying the installation
consul -v
You will get a similar output to this:
Consul v2.0.1
Revision 16a4c49
Build Date 2026-06-19T03:47:10Z
Protocol 2 spoken by default, understands 2 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)
2. Testing (Optional)
2.1. Run test cases
cd $GOPATH/src/github.com/hashicorp/consul/
make test
The make test command will run the tests.
Notes:
- If you encounter a failure in
TestTakeReturnundergithub.com/hashicorp/consul/sdk/freeport, changing ulimit to a larger number could make the test pass. For example:
ulimit -n 2048
- If you encounter a failure in
TestDebugCommandundergithub.com/hashicorp/consul/command/debug, setting umask value to 0022 could make the test pass. For example:
umask 0022
- Some tests might fail. Re-run these tests individually and they should pass. In case of unexpected test failures, try running the test individually using command:
go test -v <package_name> -run <failed_test_name>
For example: TestHealthServiceNodes_NodeMetaFilter
go test -v github.com/hashicorp/consul/agent -run TestHealthServiceNodes_NodeMetaFilter
3. Verification (Optional)
To start a Consul cluster, please refer to Getting Started guide here.Start Consul server