Skip to content

Commit

Permalink
Merge pull request ceph#131 from ceph/rerun-demo
Browse files Browse the repository at this point in the history
Ability to re-use an existing ceph/demo cluster
  • Loading branch information
leseb committed Jul 20, 2015
2 parents fcbbfd3 + 94c6cd2 commit 6336416
Showing 1 changed file with 36 additions and 30 deletions.
66 changes: 36 additions & 30 deletions demo/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fi
# bootstrap MON
if [ ! -e /etc/ceph/ceph.conf ]; then
fsid=$(uuidgen)
cat <<ENDHERE >/etc/ceph/ceph.conf
cat <<ENDHERE >/etc/ceph/${CLUSTER}.conf
[global]
fsid = $fsid
mon initial members = ${MON_NAME}
Expand All @@ -42,25 +42,25 @@ cluster network = ${CEPH_NETWORK}
ENDHERE

# Generate administrator key
ceph-authtool /etc/ceph/ceph.client.admin.keyring --create-keyring --gen-key -n client.admin --set-uid=0 --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow'
ceph-authtool /etc/ceph/${CLUSTER}.client.admin.keyring --create-keyring --gen-key -n client.admin --set-uid=0 --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow'

# Generate the mon. key
ceph-authtool /etc/ceph/ceph.mon.keyring --create-keyring --gen-key -n mon. --cap mon 'allow *'
ceph-authtool /etc/ceph/${CLUSTER}.mon.keyring --create-keyring --gen-key -n mon. --cap mon 'allow *'

# Generate initial monitor map
monmaptool --create --add ${MON_NAME} ${MON_IP} --fsid ${fsid} /etc/ceph/monmap
fi

# If we don't have a monitor keyring, this is a new monitor
if [ ! -e /var/lib/ceph/mon/ceph-${MON_NAME}/keyring ]; then
if [ ! -e /var/lib/ceph/mon/${CLUSTER}-${MON_NAME}/keyring ]; then

if [ ! -e /etc/ceph/ceph.client.admin.keyring ]; then
echo "ERROR- /etc/ceph/ceph.client.admin.keyring must exist; get it from your existing mon"
if [ ! -e /etc/ceph/${CLUSTER}.client.admin.keyring ]; then
echo "ERROR- /etc/ceph/${CLUSTER}.client.admin.keyring must exist; get it from your existing mon"
exit 2
fi

if [ ! -e /etc/ceph/ceph.mon.keyring ]; then
echo "ERROR- /etc/ceph/ceph.mon.keyring must exist. You can extract it from your current monitor by running 'ceph auth get mon. -o /tmp/ceph.mon.keyring'"
if [ ! -e /etc/ceph/${CLUSTER}.mon.keyring ]; then
echo "ERROR- /etc/ceph/${CLUSTER}.mon.keyring must exist. You can extract it from your current monitor by running 'ceph auth get mon. -o /tmp/${CLUSTER}.mon.keyring'"
exit 3
fi

Expand All @@ -70,17 +70,17 @@ if [ ! -e /var/lib/ceph/mon/ceph-${MON_NAME}/keyring ]; then
fi

# Import the client.admin keyring and the monitor keyring into a new, temporary one
ceph-authtool /tmp/ceph.mon.keyring --create-keyring --import-keyring /etc/ceph/ceph.client.admin.keyring
ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.mon.keyring
ceph-authtool /tmp/${CLUSTER}.mon.keyring --create-keyring --import-keyring /etc/ceph/${CLUSTER}.client.admin.keyring
ceph-authtool /tmp/${CLUSTER}.mon.keyring --import-keyring /etc/ceph/${CLUSTER}.mon.keyring

# Make the monitor directory
mkdir -p /var/lib/ceph/mon/ceph-${MON_NAME}
mkdir -p /var/lib/ceph/mon/${CLUSTER}-${MON_NAME}

