Last active
May 25, 2021 14:29
-
-
Save swamibluedata/41ee4e6718f1b462301000a7db138681 to your computer and use it in GitHub Desktop.
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
# Create a file (update_worker_disk.sh) with the following contents and store them under /opt/bluedata/bundles/hpe-*/scripts | |
# Run as following | |
# /opt/bluedata/bundles/hpe-cp*/scripts/startscript -a update_worker_disk | |
#! /bin/bash | |
# Set the following parameters | |
WORKER_IP="16.143.21.4" | |
CONTAINER_DISKS="/dev/sdf" | |
MAPR_DISKS="/dev/sdd,/dev/sde" | |
source ${BUNDLE_COMMON_DIR}/startscr_common.sh | |
MAPR_COMMON_SH="$BUNDLE_COMMON_DIR/mapr-common.sh" | |
ERTS_PATH=/opt/bluedata/common-install/bd_mgmt/erts-*/bin | |
NODETOOL=$ERTS_PATH/../../bin/nodetool | |
NAME_ARG=`egrep '^-s?name' $ERTS_PATH/../../releases/1/vm.args` | |
RPCCMD="$ERTS_PATH/escript $NODETOOL $NAME_ARG rpcterms" | |
# Fetch worker id based on host ip provided | |
WORKER_ID=$(bdconfig --getw | grep -w "$WORKER_IP" | awk '{print $1}') | |
# Set bdconfig parameters on the remote host | |
util_remote_exec "$bds_global_user" "$WORKER_IP" "bdconfig --set=\"bds_storage_maprdisks=$MAPR_DISKS\"" | |
util_remote_exec "$bds_global_user" "$WORKER_IP" "bdconfig --set=\"bds_storage_containerdisks=$CONTAINER_DISKS\"" | |
# Update host sysinfo for the worker in db | |
CMD="${RPCCMD} bd_mgmt_worker_common update_host_sysinfo '\"$WORKER_IP\". true.'" | |
OUTPUT=$(eval $CMD) | |
echo $OUTPUT | |
# Prepare a list of mapr disks and container disk as an array for db update | |
ERL_MAPR_DISKS="[" | |
for disk in $(echo $MAPR_DISKS | tr ',' ' ') | |
do | |
ERL_MAPR_DISKS="$ERL_MAPR_DISKS\"$disk\"," | |
done | |
ERL_MAPR_DISKS="${ERL_MAPR_DISKS::-1}]" | |
ERL_CONTAINER_DISKS="[" | |
for disk in $CONTAINER_DISKS | |
do | |
ERL_CONTAINER_DISKS="$ERL_CONTAINER_DISKS\"$disk\"," | |
done | |
ERL_CONTAINER_DISKS="${ERL_CONTAINER_DISKS::-1}]" | |
CMD="${RPCCMD} bd_mgmt_db_worker update_storage '\"$WORKER_ID\". $ERL_MAPR_DISKS. $ERL_CONTAINER_DISKS.'" | |
OUTPUT=$(eval $CMD) | |
echo $OUTPUT | |
# Fetch and update system quota based on new disk information | |
CMD="${RPCCMD} bd_mgmt_vm fetch_and_update_quota" | |
OUTPUT=$(eval $CMD) | |
echo $OUTPUT | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment