准备工作
- 准备代码使用的目录,注意目录要足够大,保证有100G以上可用空间(编译过程占用很多磁盘)
- clone源码,切换分支
$ git clone https: //github .com /ceph/ceph .git $ git checkout v12.2.5 -b v12.2.5 $ git submodule update --init --recursive |
编译vstart所需二进制文件
$ . /run-make-check .sh ## ceph源码根目录执行,默认如果有2个以上的CPU,只使用一半数量的CPU进行编译,可以编辑下这个脚本文件,把get_processors里面的“expr $(nproc) / 2”改成“expr $(nproc) / 1”,使用全部CPU进行编译 $ cd ceph /build $ make vstart |
等待编译结束后,即可执行vstart命令启动ceph集群。
启动集群
$ .. /src/vstart .sh -d -n -X --bluestore --mon_num 1 --osd_num 3 --mgr_num 1 --mds_num 1 ### build目录下执行 ## 各参数意义 $ .. /src/vstart .sh -h usage: .. /src/vstart .sh [option]... ex: .. /src/vstart .sh -n -d --mon_num 3 --osd_num 3 --mds_num 1 --rgw_num 1 options: -d, --debug -s, --standby_mds: Generate standby-replay MDS for each active -l, --localhost: use localhost instead of hostname -i <ip>: bind to specific ip -n, --new ####### 注意这个参数,首次启动新集群要加,二次启动不要加 -N, --not-new: reuse existing cluster config (default) --valgrind[_{osd,mds,mon,rgw}] 'toolname args...' --nodaemon: use ceph-run as wrapper for mon /osd/mds --smallmds: limit mds cache size -m ip:port specify monitor address -k keep old configuration files -x enable cephx (on by default) -X disable cephx --hitset <pool> <hit_set_type>: enable hitset tracking -e : create an erasure pool -o config add extra config parameters to all sections --mon_num specify ceph monitor count --osd_num specify ceph osd count --mds_num specify ceph mds count --rgw_num specify ceph rgw count --mgr_num specify ceph mgr count --rgw_port specify ceph rgw http listen port --rgw_frontend specify the rgw frontend configuration --rgw_compression specify the rgw compression plugin -b, --bluestore use bluestore as the osd objectstore backend ######## 使用bluestore后端 --memstore use memstore as the osd objectstore backend --cache <pool>: enable cache tiering on pool --short: short object names only; necessary for ext4 dev --nolockdep disable lockdep --multimds <count> allow multimds with maximum active count |
查看集群状态
### build目录下执行 $ bin /ceph -s *** DEVELOPER MODE: setting PATH, PYTHONPATH and LD_LIBRARY_PATH *** 2018-08-21 14:25:48.651800 7f35d4418700 -1 WARNING: all dangerous and experimental features are enabled. 2018-08-21 14:25:48.659410 7f35d4418700 -1 WARNING: all dangerous and experimental features are enabled. cluster: id : 376aef1c-90a7-4dc1-ba3f-d0ce00490988 health: HEALTH_OK services: mon: 1 daemons, quorum a mgr: x(active) mds: cephfs_a-1 /1/1 up {0=a=up:active} osd: 3 osds: 3 up, 3 in data: pools: 3 pools, 24 pgs objects: 21 objects, 2246 bytes usage: 3081 MB used, 27638 MB / 30720 MB avail pgs: 24 active+clean |
停止集群
$ .. /src/stop .sh ### build目录下执行 |
清理集群
$ .. /src/stop .sh ### build目录下执行 $ rm -rf out dev ### build目录下执行 |
注意清理后,如果要再次启动集群,vstart.sh参数里要加上-n。
编译rbd命令
默认情况下,vstart并不编译rbd相关命令和库,需要手工编译,编译方法和普通编译过程没有区别,编译好的二进制文件都在build/bin目录下,跟vstart编译的其他二进制文件一样
$ make rbd -j4 ##### build目录下执行 |
之后就可以进行rbd卷相关操作了,
### build目录下执行 $ bin /ceph osd pool create rbd 8 replicated #### 创建rbd pool $ bin /rbd ls 2018-08-21 14:26:49.086272 7f887ac2c0c0 -1 WARNING: all dangerous and experimental features are enabled. 2018-08-21 14:26:49.086515 7f887ac2c0c0 -1 WARNING: all dangerous and experimental features are enabled. 2018-08-21 14:26:49.089905 7f887ac2c0c0 -1 WARNING: all dangerous and experimental features are enabled. $ bin /rbd create vol1 --size 10M $ bin /rbd ls vol1 $ bin /rbd info vol1 rbd image 'vol1' : size 10240 kB in 3 objects order 22 (4096 kB objects) block_name_prefix: rbd_data.10346b8b4567 format : 2 features: layering, exclusive-lock, object-map, fast- diff , deep-flatten flags: create_timestamp: Tue Aug 21 14:27:13 2018 $ bin /rbd create vol2 --size 10M --image-feature layering $ bin /rbd info vol2 rbd image 'vol2' : size 10240 kB in 3 objects order 22 (4096 kB objects) block_name_prefix: rbd_data.10386b8b4567 format : 2 features: layering flags: create_timestamp: Tue Aug 21 14:28:24 2018 $ bin /rbd map vol2 /dev/rbd0 |