-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap.sh
executable file
·48 lines (39 loc) · 1.24 KB
/
bootstrap.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
#!/bin/sh
fsid=$(uuidgen)
ipaddr=$(ip -o -4 addr show eth0 | sed 's:^.*inet \([^/]*\).*$:\1:')
hostname=$(hostname)
cat << EOF > /etc/ceph/ceph.conf
[global]
fsid = $fsid
mon host = $ipaddr
auth cluster required = cephx
auth service required = cephx
auth client required = cephx
osd journal size = 1024
filestore xattr use omap = true
osd pool default size = 2
osd pool default min size = 1
EOF
ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'
cat << EOF > /tmp/ceph.admin.keyring
[client.admin]
$(grep "key = " /tmp/ceph.mon.keyring)
auid = 0
caps mds = "allow"
caps mon = "allow *"
caps osd = "allow *"
EOF
monmaptool --create --add $hostname $ipaddr --fsid $fsid /tmp/monmap
mkdir /var/lib/ceph/mon/ceph-$hostname
ceph-mon --mkfs -i $hostname --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring
touch /var/lib/ceph/mon/ceph-$hostname/done
touch /var/lib/ceph/mon/ceph-$hostname/sysvinit
service ceph start mon.$hostname
while ! ceph mon stat 2>/dev/null; do
sleep 1
done
ceph auth import -i /tmp/ceph.admin.keyring
mv /tmp/ceph.admin.keyring /etc/ceph/ceph.client.admin.keyring
mkdir /home/osd
ceph-disk prepare --cluster ceph --cluster-uuid $fsid --fs-type ext4 /home/osd
ceph-disk activate /home/osd