-
Notifications
You must be signed in to change notification settings - Fork 23
/
provision-storage.sh
68 lines (60 loc) · 1.75 KB
/
provision-storage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
set -eux
storage_network_first_node_ip=$1
storage_network="$2/24"
storage_ip=$3
storage_monitor_ips=$4
dmi_sys_vendor=$(cat /sys/devices/virtual/dmi/id/sys_vendor)
if [ "$dmi_sys_vendor" == 'QEMU' ]; then
osd_disk_device='/dev/sdb'
else
osd_disk_device='/dev/sdb'
fi
# install ceph.
yes | pveceph install
# create the ceph cluster.
# see https://pve.proxmox.com/wiki/Ceph_Server
# see https://pve.proxmox.com/wiki/Storage:_RBD
# see https://pve.proxmox.com/pve-docs/chapter-pvesm.html
# see https://pve.proxmox.com/pve-docs/pveceph.1.html
# see https://pve.proxmox.com/pve-docs/pvesm.1.html
# run pveceph help createpool
if [ "$storage_ip" == "$storage_network_first_node_ip" ]; then
# initialize ceph.
pveceph init --network $storage_network
pveceph createmon
mkdir /etc/pve/priv/ceph
# create a storage pool for lxc containers.
pve_pool_name='ceph-lxc'
pveceph createpool $pve_pool_name \
--size 3 \
--min_size 2 \
--pg_num 64
pvesm add rbd $pve_pool_name \
--monhost $storage_monitor_ips \
--content rootdir \
--krbd 1 \
--pool $pve_pool_name \
--username admin
# create a storage pool for virtual machines.
pve_pool_name='ceph-vm'
pveceph createpool $pve_pool_name \
--size 3 \
--min_size 2 \
--pg_num 64
pvesm add rbd $pve_pool_name \
--monhost $storage_monitor_ips \
--content images \
--krbd 0 \
--pool $pve_pool_name \
--username admin
else
pveceph createmon
fi
# wait for ceph to be ready.
# TODO find a better way.
# NB without this, the pveceph createosd command will fail with:
# got timeout
sleep 5
# create an OSD in a disk.
pveceph createosd $osd_disk_device