编译OpenWRT x86_64可运行的filebeat

created
updated
category Category: OpenWRT
tags Tag: ELK Tag: Linux Tag: OpenWRT

Arch Linux 环境中交叉编译可在 x86 OpenWrt 上运行的 Filebeat 二进制文件。

git clone git@github.com:elastic/beats.git --depth=1
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o filebeat-openwrt-x86_64 -ldflags="-s -w" .

参数:

参数说明
GOOS=linux目标操作系统为 Linux
GOARCH=amd64目标架构为 x86_64 (64位)
CGO_ENABLED=0禁用 CGO,生成完全静态链接的二进制文件,无需动态库依赖
-o filebeat-openwrt-x86_64输出文件名
-ldflags="-s -w"链接器参数:-s 去除符号表,-w 去除 DWARF 调试信息

Pasted image 20251207164525.png

comments