Besu

Installing and configuring Hyperledger Besu as a systemd service.

Besu

Hyperledger Besu is an Ethereum client designed with enterprise-grade use cases in mind. It is developed under the Hyperledger umbrella and is written in Java, making it the most mature choice for corporate environments familiar with the JVM (Java Virtual Machine).

🛡️ Role: Besu is an excellent choice for Client Diversity. It implements unique storage features like "Bonsai Tries," which optimize data storage and access speeds significantly compared to older archive node structures.


1. Install Dependencies (Java)

Besu requires a Java Runtime Environment (JRE). We recommend Java 21 LTS for the best performance and compatibility with recent Besu releases.

Bash

# Update repositories
sudo apt update

# Install OpenJDK 21
sudo apt install -y openjdk-21-jre-headless

# Verify Java installation
java -version

2. Download & Install

We will download the latest binary release from the official Hyperledger repository.

A. Create the Application Directory

Bash

# Create a folder for the binary
sudo mkdir -p /usr/local/lib/besu

# Download the latest Linux release (Check https://github.com/hyperledger/besu/releases for newer versions)
# Example for version 24.1.2:
sudo wget https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/24.1.2/besu-24.1.2.tar.gz -O besu.tar.gz

# Extract the archive
sudo tar -xvzf besu.tar.gz -C /usr/local/lib/besu --strip-components=1

# Cleanup
rm besu.tar.gz

B. Set Permissions Ensure the ethereum user owns the directory.

Bash

sudo chown -R ethereum:ethereum /usr/local/lib/besu

3. Configure Systemd Service

We will configure Besu to run as a background service.

Create the service file:

Bash

sudo nano /etc/systemd/system/besu.service

Paste the following configuration:

Ini, TOML

[Unit]
Description=Besu Execution Client
After=network.target

[Service]
User=ethereum
Group=ethereum
Type=simple
Restart=always
RestartSec=5

# Environment variables (Optional java options)
Environment="JAVA_OPTS=-Xmx8g"

# Execution Command
ExecStart=/usr/local/lib/besu/bin/besu \
  --network=mainnet \
  --data-path=/home/ethereum/execution \
  --data-storage-format=BONSAI \
  --sync-mode=X_SNAP \
  --engine-jwt-enabled=true \
  --engine-jwt-secret=/home/ethereum/jwt/jwt.hex \
  --engine-host-allowlist="*" \
  --rpc-http-enabled=true \
  --rpc-http-host=0.0.0.0 \
  --rpc-http-port=8545 \
  --rpc-http-cors-origins="*" \
  --rpc-http-api=ETH,NET,WEB3,CLIQUE,MINER,ADMIN

# Resource Limits
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target

🔍 Flag Explanation:

  • --data-storage-format=BONSAI: Enables Besu's optimized storage format (Essential for performance).

  • --sync-mode=X_SNAP: Uses Snap Sync to download the state quickly.

  • JAVA_OPTS=-Xmx8g: Limits Java to 8GB of Heap RAM. Adjust this based on your total system RAM (keep it to ~50% of available RAM).


4. Start the Service

Reload the systemd daemon and start the node.

Bash

# Reload systemd configuration
sudo systemctl daemon-reload

# Enable Besu to start on boot
sudo systemctl enable besu

# Start the service
sudo systemctl start besu

5. Verify Status

Check the logs to ensure Besu is initializing correctly.

Bash

sudo journalctl -fu besu

Expected Output:

  1. Bonsai: You should see logs referencing Bonsai storage initialization.

  2. Engine API: Look for WebSocketService or JsonRpcHttpService starting on ports 8551/8545.

  3. Waiting: Similar to other clients, it will wait for the Consensus Client to begin the sync process.

Last updated