Skip to content

Instantly share code, notes, and snippets.

@Raboo
Forked from uprush/move-journal-node.sh
Last active June 30, 2021 14:19
Show Gist options
  • Select an option

  • Save Raboo/b19df89e8e6f864212b39bb0ba8e768d to your computer and use it in GitHub Desktop.

Select an option

Save Raboo/b19df89e8e6f864212b39bb0ba8e768d to your computer and use it in GitHub Desktop.
#!/bin/bash
AMBARI_USER='admin'
AMBARI_PASSWORD='PWPWPW'
AMBARI_HOST='localhost'
CLUSTER_NAME='mitate'
MOVE_FROM='old-host.mitate.com'
MOVE_TO='new-host.mitate.com'
SSH_USER=john.doe
# Tell to ambari we want to install this component on new_host
curl -u $AMBARI_USER:$AMBARI_PASSWORD -H "X-Requested-By:ambari" -i -X POST http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/hosts/$MOVE_TO/host_components/JOURNALNODE
# Trigger installation
curl -u $AMBARI_USER:$AMBARI_PASSWORD -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo": {"context": "Install JournalNode","query":"HostRoles/component_name.in('JOURNALNODE')"}, "Body":{"HostRoles": {"state": "INSTALLED"}}}' http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/hosts/$MOVE_TO/host_components
# Stop JournalNode on old host
curl -u $AMBARI_USER:$AMBARI_PASSWORD -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo": {"context": "Stop JournalNode","query":"HostRoles/component_name.in('JOURNALNODE')"}, "Body":{"HostRoles": {"state": "INSTALLED"}}}' http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/hosts/$MOVE_FROM/host_components/JOURNALNODE
# copy journal from old node to new node.
mkdir /hadoop/hdfs
rsync -av -e "ssh" --rsync-path="sudo rsync" $SSH_USER@$MOVE_FROM:/hadoop/hdfs/journal/ $SSH_USER@$MOVE_TO:/hadoop/hdfs/journal
# update the configuration property below within in the Ambari UI within the HDFS section.
# <dfs.namenode.shared.edits.dir>
# Start JournalNode on new host
curl -u $AMBARI_USER:$AMBARI_PASSWORD -H "X-Requested-By:ambari" -i -X PUT -d '{"RequestInfo": {"context": "Start JournalNode","query":"HostRoles/component_name.in('JOURNALNODE')"}, "Body":{"HostRoles": {"state": "STARTED"}}}' http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/hosts/$MOVE_TO/host_components/JOURNALNODE
# Remove the old component
curl -u $AMBARI_USER:$AMBARI_PASSWORD -H "X-Requested-By:ambari" -i -X DELETE http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/hosts/$MOVE_FROM/host_components/JOURNALNODE
@abourakba
Copy link
Copy Markdown

abourakba commented Apr 13, 2021

Hello Did you make anything to reconstruct the dfs.journalnode.edits.dir.
my directory dfs.journalnode.edits.dir seems to stay empty now.
Even the other nodes I did not move ...

Best Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment