前言:
本文基於ubuntu 14.04.5 LTS 和ceph v0.94.3 之上做的實驗
一、編譯ceph包
1.1.克隆ceph代碼,切換分支
git clone --recursive https://github.com/ceph/ceph.git cd ceph git checkout v0.94.3 -f
備注:recursive會把子模塊一起克隆
1.2.安裝依賴包
./install-deps.sh ./autogen.sh
1.3.編譯前配置
./configure --prefix=/
注意:這里如果不配置--prefix選項,所有程序默認安裝在/usr/local下面,在后面可能會涉及到路徑的問題
1.4.編譯
make -j 4
通過如下命令確定總核數
cat /proc/cpuinfo | grep cores
1.5.構建 Ceph deb安裝包
apt-get install debhelper dpkg-buildpackage -j8 2>err0813dpkg.txt
1.6.編譯完畢后,會有以下包存在

二、制作deb包本地安裝源
2.1.安裝dpkg-scanpackages命令
apt-get install dpkg-dev
2.2 創建ceph軟件包目錄
mkdir /home/ceph-hammer cd /home/ceph-hammer mkdir pools mkdir -p dists/trusty/main/binary-i386 mkdir -p dists/trusty/main/binary-amd64
備注:pools 為軟件包存放的物理地址
2.3 拷貝ceph軟件包到pools
cp *.deb /home/ceph-hammer/pools
2.4 生成override 文件
把pools目錄下所有的deb包包名寫入文件override中
ls -1 pools | sed 's/_.*$/ extra BOGUS/' | uniq > override
2.5生成Packages
把所有包的包名、版本號、依賴關系等信息寫入文件Packages中
dpkg-scanpackages pools override > dists/trusty/main/binary-i386/Packages dpkg-scanpackages pools override > dists/trusty/main/binary-amd64/Packages
備注:etch版本中要把Packages文件變成Packages.gz文件
2.6 更改sources.list
echo "deb file:///home/ceph-hammer trusty main " >> /etc/apt/sources.list
注意:由於ceph-deploy1.5 默認會連接網絡下載最新的版本,所以在這邊的配置,似乎不太起作用。
2.7 本地安裝源目錄結構
創建完本地安裝源后,目錄結構如下所示:

2.8設置完成,更新deb源
完成以上設置和文件復制之后,就可以開始正常使用本地的源了和使用網絡上的源一樣操作。
apt-get update apt-get dist-upgrade
三、安裝ceph
3.1 安裝前准備
關閉ubuntu的packages 認證功能,否則會報The following packages cannot be authenticated!
echo "APT::Get::AllowUnauthenticated 1 ;" | sudo tee -a /etc/apt/apt.conf
3.2.安裝並更改ceph-deploy
1.在ceph01安裝ceph-deploy
apt-get install ceph-deploy
2. 修改install.py文件
在通過ceph-deploy安裝ceph節點時(即ceph-deploy install monitor),會調用ceph-deploy的install.py,而此時會使用該腳本連接網絡下載deb包,由於使用本地源,故需修改 install.py中deb包下載的路徑。
install.py位置:/usr/lib/python2.7/dist-packages/ceph_deploy/hosts/debian/install.py
修改如下:
修改前
---------------------------
32 if version_kind == 'stable':
33 url = 'http://ceph.com/debian-{version}/'.format(
34 version=version,
35 )
36 elif version_kind == 'testing':
37 url = 'http://ceph.com/debian-testing/'
---------------------------
修改后:
---------------------------
32 if version_kind == 'stable':
33 # url = 'http://ceph.com/debian-{version}/'.format(
34 url = 'file:///home/ceph-{version}/'.format(
35 version=version,
36 )
37 elif version_kind == 'testing':
38 url = 'http://ceph.com/debian-testing/'
---------------------------
3.3 安裝ceph
見ceph官方文檔
四、所遇問題
問題1:
執行ceph-deploy install ceph01 報以下錯誤:
[ceph01][DEBUG ] The following packages have unmet dependencies:
[ceph01][DEBUG ] ceph : Depends: liblttng-ust0 (>= 2.5.1-1ubuntu2~cloud0) but 2.4.0-4ubuntu1 is to be installed
[ceph01][DEBUG ] Depends: librados2 but it is not going to be installed
[ceph01][DEBUG ] ceph-common : Depends: librbd1 (= 0.94.7-1) but it is not going to be installed
[ceph01][DEBUG ] Depends: librados2 but it is not going to be installed
[ceph01][DEBUG ] Depends: python-rados (= 0.94.7-1) but it is not going to be installed
[ceph01][DEBUG ] Depends: python-rbd (= 0.94.7-1) but it is not going to be installed
[ceph01][DEBUG ] ceph-mds : Depends: librados2 but it is not going to be installed
原因及解決過程:
執行 apt-get install librados2報
librados2 : Depends: liblttng-ust0 (>= 2.5.1-1ubuntu2~cloud0) but 2.4.0-4ubuntu1 is to be installed
E: Unable to correct problems, you have held broken packages.
用apt-cache show liblttng-ust0 查看發現環境中安裝的版本是2.4.0-4ubuntu1,而librados2需要安裝2.5.1-1ubuntu2的版本,因此報錯。
解決下載:
1.下載liblttng-ust0_2.5.1-1ubuntu2_amd64.deb
liblttng-ust-ctl2_2.5.1-1ubuntu2_amd64.deb和
liburcu2_0.8.4-6ubuntu1_amd64.deb
三個deb包
(下載地址:
liblttng-ust0_2.5.1-1ubuntu2_amd64.deb
liblttng-ust-ctl2_2.5.1-1ubuntu2_amd64.deb
https://mirror.umd.edu/ubuntu/pool/main/u/ust/
liburcu2_0.8.4-6ubuntu1_amd64.deb
https://launchpad.net/ubuntu/vivid/amd64/liburcu2/0.8.4-6ubuntu1)
放入deb包本地安裝源目錄。
執行
dpkg-scanpackages ceph_source /dev/null |gzip > ceph_source/Packages.gz
更新Packages.gz包
問題2:
ceph-deploy安裝我自己編譯的deb包,報錯WARNING: The following packages cannot be authenticated!
解決方案:
關閉ubuntu的packages 認證功能:
echo "APT::Get::AllowUnauthenticated 1 ;" | sudo tee -a /etc/apt/apt.conf
參考資料:
1.Debian Linux操作系統下本地源的安裝方法
http://soft.zdnet.com.cn/software_zone/2007/1006/536773.shtml
2. CentOS6.5 本地源搭建Ceph
http://www.cnblogs.com/linprogram/p/5482513.html
