Host Deployment

This guide covers installing HUATUO from a tar archive or RPM and managing it with systemd. Check the resource limits before starting, then verify the service status after installation.

Tar Archive

HUATUO releases provide static Linux tar archives for amd64 and arm64. Each archive contains the huatuo-bamai and huatuo-apiserver binaries, configuration files, and BPF objects.

These commands apply to releases with assets named huatuo-bamai-<version>-static-linux-<arch>.tar.gz. This naming scheme starts with v2.2.0; archives for v2.0.0 and v2.1.0 have different names and cannot use these commands unchanged.

Set HUATUO_VERSION to the target release, such as v2.2.0:

HUATUO_VERSION="<release-version>"

1. Download the Archive

On x86_64 hosts, download the amd64 archive:

wget "https://github.com/ccfos/huatuo/releases/download/${HUATUO_VERSION}/huatuo-bamai-${HUATUO_VERSION}-static-linux-amd64.tar.gz"

On aarch64 hosts, download the arm64 archive:

wget "https://github.com/ccfos/huatuo/releases/download/${HUATUO_VERSION}/huatuo-bamai-${HUATUO_VERSION}-static-linux-arm64.tar.gz"

2. Install the Archive

Create the installation, log, and data directories:

sudo install -d -m 0755 /opt/huatuo-bamai /var/log/huatuo-bamai /var/lib/huatuo-bamai

amd64:

sudo tar -xzf "huatuo-bamai-${HUATUO_VERSION}-static-linux-amd64.tar.gz" --strip-components=1 --no-same-owner -C /opt/huatuo-bamai

arm64:

sudo tar -xzf "huatuo-bamai-${HUATUO_VERSION}-static-linux-arm64.tar.gz" --strip-components=1 --no-same-owner -C /opt/huatuo-bamai

3. Install Service Units

Download the service units from the corresponding source release:

sudo wget -O /etc/systemd/system/huatuo-bamai.service "https://raw.githubusercontent.com/ccfos/huatuo/${HUATUO_VERSION}/build/rpm/huatuo-bamai.service"
sudo wget -O /etc/systemd/system/huatuo-apiserver.service "https://raw.githubusercontent.com/ccfos/huatuo/${HUATUO_VERSION}/build/rpm/huatuo-apiserver.service"

4. Edit the Configuration

Edit /opt/huatuo-bamai/conf/huatuo-bamai.conf and /opt/huatuo-bamai/conf/huatuo-apiserver.conf for your environment. See the huatuo-bamai configuration and huatuo-apiserver configuration for field details.

Set resource limits with CPUQuota, MemoryMax, and TasksMax in the service unit. Configure [Runtime] only when running directly with --enable-cgroup.

5. Reload Service Configuration

Reload the systemd configuration:

sudo systemctl daemon-reload

6. Start the Services

Start the services and enable them at boot:

sudo systemctl enable --now huatuo-bamai huatuo-apiserver

RPM Package

The OpenCloudOS repository provides HUATUO v2.1.0 RPM packages for x86_64 and aarch64. These packages install the HUATUO files and systemd service units.

1. Download the RPM

Download the package for your host architecture:

x86_64:

wget https://mirrors.opencloudos.tech/epol/9/Everything/x86_64/os/Packages/huatuo-bamai-2.1.0-2.oc9.x86_64.rpm

aarch64:

wget https://mirrors.opencloudos.tech/epol/9/Everything/aarch64/os/Packages/huatuo-bamai-2.1.0-2.oc9.aarch64.rpm

2. Install the RPM

x86_64:

sudo dnf install ./huatuo-bamai-2.1.0-2.oc9.x86_64.rpm

aarch64:

sudo dnf install ./huatuo-bamai-2.1.0-2.oc9.aarch64.rpm

3. Edit the Configuration

Edit /etc/huatuo-bamai/huatuo-bamai.conf for your environment. See the huatuo-bamai configuration for field details.

Set resource limits with CPUQuota, MemoryMax, and TasksMax in the service unit. Configure [Runtime] only when running directly with --enable-cgroup.

4. Start the Service

The RPM installs huatuo-bamai.service. Start the service and enable it at boot:

sudo systemctl enable --now huatuo-bamai

See the RPM installation guide for the full instructions.

Resource Limits and Verification

Systemd manages resource limits and the process lifecycle for huatuo-bamai.service. The service unit does not enable Huatuo’s own cgroup by default. It uses these native settings:

[Service]
CPUAccounting=yes
CPUQuota=200%
MemoryAccounting=yes
MemoryMax=2G
TasksAccounting=yes
TasksMax=32768
KillMode=control-group

CPUQuota=200% allows up to 2 CPU cores; MemoryMax=2G limits service memory. Adjust these values for host capacity, collection tasks, and peak usage. Do not pass --enable-cgroup in systemd deployments, as it moves the process out of the service cgroup.

After starting the service, check its status and cgroup:

systemctl status huatuo-bamai --no-pager
systemd-cgls --unit huatuo-bamai.service