网上可参考的Milvus源码安装教程资料太少,且不全,会缺少很多依赖安装,导致最后编译安装会遇到很多问题,在此,整理自己源码编译安装的全过程,方便日后查看。
根据此教程进行部署安装Golang开发环境。
由于Milvus是GO语言开发,所以需要先安装Golang,版本要求>=1.16即可。
OpenBLAS是向量计算库,参考此教程部署安装。
1.先安装必要依赖工具:
sudo apt-get update && \
# common utils for download sources tarball/zipball
sudo apt-get install -y --no-install-recommends curl wget ca-certificates gnupg2 && \
# openblas deps
sudo apt-get install -y --no-install-recommends g++ gcc gfortran git make && \
# cleanup
sudo apt-get remove --purge -y
OPENBLAS_VERSION=0.3.9 && \
wget "https://github.com/xianyi/OpenBLAS/archive/v${OPENBLAS_VERSION}.tar.gz"
tar -zxvf xxx.tar.gz
cd xxx
sudo make TARGET=CORE2 DYNAMIC_ARCH=1 DYNAMIC_OLDER=1 USE_THREAD=0 USE_OPENMP=0 FC=gfortran CC=gcc COMMON_OPT="-O3 -g -fPIC" FCOMMON_OPT="-O3 -g -fPIC -frecursive" NMAX="NUM_THREADS=128" LIBPREFIX="libopenblas" LAPACKE="NO_LAPACKE=1" INTERFACE64=0 NO_STATIC=1
make[1]: Leaving directory '/app/OpenBLAS-0.3.9/exports'
OpenBLAS build complete. (BLAS CBLAS LAPACK LAPACKE)
OS ... Linux
Architecture ... x86_64
BINARY ... 64bit
C compiler ... GCC (command line : gcc)
Fortran compiler ... GFORTRAN (command line : gfortran)
Library Name ... libopenblas-r0.3.9.a (Single threaded)
To install the library, you can run "make PREFIX=/path/to/your/installation install".
sudo make -j4 PREFIX=/usr NO_STATIC=1 install
make[1]: Entering directory '/app/milvus/OpenBLAS-0.3.9'
Generating openblas_config.h in /usr/include
Generating f77blas.h in /usr/include
Generating cblas.h in /usr/include
Copying LAPACKE header files to /usr/include
Copying the shared library to /usr/lib
Generating openblas.pc in /usr/lib/pkgconfig
Generating OpenBLASConfig.cmake in /usr/lib/cmake/openblas
Generating OpenBLASConfigVersion.cmake in /usr/lib/cmake/openblas
Install OK!
make[1]: Leaving directory '/app/milvus/OpenBLAS-0.3.9'
rm -rf xxx.tar.gz
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup install 1.73.0
查看cargo和rustup版本是否均为1.73.0
cargo --version
rustc --version
设置为默认版本并确认cargo和rust版本
rustup default 1.73.0
输入以下命令确保已设为默认版本:
rustup toolchain list
参考此教程。
wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz && \
tar zxf release-1.8.0.tar.gz && \
rm -f release-1.8.0.tar.gz && \
cd googletest-release-1.8.0 && \
cmake . && \
make && \
make install
sudo apt-get install \
g++ \
cmake \
libboost-all-dev \
libevent-dev \
libdouble-conversion-dev \
libgoogle-glog-dev \
libgflags-dev \
libiberty-dev \
liblz4-dev \
liblzma-dev \
libsnappy-dev \
make \
zlib1g-dev \
binutils-dev \
libjemalloc-dev \
libssl-dev \
pkg-config \
libunwind-dev
git clone https://github.com/fmtlib/fmt.git && cd fmt
mkdir _build && cd _build
cmake ..
make -j$(nproc)
sudo make install
apt-get install \
libunwind8-dev \
libelf-dev \
libdwarf-dev
git clone https://github.com/facebook/folly.git
编译安装folly
cd folly
mkdir _build && cd _build
cmake ..
make -j $(nproc)
make install
到这一步,基本的前置工作已完成。
git clone https://gitee.com/milvus-io/milvus.git
cd milvus/scripts
vim 3rdparty_build.sh
搜索/cargo,找到+1.73 build替换为:
rustup run 1.73.0 cargo build --release --verbose
如果不替换使用下载的源码部署脚本编译,会报错"error:toolchain ‘1.73-x86_64-unknown-linux-gnu’ is not installed”.
回退到上一级目录,执行make milvus编译。
cd milvus
make milvus
【注】在编译的时候,请记得关掉梯子再编译!!!
若失败,make clean再次make milvus。
经过漫长的等待,最后出现下面的界面表示构建完成。
看到Build Milvus就构建成功了。
运行如下命令:
./bin/milvus
以上,Milvus 在 Ubuntu 20.04 / Ubuntu 22.04 环境中的编译安装已完成!
"fatal: destination path 'opendal' already exists and is not an empty directory.
解决办法:
rm -rf opendal/
error: toolchain '1.73-x86_64-unknown-linux-gnu' is not installed
解决办法:
更改源码脚本,将cargo +1.73 build更改为rustup run 1.73.0 cargo build --release
提示Cargo.html不存在,这种是编译的第三方库没有完整下载所以报错找不到,解决方法是删掉整个源码目录,再次编译。
无法加载共享库。
error while loading shared libraries: libfolly_exception_tracer_base.so.0.58.0 -dev: cannot open shared object file: No such file or directory
解决办法:
跟着我上面的流程走,安装了fmt,相关依赖包,及folly,依赖库肯定存在,此时,我们只需要找到这个依赖文件位置,将其放入/usr/local/lib下,再配置环境变量,使其生效即可。
find / -name libfolly_exception_tracer_base.so.0.58.0-dev 2>/dev/null
查找结果如下:
2. 制作软链接
sudo ln -s /milvus/cmake_build/lib/libfolly_exception_tracer_base.so.0.58.0-dev /usr/local/lib/libfolly_exception_tracer_base.so.0.58.0-dev
cargo部署路径要在/usr/bin之前,所以配置如下: