ceph内网单机调试环境的搭建

内网环境搭建ceph的单机调试环境:

由于是内网环境,无法连接外网,因此在搭建ceph的调试环境时,无法同步很多子模块,这些子模块都是独立成库的。因此,我们需要ceph本身,连同一些子模块一并入内网的库,同时将ceph文件中子模块的链接更改为指向内网。

ceph version:jewel

查看autogen.sh文件,在此处会同步子模块:

if test -d ".git" ; then
  force=$(if git submodule usage 2>&1 | grep --quiet 'update.*--force'; then echo --force ; fi)
  if ! git submodule sync || ! git submodule update $force --init --recursive; then
    echo "Error: could not initialize submodule projects"
    echo "  Network connectivity might be required."
    exit 1
  fi
fi

git submodule 会同步所有的子模块,子模块的链接配置文件是.gitmodules文件,v11.0.0需要以下几个模块:

[submodule "ceph-object-corpus"]
    path = ceph-object-corpus
    url = https://github.com/ceph/ceph-object-corpus.git
[submodule "src/civetweb"]
    path = src/civetweb
    url = https://github.com/ceph/civetweb
[submodule "src/erasure-code/jerasure/jerasure"]
    path = src/erasure-code/jerasure/jerasure
    url = https://github.com/ceph/jerasure.git
    branch = v2-ceph
[submodule "src/erasure-code/jerasure/gf-complete"]
    path = src/erasure-code/jerasure/gf-complete
    url = https://github.com/ceph/gf-complete.git
    branch = v2-ceph
[submodule "src/rocksdb"]
    path = src/rocksdb
    url = https://github.com/ceph/rocksdb
    ignore = dirty
[submodule "ceph-erasure-code-corpus"]
    path = ceph-erasure-code-corpus
    url = https://github.com/ceph/ceph-erasure-code-corpus.git
[submodule "src/gmock"]
    path = src/gmock
    url = https://github.com/ceph/gmock.git
    branch = ceph-release-1.7.0
[submodule "src/spdk"]
    path = src/spdk
    url = https://github.com/ceph/spdk.git
[submodule "src/xxHash"]
    path = src/xxHash
    url = https://github.com/ceph/xxHash.git

这些都是我们需要进行同步的,还有一个gtest模块,是gmock的子模块,也需要同步。其链接位于gmock branch ceph-release-1.7.0分支中的.gitmodules;因此共有10个模块需要迁移至内网,可以自己写个脚本来弄。内网的代码仓库是gitlab,具有python接口,因此可以很方便的通过python实现自动创建项目及同步项目。【留白】(同步一下python操作gitlab的脚本代码)。

完成代码的迁移后,将ceph及子项目的.gitmodules中的url更改为内部源的url地址,要更改指定分支的.gitmodules,如gmock要更改ceph-release-1.7.0分支下的.gitmodules子项目的url。

要注意:./autogen.sh中运行git submodule update时,会将子项目切换至指定的提交,此提交可能与在.gitmodules记录的branch不一致,此时,其切换是根据历史记录,而非.gitmodules。此时需要注意。如ceph中gmock会切换至提交49beb,此提交与ceph-release-1.7.0并不一致,所以即使更改了gmock的.gitmodules,也会提示无法下载gtest,此时的.gitmodules仍是旧的,出现这种情况,可以去更改.git/modules/src/gmock/config中去更改,然后重新运行autogen.sh。

./install-deps.sh:#安装一些依赖包,在此脚本中会有一个配置源的动作,如果在内网,且有自己的内部源的话,将此动作注释掉,否则会安装依赖失败。

./autogen.sh

后面的话就运行:

./configure  --with-debug  #加上debug选项,方便后面利用gdb进行调试

make

编译成功后就可以进入调试环境:

./vstart.sh #需要你指明很多参数,如mon,osd的个数等等

L版: ../src/vstart.sh -n -d -l --mon_num 1 --osd_num 1 --rgw_num 1

master:MON_NUM=1 MGR_NUM=1 OSD_NUM=1 RGW_NUM=1 ../src/vstart.sh -n -d -l

gdb program {process id}调试

./ceph -s #运行一些ceph的命令

./stop #退出调试环境

注:

编译会需要很多依赖包:

./install-deps.sh #安装一些依赖包

make过程中可能会出错,如:

src/gmock/lib/libgmock_main.la needed by libgw_file_cd

libgmock_main.la是gmock编译得到的,而在ceph的Makefile文件中可能对gmock编译的顺序有问题。因此,我们进入gmock自己手动编译一下:

cd src/gmock
make
cd -
make

  

注:

对于子项目具有子项目的情况,可以通过更新父项目中子项目的commit id的记录,实现在递归下载子项目时,可以有效的指向内网链接。如上述中gmock项目,首先在内网克隆ceph, git submodule init; git submodule update; 进入gmock,vim .gitmodules,更新子项目链接;git add -a;git commit -m "";git push; 进入ceph根目录,git add -u;git commit -m ""; git push。

posted @ 2016-11-28 20:28  舒克_贝塔  阅读(751)  评论(0)    收藏  举报