Fix multiple mon deployment failures

When 4 or 5 mons are deployed, all mons will always be in the election
state, and the ceph cluster cannot be accessed.

After comparing with ceph-deploy, I found that when the cluster was
initialized, it did not use monmap. When adding a new mon node, it
needs to use monmap. According to the above situation, I fixed the
problem.

Change-Id: Idbfc6741d371adcb06ed97d578d75d3bce862743
Closes-bug: #1824783
(cherry picked from commit 285814353a)
This commit is contained in:
wangwei 2019-04-15 18:36:40 +09:00 committed by wangwei
parent 728d49e140
commit 877df152dd
1 changed files with 11 additions and 1 deletions

View File

@ -39,6 +39,16 @@ if [[ ! -e "${MON_DIR}/keyring" ]]; then
ceph-authtool --create-keyring "${KEYRING_TMP}" --import-keyring "${KEYRING_ADMIN}"
ceph-authtool "${KEYRING_TMP}" --import-keyring "${KEYRING_MON}"
mkdir -p "${MON_DIR}"
ceph-mon --mkfs -i "${HOSTNAME}" --monmap "${MONMAP}" --keyring "${KEYRING_TMP}"
mon_stat=$(ceph mon stat --connect-timeout 1 || true)
mon_check=$(echo $mon_stat | awk '/mons/{print $0}' | wc -l)
if [[ ${mon_check} -eq 0 ]]; then
ceph-mon --mkfs -i "${HOSTNAME}" --keyring "${KEYRING_TMP}"
else
MONMAP_TMP="/tmp/ceph.${HOSTNAME}.monmap"
ceph mon getmap -o "${MONMAP_TMP}"
ceph-mon --mkfs -i "${HOSTNAME}" --monmap "${MONMAP_TMP}" --keyring "${KEYRING_TMP}"
rm "${MONMAP_TMP}"
fi
rm "${KEYRING_TMP}"
fi