Created on 06-06-2016 02:39 AM - edited 08-17-2019 12:11 PM
Ambari Backup and Restore for Postgres
Summary:
Ambari server stores cluster configurations in a database. The default database for the Ambari install is Postgres. This document goes through a step by step process for backing up and restoring the Postgres database.
Background:
A backup copy of your Ambari database is good insurance to keep your Ambari server running. Anytime you make changes to Ambari you should create a backup of the Ambari database before you make the changes. You will want to do this if you need to restore your cluster to the original state. Examples of what you want to take backups are before cluster upgrasdes, changing service configurations, adding new servers, etc.
Backing up the server configuration:
ambari-server stop
cd /tmpmkdir mkdir dbdumpscd cd dbdumps
pg_dump -U ambari ambari > ambari.sql
note: The password is “bigdata”
pg_dump -U mapred ambarirca > ambarirca.sql
note: The password is “mapred”
You will have two files when this is complete, ambari.sql and ambarirca.sql. These files need to be backed up to a server for a future restore.
Restoring the server configuration:
ambari-server stop ambari-agent stop
su – postgres psql
drop database ambari;drop database ambarirca
\list
You should not see ambari and ambarirca listed.
create database ambari;
create database ambarirca;
^d (enter a control-d)
su - postgres
psql -d ambari -f ambari.sql
psql -d ambarirca -f ambarirca.sql
ambari-server start
ambari-agent start
13.Connect to the Ambari web interface
http://<ambari server DNS name or IP address>:8080
Created on 12-19-2016 05:43 AM
@Ron Lee thank you for this article. Done restoring my ambari-server.
Now I just need to find how to reinstall hdp components/clients that are also installed on the same machine.
Created on 05-30-2017 08:13 PM
This article worked well for me except the following two commands:
To fix this, I used -f operator:
Created on 09-07-2017 09:09 PM
Well documented... Worked well with Postgres 9.4.7... Would like to add that during restore I receieved error message 'Unknown role ambari'. I manually added the role as below after step 7 in the Restore section.
CREATE ROLE ambari WITH LOGIN PASSWORD 'bigdata';