Last active
June 24, 2024 00:43
-
-
Save TyeolRik/f2dad77db44d394d71a61f67287b210b to your computer and use it in GitHub Desktop.
Remove Ceph OSD forcefully
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is really dangerous command. | |
# Please be CAREFUL | |
TARGET_OSD_ID="$1" # 6 | |
TARGET_HOST_NAME=$(ceph orch ps --daemon_type osd --format json| jq -r '.[] | select(.daemon_id == '\""$TARGET_OSD_ID"\"') | .hostname') | |
TARGET_DAEMON_NAME=$(ceph orch ps --daemon_type osd --format json | jq -r '.[] | select(.daemon_id == '\""$TARGET_OSD_ID"\"') | .daemon_name') | |
TARGET_OSD_DEV_PATH=$(ceph device ls-by-host "${TARGET_HOST_NAME}" --format json | jq -r '.[] | select(.daemons[] | contains('\""${TARGET_DAEMON_NAME}"\"')) | .location[] | .dev') | |
# ceph orch ls --service_type osd --format json | jq -c '.[] | select(.spec.data_devices.paths != null) | select(.spec.data_devices.paths[] | contains('\"${TARGET_OSD_DEV_PATH}\"')) | select(.placement.hosts != null) | select(.placement.hosts[] | contains('\"${TARGET_HOST_NAME}\"'))' | |
SERVICE_NAME=$(ceph orch ls --service_type osd --format json | jq -c '.[] | select(.spec.data_devices.paths != null) | select(.spec.data_devices.paths[] | contains('\""${TARGET_OSD_DEV_PATH}"\"')) | select(.placement.hosts != null) | select(.placement.hosts[] | contains('\""${TARGET_HOST_NAME}"\"'))' | jq -r '.service_name') | |
ceph orch rm "${SERVICE_NAME}" --force | |
ceph osd down "$TARGET_OSD_ID" | |
ceph osd purge "$TARGET_OSD_ID" --force --yes-i-really-mean-it | |
ceph orch daemon rm "${TARGET_DAEMON_NAME}" --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ceph-
부분은 적절하게 잘 해서 삭제할 것.