Apache Ambari Administration
Also available as:
PDF
loading table of contents...

Purging Ambari Server Database History

After months of operation on larger clusters, the Ambari Server may begin to accrue a large amount of historical data in the database. This can cause UI performance degradation.

To remedy this, the following Ambari Server CLI command has been implemented to automate the removal of historical records in the Ambari Server. The db-purge-history command takes two arguments, the name of the cluster, and the date of the earliest record to purge.

Example Steps

In the following example we will purge history records created before August 1st, of 2017 for the cluster named ‘Prod’.

  1. Stop the Ambari Server by using ambari-server stop:

    # ambari-server stop
    Using python /usr/bin/python
    Stopping ambari-server
    Waiting for server stop...
    Ambari Server stopped
  2. Run the db-purge-history command:

    # ambari-server db-purge-history --cluster-name Prod --from-date 2017-08-01
    Using python  /usr/bin/python
    Purge database history...
    Ambari Server configured for Embedded Postgres. Confirm you have made a backup of the Ambari Server database [y/n] y
    Ambari server is using db type Embedded Postgres. Cleanable database entries older than 2017-08-01 will be purged. Proceed [y/n] y
    Purging historical data from the database ...
    Purging historical data completed. Check the ambari-server.log for details.
    Ambari Server 'db-purge-history' completed successfully.
  3. Start the Ambari Server: by using ambari-server start:

    # ambari-server start
    Using python  /usr/bin/python
    Starting ambari-server
    Ambari Server running with administrator privileges.
    Organizing resource files at /var/lib/ambari-server/resources...
    Ambari database consistency check started...
    Server PID at: /var/run/ambari-server/ambari-server.pid
    Server out at: /var/log/ambari-server/ambari-server.out
    Server log at: /var/log/ambari-server/ambari-server.log
    Waiting for server start........................
    Server started listening on 8080
    
    DB configs consistency check: no errors and warnings were found.
    Ambari Server 'start' completed successfully.

The db-purge-history command will analyze the following tables in the Ambari Server database and remove those rows that can be deleted that have a create date after the --from-date specified when the command is run.

  • AlertCurrent

  • AlertNotice

  • ExecutionCommand

  • HostRoleCommand

  • Request

  • RequestOperationLevel

  • RequestResourceFilter

  • RoleSuccessCriteria

  • Stage

  • TopologyHostRequest

  • TopologyHostTask

  • TopologyLogicalTask