首页 > 其他分享 >DCC从编译到运行

DCC从编译到运行

时间:2022-12-01 17:23:21浏览次数:60  
标签:opt lib so.1 DCC 编译 binarylibs openGauss 运行

Distributed Configuration Center

分布式配置中心,基于DCF实现的一个状态机,用于实现集群中配置信息管理;

openGauss CM依赖DCC组件对配置数据分布式存取,实现集群配置管理高可用能力;

一、工程说明

1. 编程语言:C

2. 编译工程:cmake或make,建议cmake

3. 目录说明:

  • DCC:主目录,CMakeLists.txt为主工程入口;
  • src: 源代码目录,按子目录划分模块解耦;
  • test:测试工程
  • build:工程构建脚本

二、编译指导

注意事项:

环境要求:

操作系统:CentOS 7.6 64位

cmake版本:cmake-3.20.2

gcc与g++版本:7.3.1

安装目录:/opt/

1. 安装依赖库

yum -y install openssl openssl-devel libaio libaio-devel

2. 准备第三方库源码

cd /opt/

# 下载
wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.1.0/binarylibs/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz

# 解压
tar -zxvf openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz

3. 修复第三方库软链接问题

cd /opt/openGaussthird_party_binarylibs_Centos7.6_x86_64/kernel/dependency/lz4/llt/lib
ln -sf liblz4.so.1.9.3 liblz4.so.1
ln -sf liblz4.so.1 liblz4.so

cd /opt/openGaussthird_party_binarylibs_Centos7.6_x86_64/kernel/dependency/lz4/comm/lib
ln -sf liblz4.so.1.9.3 liblz4.so.1
ln -sf liblz4.so.1 liblz4.so

4. 添加第三方库链接路径

4.1. 新建文件,进入编辑模式

vim /etc/ld.so.conf.d/openGauss-3rd-binarylibs.conf

4.2. 写入如下内容,保存并退出

/opt/openGauss-third_party_binarylibs_Centos7.6_x86_64/kernel/component/cbb/lib
/opt/openGauss-third_party_binarylibs_Centos7.6_x86_64/kernel/component/dcf/lib
/opt/openGauss-third_party_binarylibs_Centos7.6_x86_64/kernel/component/dcc/lib

4.3. 使文件生效

ldconfig

5. 下载DCC源码

cd /opt/

git clone https://gitee.com/opengauss/DCC.git

注意:如需编译 test/test_main/ 目录下的 dcc_main 程序,则需要修改DCC项目中
build/linux/openguass/build.sh 文件的 141 行,把 -DTEST=OFF 改成 -DTEST=ON

6. 编译DCC源码

进入DCC项目目录,使用命令sh build.sh -3rd [binarylibs path] -m Debug -t cmake进行编译。各参数意义如下:

选项 参数 说明
-3rd [binarylibs path] 指定binarylibs路径。该路径必须是绝对路径。
-m [version_mode] 编译目标版本,Debug或者Release。默认Release
-t [build_tool] 指定编译工具,cmake或者make。默认cmake。
cd /opt/DCC/

sh build.sh -3rd /opt/openGauss-third_party_binarylibs_Centos7.6_x86_64 -m Debug -t cmake

注意:最后一步可直接使用 cmake、make 两步(而不使用 build.sh,好处是可调节编译参数):

cmake -DCMAKE_BUILD_TYPE=Release -DTEST=ON -DUT=OFF -DENABLE_GCOV=OFF -
DENABLE_DCC_LITE=ON -DENABLE_MEMCHECK=OFF -DENABLE_EXPORT_API=ON

make -sj 8

完成编译后,动态库生成在DCC/output/lib目录中

7. 检查动态库链接

ldd /opt/DCC/output/bin/dcc_server

