he3db基于docker centos8编译

214 阅读2分钟

(1)下载centos8镜像

sudo docker pull centos:centos8

sudo docker run -itd --name c8 centos:centos8

sudo docker exec -it c8 /bin/bash

 

(2)进入docker容器环境变更centos8的yum源

mv /etc/yum.repos.d/ /etc/yum.repos.d_bak && mkdir /etc/yum.repos.d/

curl -o /etc/yum.repos.d/CentOS-Base.repo mirrors.aliyun.com/repo/Centos…

sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

dnf makecache

 

(3)创建数据库用户

yum -y update

yum -y install passwd sudo zip unzip tar

yum -y install git

----创建数据库用户

useradd postgres

passwd postgres

----给用户sudo权限(看实际情况给予)

chmod u+w /etc/sudoers

vi /etc/sudoers

chmod u-w /etc/sudoers

(4)切换到数据库用户准备编译环境

su - postgres

sudo yum -y install \

cmake \

gcc \

gcc-c++ \

automake \

autoconf \

libtool \

make \

bison \

flex \

readline \

readline-devel \

ncurses-devel \

zlib \

zlib-devel \

glib2-devel \

 

(5)上传其余依赖组件---建议外部环境上编译后直接拷贝库到容器内

将压缩文件拷贝进Docker容器内:sudo docker XX/prom.zip 容器id或者容器名字:容器内路径

动态库放到/lib64目录下,然后执行ldconfig。

头文件编译的时候可使用--with-includes指定访问路径。

1:libmicrohttpd库安装

wget ftp.gnu.org/gnu/libmicr… -O libmicrohttpd-0.9.63.tar.gz

tar -xzf libmicrohttpd-0.9.63.tar.gz

cd libmicrohttpd-0.9.63

./configure --enable-shared=no --disable-doc --disable-examples --enable-https=no --disable-messages

sudo make install

 

2:Prom工具:

【源码编译】

ubuntu: doc/he3db/prom.md · He3DB/He3PG - Gitee.com

Centos: 只能从官网下载源码编译

 

3:Rust工具:

【源码编译】

源码文件在gitee.com/he3db/he3fs…kv/pgfsgrpc 中,为dev_kv分支,后续可能会有变化,需要注意,可通过cargo build进行编译构建

(6)He3DB源码编译

#创建源码目录

mkdir code

#创建编译后的二进制文件目录

mkdir app

cd code

git init

git remote add upstream gitee.com/he3db/he3pg…

git fetch upstream

git reset --hard upstream/dev_performance

#编译debug版本

./configure --prefix=/home/postgres/app --with-includes=/home/postgres/tools/libprom/include:/home/postgres/tools/libpromhttp/include:/usr/lib64/glib-2.0/include  --enable-debug --enable-depend --enable-cassert CFLAGS="-O0"

make && make install

#编译release版本

./configure --prefix=/home/postgres/app --with-includes=/home/postgres/tools/libprom/include:/home/postgres/tools/libpromhttp/include:/usr/lib64/glib-2.0/include

make && make install  

Q&A****

(1)编译报错找不到某个头文件

 

解决方法:

查找文件的目录: find / -name ‘文件名’ ,并将这个文件目录加入编译命令中

./configure --prefix=/home/postgres/app --with-includes=/home/postgres/tools/libprom/include:/home/postgres/tools/libpromhttp/include:/usr/lib64/glib-2.0/include  --enable-debug --enable-depend --enable-cassert CFLAGS="-O0"

如果find查找没有这个依赖,需要安装的安装,需要拷贝的拷贝