OSD_TYPE_CODE="4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D"
JOURNAL_TYPE_CODE="45B0969E-9B03-4F30-B4C6-B4B80CEFF106"
mk_xfs_option="-i size=2048 -f "
journal_size=512m
dest_drive=/dev/sdd
backup_directory=/var/lib/ceph/osd/ceph-2
osd_uuid=$(cat $backup_directory/fsid)
osd_id=$(cat $backup_directory/whoami)
osd_partition=$(blkid |grep "$osd_uuid"|cut -d':' -f1)
journal_device=$(readlink -f $backup_directory/journal)
echo OSD_UUID: $osd_uuid
echo OSD_ID: $osd_id
if [ $(mount |grep "${dest_drive}1"|grep "$backup_directory"|wc -l) -gt 0 ];then
echo "Destination drive has been well prepared."
exit 1
fi
exit
#sgdisk -o $dest_drive
#sgdisk --new=2:-${journal_size}: --change-name=2:'ceph journal' --mbrtogpt --typecode=2:$JOURNAL_TYPE_CODE -- ${dest_drive}
#sgdisk --new=1:: --change-name=1:'ceph data' --mbrtogpt --typecode=1:$OSD_TYPE_CODE --partition-guid=1:$osd_uuid -- ${dest_drive}
#partprobe ${dest_drive}
#mkfs.xfs $mk_xfs_option ${dest_drive}1
systemctl stop ceph-osd@$osd_id
ceph-osd -i 2 --flush-journal
mount_device=$(cat /proc/mounts |grep "$backup_directory"|awk '{print $1}')
mount_option=$(cat /proc/mounts |grep "$backup_directory"|awk '{print $4}')
umount $backup_directory
mount -o ${mount_option} ${dest_drive}1 $backup_directory
mount -o ${mount_option} ${mount_device} /mnt
ceph-osd -i $osd_id --mkfs --osd-uuid $osd_uuid --osd-journal ${dest_drive}2
rm -f ${backup_directory}/journal
journal_partuuid=$(blkid ${dest_drive}2 |grep -E -o "PARTUUID=.*"|cut -d'"' -f2)
ln -s /dev/disk/by-partuuid/${journal_partuuid} ${backup_directory}/journal
ceph-osd -i $osd_id --mkjournal
mv ${backup_directory}/journal ${backup_directory}/journal.orig
tar cf - . | (cd /var/lib/ceph/osd/ceph-2/ && tar xBf -)
rm -f ${backup_directory}/journal
mv ${backup_directory}/journal.orig ${backup_directory}/journal
umount /mnt
systemctl start ceph-osd@$osd_id
沒有留言:
張貼留言