]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/scripts/ceph/start.sh
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / scripts / ceph / start.sh
1 #!/usr/bin/env bash
2 # create mon
3
4 set -x
5 set -e
6
7 script_dir=$(readlink -f $(dirname $0))
8
9 base_dir=/var/tmp/ceph
10 mon_ip=$1
11 mon_dir=${base_dir}/mon.a/
12 pid_dir=${base_dir}/pid
13 ceph_conf=${base_dir}/ceph.conf
14 mnt_dir=${base_dir}/mnt
15 dev_backend=/dev/ceph
16 image=/var/tmp/ceph_raw.img
17 dev=/dev/loop200
18
19 umount $dev || true
20 losetup -d $dev_backend || true
21
22 # partition osd
23 if [ -d $base_dir ]; then
24 rm -rf $base_dir
25 fi
26 mkdir ${base_dir}
27 cp ${script_dir}/ceph.conf $ceph_conf
28
29 if [ ! -e $image ]; then
30 fallocate -l 10G $image
31 fi
32
33 mknod ${dev_backend} b 7 200 || true
34 losetup ${dev_backend} ${image} || true
35
36 PARTED="parted -s"
37 SGDISK="sgdisk"
38
39 echo "Partitioning ${dev}"
40 ${PARTED} ${dev} mktable gpt
41 sleep 2
42 ${PARTED} ${dev} mkpart primary 0% 5GiB
43 ${PARTED} ${dev} mkpart primary 5GiB 100%
44
45
46 partno=0
47 echo "Setting name on ${dev}"
48 ${SGDISK} -c 1:osd-device-${partno}-journal ${dev}
49 ${SGDISK} -c 2:osd-device-${partno}-data ${dev}
50 kpartx ${dev}
51
52 # prep osds
53
54 mnt_pt=${mnt_dir}/osd-device-0-data/
55 mkdir -p ${mnt_pt}
56 mkfs.xfs -f /dev/disk/by-partlabel/osd-device-0-data
57 mount /dev/disk/by-partlabel/osd-device-0-data ${mnt_pt}
58 echo -e "\tosd data = ${mnt_pt}" >> "$ceph_conf"
59 echo -e "\tosd journal = /dev/disk/by-partlabel/osd-device-0-journal" >> "$ceph_conf"
60
61 # add mon address
62 echo -e "\t[mon.a]" >> "$ceph_conf"
63 echo -e "\tmon addr = ${mon_ip}:12046" >> "$ceph_conf"
64
65 # create mon
66 rm -rf ${mon_dir}/*
67 mkdir -p ${mon_dir}
68 mkdir -p ${pid_dir}
69
70 ceph-authtool --create-keyring --gen-key --name=mon. ${base_dir}/keyring --cap mon 'allow *'
71 ceph-authtool --gen-key --name=client.admin --set-uid=0 --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *' --cap mgr 'allow *' ${base_dir}/keyring
72
73 monmaptool --create --clobber --add a ${mon_ip}:12046 --print ${base_dir}/monmap
74
75 sh -c "ulimit -c unlimited && exec ceph-mon --mkfs -c ${ceph_conf} -i a --monmap=${base_dir}/monmap --keyring=${base_dir}/keyring --mon-data=${mon_dir}"
76
77 cp ${base_dir}/keyring ${mon_dir}/keyring
78
79 cp $ceph_conf /etc/ceph/ceph.conf
80
81 cp ${base_dir}/keyring /etc/ceph/keyring
82
83 ceph-run sh -c "ulimit -n 16384 && ulimit -c unlimited && exec ceph-mon -c ${ceph_conf} -i a --keyring=${base_dir}/keyring --pid-file=${base_dir}/pid/root@`hostname`.pid --mon-data=${mon_dir}" || true
84
85 # create osd
86
87 i=0
88
89 mkdir -p ${mnt_dir}
90
91 uuid=`uuidgen`
92 ceph -c ${ceph_conf} osd create ${uuid} $i
93 ceph-osd -c ${ceph_conf} -i $i --mkfs --mkkey --osd-uuid ${uuid}
94 ceph -c ${ceph_conf} osd crush add osd.${i} 1.0 host=`hostname` root=default
95 ceph -c ${ceph_conf} -i ${mnt_dir}/osd-device-${i}-data/keyring auth add osd.${i} osd "allow *" mon "allow profile osd" mgr "allow"
96
97 # start osd
98 pkill -9 ceph-osd || true
99 sleep 2
100
101 mkdir -p ${pid_dir}
102 env -i TCMALLOC_MAX_TOTAL_THREAD_CACHE_BYTES=134217728 ceph-osd -c ${ceph_conf} -i 0 --pid-file=${pid_dir}/ceph-osd.0.pid