openEuler欧拉系统编译InfluxDB2.0.6(Go、rust编译)

环境准备

go安装

前往官网下载1.19版本的安装包,运行命令:

tar -C /usr/local -zxf go1.19.tar.gz
export PATH=$PATH:/usr/local/go/bin
go开启代理
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn

rust安装

通过查看flux@0.113.0源码的Dockerfile_build文件,可知使用的是1.51.0的Rust。一般来说,Rust编译器会有向后兼容性,但涉及到一些重大语法或规则更新时会出现编译不通过的情况。此处如果使用了最新版的Rust,会出现后文中Q7的问题。

执行命令:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh  -s -- --default-toolchain "1.51.0" -y
export PATH="$HOME/.cargo/bin:${PATH}"
rustc --version
cargo开启代理

通过命令vi ~/.cargo/config.toml写入以下内容:

[source.crates-io]
replace-with = 'tuna'

[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"

[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"

[source.rustcc]
registry = "git://crates.rustcc.cn/crates.io-index"

[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"

安装编译工具

GCC安装

执行命令:

yum -y install gcc gcc-c++
influxdata pkg-config安装

安装influxdata的pkg-config:

go install github.com/influxdata/pkg-config@latest
# 查看安装结果
ll ~/go/bin

编译源码

github下载v2.0.6版本的influxdb源码:influxdb-2.0.6.tar.gz
cd进项目根目录influxdb-2.0.6,运行:

PKG_CONFIG=~/go/bin/pkg-config CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -o test -v cmd/influxd/main.go

编译完成后,运行测试:

./test --help

Q&A

Q1. 编译报错提示undefined: libflux.ASTPkg

github.com/influxdata/flux/parser
# github.com/influxdata/flux/parser
/home/ecx/go/pkg/mod/github.com/influxdata/flux@v0.113.0/parser/parser.go:88:30: undefined: libflux.ASTPkg
/home/ecx/go/pkg/mod/github.com/influxdata/flux@v0.113.0/parser/parser.go:92:42: undefined: libflux.ASTPkg
/home/ecx/go/pkg/mod/github.com/influxdata/flux@v0.113.0/parser/parser.go:93:17: undefined: libflux.ParseString
/home/ecx/go/pkg/mod/github.com/influxdata/flux@v0.113.0/parser/libflux_parser.go:10:21: undefined: libflux.Parse

A1. 打开CGO_ENABLED开关:

CGO_ENABLED=1

Q2. 编译报错提示No package 'flux' found

github.com/influxdata/flux/libflux/go/libflux
# pkg-config --cflags  -- flux
Package flux was not found in the pkg-config search path.
Perhaps you should add the directory containing `flux.pc'
to the PKG_CONFIG_PATH environment variable
No package 'flux' found
pkg-config: exit status 1

A2. 查看flux文档GO论坛,安装influxdata的pkg-config:

go install github.com/influxdata/pkg-config@latest
ll ~/go/bin

Q3. 提示"gcc": executable file not found in $PATH

cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH

A3. 安装gcc:

yum -y install gcc gcc-c++

Q4. 提示gcc: error: unrecognized command line option '-m64'

runtime/cgo
# runtime/cgo
gcc: error: unrecognized command line option '-m64'
Error installing library        {"name": "flux", "error": "exec: \"cargo\": executable file not found in $PATH"}

A4. 使用arm64架构:

GOARCH=arm64

Q5. 提示\"cargo\": executable file not found in $PATH"

Error installing library        {"name": "flux", "error": "exec: \"cargo\": executable file not found in $PATH"}

A5. 安装rust:

# 1.51.0版,推荐
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain "1.51.0" -y
# 最新版,会遇到问题Q7
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Q6. 提示Failed to connect to static.crates.io

Caused by:
  [7] Couldn't connect to server (Failed to connect to static.crates.io port 443 after 0 ms: Couldn't connect to server)
Error installing library        {"name": "flux", "error": "exit status 101"}

A6. 更改cargo镜像地址,参考上文cargo开启代理部分内容


Q7. 编译flux-core报错:

error: variable does not need to be mutable
  --> flux-core/src/ast/flatbuffers/mod.rs:79:13
   |
79 |         let mut v = &mut *self.inner.borrow_mut();
   |             ----^
   |             |
   |             help: remove this `mut`
   |
note: the lint level is defined here
  --> flux-core/src/lib.rs:1:38
   |
1  | #![cfg_attr(feature = "strict", deny(warnings, missing_docs))]
   |                                      ^^^^^^^^
   = note: `#[deny(unused_mut)]` implied by `#[deny(warnings)]`

error: field `message` is never read
  --> flux-core/src/parser/mod.rs:35:9
   |
34 | struct TokenError {
   |        ---------- field in this struct
35 |     pub message: String,
   |         ^^^^^^^
   |
   = note: `#[deny(dead_code)]` implied by `#[deny(warnings)]`

error: could not compile `flux-core` (lib) due to 2 previous errors

A7. 原因是rust新版无法编译flux@0.113.0,新编译器语法检查不兼容旧代码。rust切换到1.51.0版本:

# 若已安装其他版本的rust,执行以下三步:
rustup install 1.51.0
rustup toolchain list
rustup default 1.51.0-x86_64-unknown-linux-gnu
# 若以上三步提示网络错误或未安装rust则执行:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh  -s -- --default-toolchain "1.51.0" -y
<think>好的,我需要回答用户关于OpenEuler安装源镜像地址及配置方法的问题。首先,我要根据用户提供的引用内容来整理正确的信息。用户提到了几个引用,其中大部分都提到了华为云的镜像地址,例如https://repo.huaweicloud.com/openeuler/和https://mirrors.huaweicloud.com/openeuler/。这些引用中的步骤包括编辑openEuler.repo文件,替换镜像地址,备份原文件等。 接下来,我需要确保步骤正确无误。例如,引用3中提到使用sed命令替换repo文件中的URL,而引用4建议先备份原文件。用户可能使用的是openEuler 24.09版本,所以需要确认镜像地址是否包含该版本路径。此外,引用5提到配置镜像源来加速docker镜像拉取,这可能与YUM源不同,但用户的问题主要针对安装源,所以暂时不需要涉及docker部分。 然后,我需要将步骤分点说明,确保清晰易懂。首先备份原配置文件,然后创建或编辑.repo文件,替换正确的镜像地址,最后更新缓存。可能还需要检查版本号是否正确,并提醒用户注意权限问题,比如使用sudo命令。 用户还要求生成相关问题,我需要考虑用户可能的后续疑问,比如如何验证配置是否成功,遇到问题如何解决,如何恢复备份,或者是否有其他镜像源可用。这些问题有助于用户进一步操作和故障排除。 最后,要确保所有引用正确对应,比如步骤中的备份文件对应引用4,替换镜像地址对应引用3,镜像地址本身来自引用1、2、3。同时,检查是否有遗漏的信息或可能的错误,比如不同引用中的镜像地址是否一致,确保给出的步骤准确可靠。</think>### OpenEuler 安装源镜像地址及配置方法 #### 镜像地址 1. **华为云镜像源**:支持多版本,根据系统版本选择对应路径: - 基础地址:`https://repo.huaweicloud.com/openeuler/` 或 `https://mirrors.huaweicloud.com/openeuler/`[^1][^2][^3] - 具体版本路径示例(如24.09):`https://mirrors.huaweicloud.com/openeuler/openEuler-24.09/` #### 配置步骤 **步骤1:备份原配置文件** ```bash sudo mv /etc/yum.repos.d/openEuler.repo /etc/yum.repos.d/openEuler.repo.bak # 备份原文件[^4] ``` **步骤2:创建或编辑镜像源文件** 新建或修改`openEuler.repo`文件,写入以下内容(以24.09版本为例): ```ini [openEuler] name=openEuler-24.09 baseurl=https://mirrors.huaweicloud.com/openeuler/openEuler-24.09/ enabled=1 gpgcheck=1 gpgkey=https://mirrors.huaweicloud.com/openeuler/openEuler-24.09/OS/$basearch/RPM-GPG-KEY-openEuler ``` *注:若需其他版本,替换URL中的版本号即可[^1]。* **步骤3:快速替换镜像地址(替代步骤2的快捷方式)** 若原文件已存在,可直接执行命令替换镜像源: ```bash sudo sed -i 's|http://repo.openeuler.org/|https://mirrors.huaweicloud.com/openeuler/|g' /etc/yum.repos.d/openEuler.repo # 批量替换域名[^3] ``` **步骤4:更新YUM缓存** ```bash sudo yum clean all && sudo yum makecache # 刷新缓存 ``` #### 验证配置 ```bash yum repolist # 检查镜像源是否生效 ```
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值