diff options
| author | Suren A. Chilingaryan <csa@suren.me> | 2025-12-09 16:14:26 +0000 |
|---|---|---|
| committer | Suren A. Chilingaryan <csa@suren.me> | 2025-12-09 16:14:26 +0000 |
| commit | 77aa9c433f9255d713394e3b25987fa2b4a03a1a (patch) | |
| tree | ddc5d87bf838bd589f36b43b53955ad8207796a2 /scripts/maintain/gluster/bricks_move_heketi.sh | |
| parent | d35216ee0cbf9f1a84a6d4151daf870b1ff00395 (diff) | |
| download | ands-master.tar.gz ands-master.tar.bz2 ands-master.tar.xz ands-master.zip | |
Diffstat (limited to 'scripts/maintain/gluster/bricks_move_heketi.sh')
| -rw-r--r-- | scripts/maintain/gluster/bricks_move_heketi.sh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/scripts/maintain/gluster/bricks_move_heketi.sh b/scripts/maintain/gluster/bricks_move_heketi.sh new file mode 100644 index 0000000..36b8602 --- /dev/null +++ b/scripts/maintain/gluster/bricks_move_heketi.sh @@ -0,0 +1,39 @@ +HOST="192.168.12.1" +NEW_BASE="/mnt/ands/glusterfs/vg_ce3a7c1bb6da5c98ce4bb3e76aeacb8b" +GLUSTER_BIN="gluster" +DRYRUN=1 # set to 0 to actually run +GLUSTER_UID=107 # adjust if your gluster user has a different uid/gid + +# get all volumes like vol_<uid> +VOLS=$($GLUSTER_BIN volume list | grep '^vol_') + +for VOL in $VOLS; do + # find bricks on this host + # lines look like: "Brick2: 192.168.12.1:/var/lib/heketi/.../brick" + mapfile -t OLDBRICKS < <($GLUSTER_BIN volume info "$VOL" \ + | grep "$HOST:" \ + | awk '{print $2}') + + # skip volumes that don't have a brick on this host + if [ ${#OLDBRICKS[@]} -eq 0 ]; then + continue + fi + + for OLD in "${OLDBRICKS[@]}"; do + BRICKID=$(echo "$OLD" | sed -n 's#.*/\(brick_[^/]*\)/brick#\1#p') + if [ -z "$BRICKID" ]; then + echo "WARN: could not extract brick ID from $OLD" + continue + fi + + NEW="$HOST:$NEW_BASE/$BRICKID" + + echo "=== volume: $VOL ===" + echo "old brick: $OLD" + echo "new brick: $NEW" + + + $GLUSTER_BIN volume replace-brick "$VOL" "$OLD" "$NEW" commit force + + done +done |