# Prepare the monitor daemon's directory with the map and keyring
ceph-mon --mkfs -i ${MON_NAME} --monmap /etc/ceph/monmap --keyring /tmp/ceph.mon.keyring
ceph-mon --mkfs -i ${MON_NAME} --monmap /etc/ceph/monmap --keyring /tmp/${CLUSTER}.mon.keyring

# Clean up the temporary key
rm /tmp/ceph.mon.keyring
rm /tmp/${CLUSTER}.mon.keyring
fi

# start MON
Expand All @@ -94,13 +94,15 @@ ceph osd pool set rbd size 1
# OSD #
#######

# bootstrap OSD
mkdir -p /var/lib/ceph/osd/ceph-0
ceph osd create
ceph-osd -i 0 --mkfs
ceph auth get-or-create osd.0 osd 'allow *' mon 'allow profile osd' -o /var/lib/ceph/osd/${CLUSTER}-0/keyring
ceph osd crush add 0 1 root=default host=$(hostname -s)
ceph-osd -i 0 -k /var/lib/ceph/osd/ceph-0/keyring
if [ ! -e /var/lib/ceph/osd/${CLUSTER}-0/keyring ]; then
# bootstrap OSD
mkdir -p /var/lib/ceph/osd/${CLUSTER}-0
ceph osd create
ceph-osd -i 0 --mkfs
ceph auth get-or-create osd.0 osd 'allow *' mon 'allow profile osd' -o /var/lib/ceph/osd/${CLUSTER}-0/keyring
ceph osd crush add 0 1 root=default host=$(hostname -s)
ceph-osd -i 0 -k /var/lib/ceph/osd/${CLUSTER}-0/keyring
fi

# start OSD
ceph-osd --cluster=${CLUSTER} -i 0
Expand All @@ -110,14 +112,16 @@ ceph-osd --cluster=${CLUSTER} -i 0
# MDS #
#######

# create ceph filesystem
ceph osd pool create cephfs_data 8
ceph osd pool create cephfs_metadata 8
ceph fs new cephfs cephfs_metadata cephfs_data
if [ ! -e /var/lib/ceph/mds/${CLUSTER}-0/keyring ]; then
# create ceph filesystem
ceph osd pool create cephfs_data 8
ceph osd pool create cephfs_metadata 8
ceph fs new cephfs cephfs_metadata cephfs_data

# bootstrap MDS
mkdir -p /var/lib/ceph/mds/ceph-0
ceph auth get-or-create mds.0 mds 'allow' osd 'allow *' mon 'allow profile mds' > /var/lib/ceph/mds/${CLUSTER}-0/keyring
# bootstrap MDS
mkdir -p /var/lib/ceph/mds/${CLUSTER}-0
ceph auth get-or-create mds.0 mds 'allow' osd 'allow *' mon 'allow profile mds' > /var/lib/ceph/mds/${CLUSTER}-0/keyring
fi

# start MDS
ceph-mds --cluster=${CLUSTER} -i 0
Expand All @@ -127,9 +131,11 @@ ceph-mds --cluster=${CLUSTER} -i 0
# RGW #
#######

# bootstrap RGW
mkdir -p /var/lib/ceph/radosgw/${RGW_NAME}
ceph auth get-or-create client.radosgw.gateway osd 'allow rwx' mon 'allow rw' -o /var/lib/ceph/radosgw/${RGW_NAME}/keyring
if [ ! -e /var/lib/ceph/radosgw/${RGW_NAME}/keyring ]; then
# bootstrap RGW
mkdir -p /var/lib/ceph/radosgw/${RGW_NAME}
ceph auth get-or-create client.radosgw.gateway osd 'allow rwx' mon 'allow rw' -o /var/lib/ceph/radosgw/${RGW_NAME}/keyring
fi

# start RGW
radosgw -c /etc/ceph/ceph.conf -n client.radosgw.gateway -k /var/lib/ceph/radosgw/${RGW_NAME}/keyring --rgw-socket-path="" --rgw-frontends="civetweb port=${RGW_CIVETWEB_PORT}"
Expand Down

0 comments on commit 6336416

Please sign in to comment.