@Niruu
Here is a link changing ambari hostnames that should help you. I have used it successfully before but there are 2 hidden undocumented caveats, you should manually change the hostname in the ambari.properties there should be 2 or 3 properties to match the new VM hostname and also run some SQL like alter in the ambari, ranger, oozi, hive databases you have to do this for all the fore mentioned components.
The contents of your host_names_changes.json should look like below make sure you have the correct cluster name, you will be prompted if you have already backed up your database etc in my case I usually just accept , with a VM you can easily create another snapshot and you are good to go.
You must have completely stopped ambari and the agents
host_names_changes.json
{
"cluster1" : {
"ambari01.example.com" : "ambari02.example.com"
}
}
The command should look like this
# ambari-server update-host-names + host_names_changes.json
# ambari-server update-host-names host_names_changes.json
After completion, you should see successful
Note :
Remember to update the ambari-agent.ini to point to the new ambari02.example.com
If you use the above document you could stop on number 8 you don't need to format you Zk
For ambari database I am assuming you are using MariaDB or Mysql
mysql -u <ambari_user> -p<ambari_user_password>
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'<new_FQDN_new_VM>';
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'<new_FQDN_new_VM>' IDENTIFIED BY '<ambari_user_password>';
Hive to that for all the rest
mysql -u <hive_user> -p<hive_user_password>
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'<new_FQDN_new_VM>';
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'<new_FQDN_new_VM>' IDENTIFIED BY '<hive_user_password>';
Hope that helps
Happy hadooping