<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question PostgreSQL + Removing old Host from DB not succeeded in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/PostgreSQL-Removing-old-Host-from-DB-not-succeeded/m-p/383542#M244945</link>
    <description>&lt;P&gt;We have HDP cluster with 152 workers machines - `worker1.duplex.com` .. `worker152.duplex.com` , While all machines are installed on RHEL 7.9 version&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;We are trying to delete the last host - `worker152.duplex.com` from Ambari server or actually from PostgreSQL DB as the following&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;First we need to find the `host_id`&lt;/P&gt;&lt;P&gt;select host_id from hosts where host_name='worker152.duplex.com';&lt;BR /&gt;&lt;BR /&gt;and host_id is:&lt;BR /&gt;&lt;BR /&gt;host_id&lt;BR /&gt;---------&lt;BR /&gt;51&lt;BR /&gt;(1 row)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Now we are deletion this `host_id` - 51&lt;/P&gt;&lt;P&gt;delete from execution_command where task_id in (select task_id from host_role_command where host_id in (51));&lt;BR /&gt;delete from host_version where host_id in (51);&lt;BR /&gt;delete from host_role_command where host_id in (51);&lt;BR /&gt;delete from serviceconfighosts where host_id in (51);&lt;BR /&gt;delete from hoststate where host_id in (51);&lt;BR /&gt;delete from kerberos_principal_host WHERE host_id='worker152.duplex.com';&lt;BR /&gt;delete from hosts where host_name in ('worker152.duplex.com');&lt;BR /&gt;delete from alert_current where history_id in ( select alert_id from alert_history where host_name in ('worker152.duplex.com'));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Now we verify that `host_id` - 51 that represented the host - `worker152.duplex.com` isn't exists By the following verification&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ambari=&amp;gt; select host_name, public_host_name from hosts;&lt;BR /&gt;host_name | public_host_name&lt;BR /&gt;--------------------------+--------------------------&lt;BR /&gt;worker1.duplex.com&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;worker151.duplex.com&lt;/P&gt;&lt;P&gt;As we can see above the host `worker151.duplex.com` not exist and that's fine , and indeed seems That host - `worker151.duplex.com` was deleted from PostgreSQL DB&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Now we restarting the `Ambari-server` in order to take affect ( its also restart the PostgreSQL service )&lt;/P&gt;&lt;P&gt;ambari-server restart&lt;BR /&gt;Using python /usr/bin/python&lt;BR /&gt;Restarting ambari-server&lt;BR /&gt;Waiting for server stop...&lt;BR /&gt;Ambari Server stopped&lt;BR /&gt;Ambari Server running with administrator privileges.&lt;BR /&gt;Organizing resource files at /var/lib/ambari-server/resources...&lt;BR /&gt;Ambari database consistency check started...&lt;BR /&gt;Server PID at: /var/run/ambari-server/ambari-server.pid&lt;BR /&gt;Server out at: /var/log/ambari-server/ambari-server.out&lt;BR /&gt;Server log at: /var/log/ambari-server/ambari-server.log&lt;BR /&gt;Waiting for server start.........................&lt;BR /&gt;Server started listening on 8080&lt;BR /&gt;&lt;BR /&gt;DB configs consistency check: no errors and warnings were found.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;After Ambari server started , we are surprised because the `host_id` - 51 or host - `worker152.duplex.com` , is still exist as the following&lt;/P&gt;&lt;P&gt;ambari=&amp;gt; select host_name, public_host_name from hosts;&lt;BR /&gt;host_name | public_host_name&lt;BR /&gt;--------------------------+--------------------------&lt;BR /&gt;worker1.duplex.com&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;worker152.duplex.com&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;We not understand why this host back again in spite we delete this record&lt;/P&gt;&lt;P&gt;We also tried to delete historical data by the following but this isn't help&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ambari-server db-purge-history --cluster-name hadoop7 --from-date 2024-01-01&lt;/P&gt;&lt;P&gt;Using python /usr/bin/python&lt;BR /&gt;Purge database history...&lt;BR /&gt;Ambari Server configured for Embedded Postgres. Confirm you have made a backup of the Ambari Server database [y/n]yes&lt;BR /&gt;ERROR: The database purge historical data cannot proceed while Ambari Server is running. Please shut down Ambari first.&lt;BR /&gt;Ambari Server 'db-purge-history' completed successfully.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Why host returned after `Ambari-server` restart ?&lt;/P&gt;&lt;P&gt;2. what is wrong with out deletion process?&lt;/P&gt;&lt;P&gt;PostgreSQL Version:&lt;/P&gt;&lt;P&gt;postgres=# SHOW server_version;&lt;BR /&gt;server_version&lt;BR /&gt;----------------&lt;BR /&gt;9.2.24&lt;BR /&gt;(1 row)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;links:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.andruffsolutions.com/removing-old-host-data-from-ambari-server-and-tuning-the-database/" target="_blank"&gt;https://www.andruffsolutions.com/removing-old-host-data-from-ambari-server-and-tuning-the-database/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.cloudera.com/t5/Support-Questions/how-to-remove-old-registered-hosts-from-DB/m-p/217524/highlight/true" target="_blank"&gt;https://community.cloudera.com/t5/Support-Questions/how-to-remove-old-registered-hosts-from-DB/m-p/217524/highlight/true&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Feb 2024 17:02:54 GMT</pubDate>
    <dc:creator>mike_bronson7</dc:creator>
    <dc:date>2024-02-15T17:02:54Z</dc:date>
    <item>
      <title>PostgreSQL + Removing old Host from DB not succeeded</title>
      <link>https://community.cloudera.com/t5/Support-Questions/PostgreSQL-Removing-old-Host-from-DB-not-succeeded/m-p/383542#M244945</link>
      <description>&lt;P&gt;We have HDP cluster with 152 workers machines - `worker1.duplex.com` .. `worker152.duplex.com` , While all machines are installed on RHEL 7.9 version&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;We are trying to delete the last host - `worker152.duplex.com` from Ambari server or actually from PostgreSQL DB as the following&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;First we need to find the `host_id`&lt;/P&gt;&lt;P&gt;select host_id from hosts where host_name='worker152.duplex.com';&lt;BR /&gt;&lt;BR /&gt;and host_id is:&lt;BR /&gt;&lt;BR /&gt;host_id&lt;BR /&gt;---------&lt;BR /&gt;51&lt;BR /&gt;(1 row)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Now we are deletion this `host_id` - 51&lt;/P&gt;&lt;P&gt;delete from execution_command where task_id in (select task_id from host_role_command where host_id in (51));&lt;BR /&gt;delete from host_version where host_id in (51);&lt;BR /&gt;delete from host_role_command where host_id in (51);&lt;BR /&gt;delete from serviceconfighosts where host_id in (51);&lt;BR /&gt;delete from hoststate where host_id in (51);&lt;BR /&gt;delete from kerberos_principal_host WHERE host_id='worker152.duplex.com';&lt;BR /&gt;delete from hosts where host_name in ('worker152.duplex.com');&lt;BR /&gt;delete from alert_current where history_id in ( select alert_id from alert_history where host_name in ('worker152.duplex.com'));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Now we verify that `host_id` - 51 that represented the host - `worker152.duplex.com` isn't exists By the following verification&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ambari=&amp;gt; select host_name, public_host_name from hosts;&lt;BR /&gt;host_name | public_host_name&lt;BR /&gt;--------------------------+--------------------------&lt;BR /&gt;worker1.duplex.com&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;worker151.duplex.com&lt;/P&gt;&lt;P&gt;As we can see above the host `worker151.duplex.com` not exist and that's fine , and indeed seems That host - `worker151.duplex.com` was deleted from PostgreSQL DB&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Now we restarting the `Ambari-server` in order to take affect ( its also restart the PostgreSQL service )&lt;/P&gt;&lt;P&gt;ambari-server restart&lt;BR /&gt;Using python /usr/bin/python&lt;BR /&gt;Restarting ambari-server&lt;BR /&gt;Waiting for server stop...&lt;BR /&gt;Ambari Server stopped&lt;BR /&gt;Ambari Server running with administrator privileges.&lt;BR /&gt;Organizing resource files at /var/lib/ambari-server/resources...&lt;BR /&gt;Ambari database consistency check started...&lt;BR /&gt;Server PID at: /var/run/ambari-server/ambari-server.pid&lt;BR /&gt;Server out at: /var/log/ambari-server/ambari-server.out&lt;BR /&gt;Server log at: /var/log/ambari-server/ambari-server.log&lt;BR /&gt;Waiting for server start.........................&lt;BR /&gt;Server started listening on 8080&lt;BR /&gt;&lt;BR /&gt;DB configs consistency check: no errors and warnings were found.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;After Ambari server started , we are surprised because the `host_id` - 51 or host - `worker152.duplex.com` , is still exist as the following&lt;/P&gt;&lt;P&gt;ambari=&amp;gt; select host_name, public_host_name from hosts;&lt;BR /&gt;host_name | public_host_name&lt;BR /&gt;--------------------------+--------------------------&lt;BR /&gt;worker1.duplex.com&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;worker152.duplex.com&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;We not understand why this host back again in spite we delete this record&lt;/P&gt;&lt;P&gt;We also tried to delete historical data by the following but this isn't help&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ambari-server db-purge-history --cluster-name hadoop7 --from-date 2024-01-01&lt;/P&gt;&lt;P&gt;Using python /usr/bin/python&lt;BR /&gt;Purge database history...&lt;BR /&gt;Ambari Server configured for Embedded Postgres. Confirm you have made a backup of the Ambari Server database [y/n]yes&lt;BR /&gt;ERROR: The database purge historical data cannot proceed while Ambari Server is running. Please shut down Ambari first.&lt;BR /&gt;Ambari Server 'db-purge-history' completed successfully.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Why host returned after `Ambari-server` restart ?&lt;/P&gt;&lt;P&gt;2. what is wrong with out deletion process?&lt;/P&gt;&lt;P&gt;PostgreSQL Version:&lt;/P&gt;&lt;P&gt;postgres=# SHOW server_version;&lt;BR /&gt;server_version&lt;BR /&gt;----------------&lt;BR /&gt;9.2.24&lt;BR /&gt;(1 row)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;links:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.andruffsolutions.com/removing-old-host-data-from-ambari-server-and-tuning-the-database/" target="_blank"&gt;https://www.andruffsolutions.com/removing-old-host-data-from-ambari-server-and-tuning-the-database/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.cloudera.com/t5/Support-Questions/how-to-remove-old-registered-hosts-from-DB/m-p/217524/highlight/true" target="_blank"&gt;https://community.cloudera.com/t5/Support-Questions/how-to-remove-old-registered-hosts-from-DB/m-p/217524/highlight/true&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 17:02:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/PostgreSQL-Removing-old-Host-from-DB-not-succeeded/m-p/383542#M244945</guid>
      <dc:creator>mike_bronson7</dc:creator>
      <dc:date>2024-02-15T17:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: PostgreSQL + Removing old Host from DB not succeeded</title>
      <link>https://community.cloudera.com/t5/Support-Questions/PostgreSQL-Removing-old-Host-from-DB-not-succeeded/m-p/386888#M246176</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/59349"&gt;@mike_bronson7&lt;/a&gt;&amp;nbsp;did you try to delete the host from Ambari UI? if not please try that out first.&lt;/P&gt;&lt;P&gt;You might need to stop the ambari server first delete entries from the backed DB commit the changes then start your ambari server. But I would recommend deleting if from Ambari UI and checking.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 06:30:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/PostgreSQL-Removing-old-Host-from-DB-not-succeeded/m-p/386888#M246176</guid>
      <dc:creator>Rajat_710</dc:creator>
      <dc:date>2024-04-22T06:30:27Z</dc:date>
    </item>
  </channel>
</rss>