若出现如下情况(很多not found),则说明动态库链接有问题,需执行步骤8;

		linux-vdso.so.1 =>  (0x00007ffe9b7fe000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fa4639aa000)
        libdcf.so => /opt/openGauss-third_party_binarylibs_Centos7.6_x86_64/kernel/component/dcf/lib/libdcf.so (0x00007fa4534fe000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fa4532e2000)
        librt.so.1 => /lib64/librt.so.1 (0x00007fa4530da000)
        libzstd.so.1 => not found
        libssl.so.1.1 => not found
        libcrypto.so.1.1 => not found
        liblz4.so.1 => /lib64/liblz4.so.1 (0x00007fa452ecb000)
        libcjson.so.1 => not found
        libgstor.so => /opt/openGauss-third_party_binarylibs_Centos7.6_x86_64/kernel/component/dcc/lib/libgstor.so (0x00007fa4527f9000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fa4524f7000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fa452129000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fa4648be000)
        libzstd.so.1 => not found
        libssl.so.1.1 => not found
        libcrypto.so.1.1 => not found
        libcjson.so.1 => not found
        libz.so.1 => /lib64/libz.so.1 (0x00007fa451f13000)
        libzstd.so.1 => not found
        libssl.so.1.1 => not found
        libcrypto.so.1.1 => not found

8. 添加环境变量

8.1. 打开 ~/.bashrc 文件,进入编辑模式

vim ~/.bashrc

8.2. 添加如下内容

export DCC_BASE=/opt/DCC
export DCC_LIBRARY=$DCC_BASE/library
export DCC_LIB_ZSTD=$DCC_LIBRARY/zstd
export DCC_LIB_OPENSSL=$DCC_LIBRARY/openssl
export DCC_LIB_LZ4=$DCC_LIBRARY/lz4
export DCC_LIB_CJSON=$DCC_LIBRARY/cJSON
export LD_LIBRARY_PATH=$DCC_LIB_ZSTD/lib:$DCC_LIB_OPENSSL/lib:$DCC_LIB_LZ4/lib:$DCC_LIB_CJSON/lib:$LD_LIBRARY_PATH

8.3. 保存退出 ,使文件生效

source ~/.bashrc

该步骤执行完毕后,重新执行步骤7,检查动态库链接情况。若出现以下情况,说明动态库链接的问题已被解决;否则需要另想办法进行解决。

        linux-vdso.so.1 =>  (0x00007ffd52a7e000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fc59bb53000)
        libdcf.so => /opt/openGauss-third_party_binarylibs_Centos7.6_x86_64/kernel/component/dcf/lib/libdcf.so (0x00007fc58b6a7000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc58b48b000)
        librt.so.1 => /lib64/librt.so.1 (0x00007fc58b283000)
        libzstd.so.1 => /opt/DCC/library/zstd/lib/libzstd.so.1 (0x00007fc58afb3000)
        libssl.so.1.1 => /opt/DCC/library/openssl/lib/libssl.so.1.1 (0x00007fc58ad22000)
        libcrypto.so.1.1 => /opt/DCC/library/openssl/lib/libcrypto.so.1.1 (0x00007fc58a85f000)
        liblz4.so.1 => /opt/DCC/library/lz4/lib/liblz4.so.1 (0x00007fc58a626000)
        libcjson.so.1 => /opt/DCC/library/cJSON/lib/libcjson.so.1 (0x00007fc58a41b000)
        libgstor.so => /opt/openGauss-third_party_binarylibs_Centos7.6_x86_64/kernel/component/dcc/lib/libgstor.so (0x00007fc589cb5000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fc5899b3000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fc5895e5000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fc59ca71000)
        libz.so.1 => /lib64/libz.so.1 (0x00007fc5893cf000)

通过对比可以发现,原来显示not found的动态库,均为DCC项目编译完毕后生成的动态库。

9. 运行调试

9.1. 运行dcc_server

(1)在 DCC项目的output/data/cfg/ 目录下(无则创建)新建dcc_server.ini文件,写入以下内容:

node_id=1
ENDPOINT_LIST=[{"stream_id": 1, "node_id": 1, "ip": "127.0.0.1", "port": 1701, "role": "LEADER"}]
DCC_SSL_ENABLE=0

(2)通过以下命令运行:

./output/bin/dcc_server -D ./output/data/

9.2. 运行dcc_ctl

(1)使用dcc_ct插入一对值:

./output/bin/dcc_ctl --endpoints 127.0.0.1:9000 --put key1 value20

(2)使用dcc_ctl进行查询:

./output/bin/dcc_ctl --endpoints 127.0.0.1:9000 --get key1 value20

标签:opt,lib,so.1,DCC,编译,binarylibs,openGauss,运行
From: https://www.cnblogs.com/AnkleBreaker-ZHX/p/16942078.html

相关文章