From 877df152ddc6dcf83e5a92964a275de2dfc1444b Mon Sep 17 00:00:00 2001 From: wangwei Date: Mon, 15 Apr 2019 18:36:40 +0900 Subject: 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 285814353af29395932e15d78c6a154796978a21) --- docker/ceph/ceph-mon/extend_start.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'docker') diff --git a/docker/ceph/ceph-mon/extend_start.sh b/docker/ceph/ceph-mon/extend_start.sh index 8ec53e8b7..4c3e91b31 100644 --- a/docker/ceph/ceph-mon/extend_start.sh +++ b/docker/ceph/ceph-mon/extend_start.sh @@ -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 -- cgit v1.2.3