使用 Ceph - Vagrant Box

shan

开始使用 Ceph 的材料。此 Vagrant box 包含一个一体化的 Ceph 安装。

一、设置

首先 下载安装 Vagrant。

下载 Ceph box:这里。此 box 包含一台虚拟机

  • Ceph VM 包含 2 个 OSD(每个磁盘 1 个),1 个 MDS,1 个 MON,1 个 RGW。修改后的 CRUSH Map,它只是代表一个完整的数据中心,并应用每个 OSD 的副本
  • VagrantFile 用于 VM 客户端和 ceph
  • 其他包含的文件

下载一个用于客户端的额外 VM 这里,请注意,基于 Debian 和 Red Hat 的系统运行良好,因此由您决定

  • 客户端:只是一个 Ubuntu 安装

初始化 Ceph box

1
2
3
4
5
6
7
8
9
$ wget https://www.dropbox.com/s/hn28qgjn59nud6h/ceph-all-in-one.box
...
...
$ vagrant box add big-ceph ceph-all-in-one.box
[vagrant] Downloading with Vagrant::Downloaders::File...
[vagrant] Copying box to temporary location...
[vagrant] Extracting box...
[vagrant] Verifying box...
[vagrant] Cleaning up downloaded box...

初始化客户端 box

1
2
3
4
5
6
7
$ wget http://dl.dropbox.com/u/1537815/precise64.box
$ vagrant box add ubuntu-12.04.1 precise64.box
[vagrant] Downloading with Vagrant::Downloaders::File...
[vagrant] Copying box to temporary location...
[vagrant] Extracting box...
[vagrant] Verifying box...
[vagrant] Cleaning up downloaded box...

检查您的 boxes

1
2
3
$ vagrant box list
ceph-all-in-one
ubuntu-12.04.1

导入 box 中的所有文件

1
2
3
$ mkdir setup
$ cp /Users/leseb/.vagrant.d/boxes/ceph-all-in-one/include/* setup/
$ mv setup/_Vagrantfile Vagrantfile

为了使设置更容易,我假设您的工作目录是 $HOME/ceph。最后,您的目录树如下所示

.
├── Vagrantfile
├── ceph-all-in-one.box
├── precise64.box
└── setup
    ├── ceph.conf
    ├── ceph.sh
    └── keyring

二、启动它!

检查您的虚拟机的状态

1
2
3
4
5
6
7
8
9
$ vagrant status
Current VM states:

client                   poweroff
ceph                     poweroff

This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.

最终运行它们

1
2
3
$ vagrant up ceph && vagrant up client
...
...

下次,您将运行客户端,请以这种方式运行它,以避免重新配置机器

1
$ vagrant up --no-provision client

最终 SSH 到您的客户端

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ vagrant ssh client
...

vagrant@ceph:~$ sudo ceph -s
   health HEALTH_OK
   monmap e3: 1 mons at {1=192.168.251.100:6790/0}, election epoch 1, quorum 0 1
   osdmap e179: 2 osds: 2 up, 2 in
    pgmap v724: 96 pgs: 96 active+clean; 9199 bytes data, 2071 MB used, 17906 MB / 19978 MB avail; 232B/s wr, 0op/s
   mdsmap e54: 1/1/1 up {0=0=up:active}

vagrant@ceph:~$ sudo ceph osd tree
# id  weight  type name up/down reweight
-1  2 root default
-4  2   datacenter dc
-5  2     room laroom
-6  2       row larow
-3  2         rack lerack
-2  2           host ceph
0 1             osd.0 up  1
1 1             osd.1 up  1

三、附加升级

III.1. Ceph 升级

将 box 升级到最新的稳定版本 Cuttlefish 非常容易。为此,只需编辑 /etc/apt/sources.list.d/ceph.list/ceph.list 为以下内容

deb https://ceph.net.cn/debian-cuttlefish/ precise main

然后运行

1
2
3
4
$ sudo apt-get update && apt-get install ceph
$ sudo service ceph restart
$ sudo ceph -v
ceph version 0.61 (237f3f1e8d8c3b85666529860285dcdffdeda4c5)

III.2. Vagrant 版本 2

感谢 freshteapot。

Vagrant 文件

Vagrant.configure("2") do |config|

  config.vm.define :ceph do |role|
    role.vm.box = "big-ceph"
    role.vm.network :private_network, ip: "192.168.251.100"
    role.vm.hostname = "ceph"
  end

  config.vm.define :client do |role|
    role.vm.box = "ubuntu1304"
    role.vm.hostname = "ceph-client"
    role.vm.provision :shell, :path => "setup/ceph.sh"
    role.vm.network :private_network, ip: "192.168.251.101"
  end

end

然后运行

1
2
$ vagrant halt [vm-name]
$ vagrant up [vm-name]

R 注意:如果由于某种原因,您收到只有 1/2 个 OSD 启动的状态,只需重启 mon。这应该可以解决问题 :-).

我每天都使用此 box 进行所有测试,它非常方便地销毁和重建它,只需一分钟。构建、销毁、构建销毁,我想你明白了!希望它 ;-)