4台虚拟机(1GB RAM,2 VCPU,40GB Disk),安装的是ubuntu11.04系统。
规划如下
节点 | IP地址 | hostname | ceph组件 |
ceph-01 | 192.168.99.14 | mon-mds | mon/mds |
ceph-02 | 192.168.99.18 | osd-00 | osd0 |
ceph-03 | 192.168.99.16 | osd-01 | osd1 |
ceph-04 | 192.168.99.17 | client | client |
给每个节点上的/etc/hosts都加上以下内容
192.168.99.14 mon-mds
192.168.99.18 osd-00
192.168.99.16 osd-01
192.168.99.17 client
设置ssh无密码登陆
添加所有其他节点对mon-mds节点的SSH信任。这样mon-mds节点就可以使用ssh登录其他节点(以root的身份)。
在mon-mds节点上运行(产生公钥和私钥,无密码)。
#ssh-keygen -d
由于使用ubuntu系统,所以先要为root设置密码,才能使用root登录。然后在mon-mds节点运行下面的命令。
#scp /root/.ssh/id_dsa.pub root@mon-mds:/root/.ssh/authorized_keys
#scp /root/.ssh/id_dsa.pub root@osd-00:/root/.ssh/authorized_keys
#scp /root/.ssh/id_dsa.pub root@osd-01:/root/.ssh/authorized_keys
#apt-get install autotools-dev autoconf automake cdbs g++ gcc git libatomic-ops-dev libboost-dev \
libcrypto++-dev libcrypto++ libedit-dev libexpat1-dev libfcgi-dev libfuse-dev \
libgoogle-perftools-dev libgtkmm-2.4-dev libtool pkg-config uuid-dev libkeyutils-dev \
uuid-dev libkeyutils-dev btrfs-tools
在http://ceph.newdream.net/download/下载
#wget http://ceph.newdream.net/download/ceph-0.41.tar.gz
编译需花费较长时间
#tar zxvf ceph-0.41.tar.gz
#cd ceph-0.41
#./autogen.sh
#./configure –prefix=/opt/ceph/
#make
#make install
#cd /opt
#tar czvf ceph-0.41.bin.tar.gz ceph/
#scp ceph-0.41.bin.tar.gz osd-00:/opt/
#scp ceph-0.41.bin.tar.gz osd-01:/opt/
#scp ceph-0.41.bin.tar.gz client:/opt/
#ssh osd-00 tar zxvf /opt/ceph-0.41.bin.tar.gz
#ssh osd-01 tar zxvf /opt/ceph-0.41.bin.tar.gz
#ssh client tar zxvf /opt/ceph-0.41.bin.tar.gz
#vim /etc/profile
在最后添加上内容
PATH=$PATH:/opt/ceph/bin:/opt/ceph/sbin:/opt/ceph/lib/ceph
# vim /etc/ld.so.conf
在最后添加上内容
/opt/ceph/lib
/opt/ceph/lib/rados-classes
复制配置文件到其他节点上
#scp /etc/profile osd-00:/etc/profile
#scp /etc/profile osd-01:/etc/profile
#scp /etc/profile client:/etc/profile
#scp /etc/ld.so.conf osd-00:/etc/ld.so.conf
#scp /etc/ld.so.conf osd-01:/etc/ld.so.conf
#scp /etc/ld.so.conf client:/etc/ld.so.conf
#ldconfig
#ssh osd-00 ldconfig
#ssh osd-01 ldconfig
#ssh client ldconfig
# vim /etc/ceph/ceph.conf
并添加上内容
[global]
pid file = /var/run/ceph/$name.pid
debug ms = 1
[mon]
mon data = /mnt/mon$id
[mon.0]
host = mon-mds
mon addr = 192.168.99.14:6789
[mds]
[mds.0]
host = mon-mds
[osd]
sudo = true
osd data = /mnt/osd$id
osd journal = /mnt/osd$id/journal
osd journal size = 100
[osd.0]
host = osd-00
[osd.1]
host = osd-01
复制到其他节点上
#cp /etc/ceph/ceph.conf /opt/ceph/etc/ceph/ceph.conf
#scp /etc/ceph/ceph.conf osd-00:/etc/ceph/ceph.conf
#scp /etc/ceph/ceph.conf osd-01:/etc/ceph/ceph.conf
#scp /etc/ceph/ceph.conf client:/etc/ceph/ceph.conf
#scp /opt/ceph/etc/ceph/ceph.conf osd-00:/opt/ceph/etc/ceph/ceph.conf
#scp /opt/ceph/etc/ceph/ceph.conf osd-01:/opt/ceph/etc/ceph/ceph.conf
#scp /opt/ceph/etc/ceph/ceph.conf client:/opt/ceph/etc/ceph/ceph.conf
在mon-mds上
#mkfs.ext3 /dev/vdb
#mount /dev/vdb /mnt
#mkdir -p /mnt/mon0
在osd-00上
#mkfs.btrfs /dev/vdb
#mount /dev/vdb /mnt
#mkdir -p /mnt/osd0
在osd-01上
#mkfs.btrfs /dev/vdb
#mount /dev/vdb /mnt
#mkdir -p /mnt/osd1
在所有节点上
#mkdir -p /var/log/ceph/
#mkdir -p /var/run/ceph/
# cp /root/ceph-0.41/src/init-ceph /etc/init.d/ceph
#mkcephfs -c /etc/ceph/ceph.conf --allhosts –v
#/etc/init.d/ceph -a start
#ceph -s
帮助信息
http://ceph.newdream.net/wiki/Building_kernel_client
获取源码
#git clone git://ceph.newdream.net/git/ceph-client-standalone.git
#git branch master-backport origin/master-backport
编译源码
#git checkout master-backport (假如当前系统的内核版本不是最新内核版本,就要执行这个命令)
安装build文件夹
#apt-get install linux-headers-$(uname -r)
#apt-get install build-essential
编译libceph模块
#make -C libceph,但是遇到出错,说缺少ceph-type.h
新建ceph-type.h文件
# vim /usr/src/linux-headers-2.6.38-8/include/keys/ceph-type.h
加上内容
#ifndef _KEYS_CEPH_TYPE_H
#define _KEYS_CEPH_TYPE_H
#include <linux/key.h>
extern struct key_type key_type_ceph;
#endif
重新编译libceph模块
#make -C libceph
编译ceph和rbd模块
#cp libceph/Module.symvers ceph/
#cp libceph/Module.symvers rbd/
#make -C ceph
#make -C rbd
加载模块
#modprobe libcrc32c
#insmod ./libceph/libceph.ko
#insmod ./ceph/ceph.ko
或者把模块放到/lib/modules中
#cp ceph-client-standalone/libceph/libceph.ko /lib/modules/2.6.38-8-virtual/kernel/fs/ceph/
#cp ceph-client-standalone/ceph/ceph.ko /lib/modules/2.6.38-8-virtual/kernel/fs/ceph/
#cp ceph-client-standalone/rbd/rbd.ko /lib/modules/2.6.38-8-virtual/kernel/fs/ceph/
然后执行
#depmod 分析可加载模块的依赖性,生成modules.dep文件和映射文件。
#modprobe libceph
#modprobe ceph
#modprobe rbd
#mount.ceph 192.168.99.14:/ /mnt (假如挂载不上,可以尝试关闭iptables)
#mount
创建虚拟磁盘
#rbd create foo –size 1000
#rbd list
# echo “192.168.99.14 name=admin rbd foo” > /sys/bus/rbd/add
查看设备
#ll /sys/bus/rbd/devices/
#cat /proc/partitions
#ll /dev/rbd0
使用dd命令写设备