You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by Darpan Patel <da...@gmail.com> on 2015/12/08 16:32:33 UTC

Issue removing and re-adding the components in Ambari

Hi folks,

I am running Version 2.1.2 of Ambari , HDP 2.3 on multinode cluster.
I was facing the issues in Knox component so decided to remove the service
and re-install it.
So I removed issued following command and it disappeared through Ambari web
portal.
// valid admin

*curl -v -u admin:Ambari-AdminPassword -H "X-Requested-By:ambari" -X DELETE
"http://AMBARI_HOST:8080/api/v1/clusters/SecureCluster/services/KNOX
<http://AMBARI_HOST:8080/api/v1/clusters/SecureCluster/services/KNOX>"*

However when I check in the /usr/hdp/2.3.2.0-2950 directory I found that
knox-server and it's directories were not removed. I manually deleted this
directory and re-initiated the Knox setup through Ambari. It goes up to
step 6 and shows a popup saying : Internal Server error.


When I check the Ambari-server logs it looks like service is already
present.

*Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services -
2.5.2.v20140319-9ad6abd):
org.eclipse.persistence.exceptions.DatabaseException*
*Internal Exception: org.postgresql.util.PSQLException: ERROR: duplicate
key value violates unique constraint "clusterservices_pkey"*
*  Detail: Key (service_name, cluster_id)=(KNOX, 2) already exists.*
*Error Code: 0*
Call: INSERT INTO clusterservices (service_name, service_enabled,
cluster_id) VALUES (?, ?, ?)
        bind => [3 parameters bound]
Query:
InsertObjectQuery(org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity@fadf9954
)
        at
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
        at
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1611)
        at
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:898)
        at
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:962)
        at
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:631)
        at
org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatch(ParameterizedSQLBatchWritingMechanism.java:149)
        at
org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatchedStatements(ParameterizedSQLBatchWritingMechanism.java:134)
        at
org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.appendCall(ParameterizedSQLBatchWritingMechanism.java:82)
.......
*Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value
violates unique constraint "clusterservices_pkey"*
*  Detail: Key (service_name, cluster_id)=(KNOX, 2) already exists.*
        at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
        at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)

What is the way around? Am I supposed to manually remove the Ambari related
database/tables, in which scenario which db/table should we update manually?

Regards,
DP

Re: Issue removing and re-adding the components in Ambari

Posted by Alejandro Fernandez <af...@hortonworks.com>.
Ambari 2.2 makes it safer to delete services, thanks to Sid Wagle. There were several Jiras related to fixing DB inconsistencies.

[cid:DF1928C7-B84A-4051-81CD-C26A760EF334]

Thanks,
Alejandro

From: Darpan Patel <da...@gmail.com>>
Reply-To: "user@ambari.apache.org<ma...@ambari.apache.org>" <us...@ambari.apache.org>>
Date: Tuesday, December 8, 2015 at 1:54 PM
To: "user@ambari.apache.org<ma...@ambari.apache.org>" <us...@ambari.apache.org>>
Cc: "dev@ambari.apache.org<ma...@ambari.apache.org>" <de...@ambari.apache.org>>
Subject: Re: Issue removing and re-adding the components in Ambari

Thanks Alejandro,

I executed the commands to delete the service.
Do you not think REST API should also execute update the tables to avoid any confusions?

Regards,
DP

On 8 December 2015 at 18:25, Alejandro Fernandez <af...@hortonworks.com>> wrote:
Hi Darpan,

I suspect that the curl call to delete KNOX only removed it from some of the database tables.
Removing a services does not make any modifications to the actual agents, such as removing bits and configs.
If you re-add that service you may have to make sure that no other tables have references to it. E.g.

DELETE FROM hostcomponentstate WHERE service_name IN ('KNOX');
DELETE FROM hostcomponentdesiredstate WHERE service_name IN ('KNOX');
DELETE FROM servicecomponentdesiredstate WHERE service_name IN ('KNOX');
DELETE FROM servicedesiredstate WHERE service_name IN ('KNOX');
DELETE FROM clusterservices WHERE service_name IN ('KNOXr');

Thanks,
Alejandro

From: Darpan Patel <da...@gmail.com>>
Reply-To: "user@ambari.apache.org<ma...@ambari.apache.org>" <us...@ambari.apache.org>>
Date: Tuesday, December 8, 2015 at 7:32 AM
To: "user@ambari.apache.org<ma...@ambari.apache.org>" <us...@ambari.apache.org>>, "dev@ambari.apache.org<ma...@ambari.apache.org>" <de...@ambari.apache.org>>
Subject: Issue removing and re-adding the components in Ambari

Hi folks,

I am running Version 2.1.2 of Ambari , HDP 2.3 on multinode cluster.
I was facing the issues in Knox component so decided to remove the service and re-install it.
So I removed issued following command and it disappeared through Ambari web portal.
// valid admin
curl -v -u admin:Ambari-AdminPassword -H "X-Requested-By:ambari" -X DELETE "http://AMBARI_HOST:8080/api/v1/clusters/SecureCluster/services/KNOX"

However when I check in the /usr/hdp/2.3.2.0-2950 directory I found that knox-server and it's directories were not removed. I manually deleted this directory and re-initiated the Knox setup through Ambari. It goes up to step 6 and shows a popup saying : Internal Server error.


When I check the Ambari-server logs it looks like service is already present.

Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "clusterservices_pkey"
  Detail: Key (service_name, cluster_id)=(KNOX, 2) already exists.
Error Code: 0
Call: INSERT INTO clusterservices (service_name, service_enabled, cluster_id) VALUES (?, ?, ?)
        bind => [3 parameters bound]
Query: InsertObjectQuery(org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity@fadf9954)
        at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1611)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:898)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:962)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:631)
        at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatch(ParameterizedSQLBatchWritingMechanism.java:149)
        at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatchedStatements(ParameterizedSQLBatchWritingMechanism.java:134)
        at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.appendCall(ParameterizedSQLBatchWritingMechanism.java:82)
.......
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "clusterservices_pkey"
  Detail: Key (service_name, cluster_id)=(KNOX, 2) already exists.
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)

What is the way around? Am I supposed to manually remove the Ambari related database/tables, in which scenario which db/table should we update manually?

Regards,
DP


Re: Issue removing and re-adding the components in Ambari

Posted by Alejandro Fernandez <af...@hortonworks.com>.
Ambari 2.2 makes it safer to delete services, thanks to Sid Wagle. There were several Jiras related to fixing DB inconsistencies.

[cid:DF1928C7-B84A-4051-81CD-C26A760EF334]

Thanks,
Alejandro

From: Darpan Patel <da...@gmail.com>>
Reply-To: "user@ambari.apache.org<ma...@ambari.apache.org>" <us...@ambari.apache.org>>
Date: Tuesday, December 8, 2015 at 1:54 PM
To: "user@ambari.apache.org<ma...@ambari.apache.org>" <us...@ambari.apache.org>>
Cc: "dev@ambari.apache.org<ma...@ambari.apache.org>" <de...@ambari.apache.org>>
Subject: Re: Issue removing and re-adding the components in Ambari

Thanks Alejandro,

I executed the commands to delete the service.
Do you not think REST API should also execute update the tables to avoid any confusions?

Regards,
DP

On 8 December 2015 at 18:25, Alejandro Fernandez <af...@hortonworks.com>> wrote:
Hi Darpan,

I suspect that the curl call to delete KNOX only removed it from some of the database tables.
Removing a services does not make any modifications to the actual agents, such as removing bits and configs.
If you re-add that service you may have to make sure that no other tables have references to it. E.g.

DELETE FROM hostcomponentstate WHERE service_name IN ('KNOX');
DELETE FROM hostcomponentdesiredstate WHERE service_name IN ('KNOX');
DELETE FROM servicecomponentdesiredstate WHERE service_name IN ('KNOX');
DELETE FROM servicedesiredstate WHERE service_name IN ('KNOX');
DELETE FROM clusterservices WHERE service_name IN ('KNOXr');

Thanks,
Alejandro

From: Darpan Patel <da...@gmail.com>>
Reply-To: "user@ambari.apache.org<ma...@ambari.apache.org>" <us...@ambari.apache.org>>
Date: Tuesday, December 8, 2015 at 7:32 AM
To: "user@ambari.apache.org<ma...@ambari.apache.org>" <us...@ambari.apache.org>>, "dev@ambari.apache.org<ma...@ambari.apache.org>" <de...@ambari.apache.org>>
Subject: Issue removing and re-adding the components in Ambari

Hi folks,

I am running Version 2.1.2 of Ambari , HDP 2.3 on multinode cluster.
I was facing the issues in Knox component so decided to remove the service and re-install it.
So I removed issued following command and it disappeared through Ambari web portal.
// valid admin
curl -v -u admin:Ambari-AdminPassword -H "X-Requested-By:ambari" -X DELETE "http://AMBARI_HOST:8080/api/v1/clusters/SecureCluster/services/KNOX"

However when I check in the /usr/hdp/2.3.2.0-2950 directory I found that knox-server and it's directories were not removed. I manually deleted this directory and re-initiated the Knox setup through Ambari. It goes up to step 6 and shows a popup saying : Internal Server error.


When I check the Ambari-server logs it looks like service is already present.

Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "clusterservices_pkey"
  Detail: Key (service_name, cluster_id)=(KNOX, 2) already exists.
Error Code: 0
Call: INSERT INTO clusterservices (service_name, service_enabled, cluster_id) VALUES (?, ?, ?)
        bind => [3 parameters bound]
Query: InsertObjectQuery(org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity@fadf9954)
        at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1611)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:898)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:962)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:631)
        at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatch(ParameterizedSQLBatchWritingMechanism.java:149)
        at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatchedStatements(ParameterizedSQLBatchWritingMechanism.java:134)
        at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.appendCall(ParameterizedSQLBatchWritingMechanism.java:82)
.......
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "clusterservices_pkey"
  Detail: Key (service_name, cluster_id)=(KNOX, 2) already exists.
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)

What is the way around? Am I supposed to manually remove the Ambari related database/tables, in which scenario which db/table should we update manually?

Regards,
DP


Re: Issue removing and re-adding the components in Ambari

Posted by Darpan Patel <da...@gmail.com>.
Thanks Alejandro,

I executed the commands to delete the service.
Do you not think REST API should also execute update the tables to avoid
any confusions?

Regards,
DP

On 8 December 2015 at 18:25, Alejandro Fernandez <afernandez@hortonworks.com
> wrote:

> Hi Darpan,
>
> I suspect that the curl call to delete KNOX only removed it from some of
> the database tables.
> Removing a services does not make any modifications to the actual agents,
> such as removing bits and configs.
> If you re-add that service you may have to make sure that no other tables
> have references to it. E.g.
>
> DELETE FROM hostcomponentstate WHERE service_name IN ('KNOX');
> DELETE FROM hostcomponentdesiredstate WHERE service_name IN ('KNOX');
> DELETE FROM servicecomponentdesiredstate WHERE service_name IN ('KNOX');
> DELETE FROM servicedesiredstate WHERE service_name IN ('KNOX');
> DELETE FROM clusterservices WHERE service_name IN ('KNOXr');
>
> Thanks,
> Alejandro
>
> From: Darpan Patel <da...@gmail.com>
> Reply-To: "user@ambari.apache.org" <us...@ambari.apache.org>
> Date: Tuesday, December 8, 2015 at 7:32 AM
> To: "user@ambari.apache.org" <us...@ambari.apache.org>, "
> dev@ambari.apache.org" <de...@ambari.apache.org>
> Subject: Issue removing and re-adding the components in Ambari
>
> Hi folks,
>
> I am running Version 2.1.2 of Ambari , HDP 2.3 on multinode cluster.
> I was facing the issues in Knox component so decided to remove the service
> and re-install it.
> So I removed issued following command and it disappeared through Ambari
> web portal.
> // valid admin
>
> *curl -v -u admin:Ambari-AdminPassword -H "X-Requested-By:ambari" -X
> DELETE "http://AMBARI_HOST:8080/api/v1/clusters/SecureCluster/services/KNOX
> <http://AMBARI_HOST:8080/api/v1/clusters/SecureCluster/services/KNOX>" *
>
> However when I check in the /usr/hdp/2.3.2.0-2950 directory I found that
> knox-server and it's directories were not removed. I manually deleted this
> directory and re-initiated the Knox setup through Ambari. It goes up to
> step 6 and shows a popup saying : Internal Server error.
>
>
> When I check the Ambari-server logs it looks like service is already
> present.
>
> *Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services -
> 2.5.2.v20140319-9ad6abd):
> org.eclipse.persistence.exceptions.DatabaseException*
> *Internal Exception: org.postgresql.util.PSQLException: ERROR: duplicate
> key value violates unique constraint "clusterservices_pkey"*
> *  Detail: Key (service_name, cluster_id)=(KNOX, 2) already exists.*
> *Error Code: 0*
> Call: INSERT INTO clusterservices (service_name, service_enabled,
> cluster_id) VALUES (?, ?, ?)
>         bind => [3 parameters bound]
> Query:
> InsertObjectQuery(org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity@fadf9954
> )
>         at
> org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
>         at
> org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1611)
>         at
> org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:898)
>         at
> org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:962)
>         at
> org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:631)
>         at
> org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatch(ParameterizedSQLBatchWritingMechanism.java:149)
>         at
> org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatchedStatements(ParameterizedSQLBatchWritingMechanism.java:134)
>         at
> org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.appendCall(ParameterizedSQLBatchWritingMechanism.java:82)
> .......
> *Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value
> violates unique constraint "clusterservices_pkey"*
> *  Detail: Key (service_name, cluster_id)=(KNOX, 2) already exists.*
>         at
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
>         at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)
>
> What is the way around? Am I supposed to manually remove the Ambari
> related database/tables, in which scenario which db/table should we update
> manually?
>
> Regards,
> DP
>

Re: Issue removing and re-adding the components in Ambari

Posted by Darpan Patel <da...@gmail.com>.
Thanks Alejandro,

I executed the commands to delete the service.
Do you not think REST API should also execute update the tables to avoid
any confusions?

Regards,
DP

On 8 December 2015 at 18:25, Alejandro Fernandez <afernandez@hortonworks.com
> wrote:

> Hi Darpan,
>
> I suspect that the curl call to delete KNOX only removed it from some of
> the database tables.
> Removing a services does not make any modifications to the actual agents,
> such as removing bits and configs.
> If you re-add that service you may have to make sure that no other tables
> have references to it. E.g.
>
> DELETE FROM hostcomponentstate WHERE service_name IN ('KNOX');
> DELETE FROM hostcomponentdesiredstate WHERE service_name IN ('KNOX');
> DELETE FROM servicecomponentdesiredstate WHERE service_name IN ('KNOX');
> DELETE FROM servicedesiredstate WHERE service_name IN ('KNOX');
> DELETE FROM clusterservices WHERE service_name IN ('KNOXr');
>
> Thanks,
> Alejandro
>
> From: Darpan Patel <da...@gmail.com>
> Reply-To: "user@ambari.apache.org" <us...@ambari.apache.org>
> Date: Tuesday, December 8, 2015 at 7:32 AM
> To: "user@ambari.apache.org" <us...@ambari.apache.org>, "
> dev@ambari.apache.org" <de...@ambari.apache.org>
> Subject: Issue removing and re-adding the components in Ambari
>
> Hi folks,
>
> I am running Version 2.1.2 of Ambari , HDP 2.3 on multinode cluster.
> I was facing the issues in Knox component so decided to remove the service
> and re-install it.
> So I removed issued following command and it disappeared through Ambari
> web portal.
> // valid admin
>
> *curl -v -u admin:Ambari-AdminPassword -H "X-Requested-By:ambari" -X
> DELETE "http://AMBARI_HOST:8080/api/v1/clusters/SecureCluster/services/KNOX
> <http://AMBARI_HOST:8080/api/v1/clusters/SecureCluster/services/KNOX>" *
>
> However when I check in the /usr/hdp/2.3.2.0-2950 directory I found that
> knox-server and it's directories were not removed. I manually deleted this
> directory and re-initiated the Knox setup through Ambari. It goes up to
> step 6 and shows a popup saying : Internal Server error.
>
>
> When I check the Ambari-server logs it looks like service is already
> present.
>
> *Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services -
> 2.5.2.v20140319-9ad6abd):
> org.eclipse.persistence.exceptions.DatabaseException*
> *Internal Exception: org.postgresql.util.PSQLException: ERROR: duplicate
> key value violates unique constraint "clusterservices_pkey"*
> *  Detail: Key (service_name, cluster_id)=(KNOX, 2) already exists.*
> *Error Code: 0*
> Call: INSERT INTO clusterservices (service_name, service_enabled,
> cluster_id) VALUES (?, ?, ?)
>         bind => [3 parameters bound]
> Query:
> InsertObjectQuery(org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity@fadf9954
> )
>         at
> org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
>         at
> org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1611)
>         at
> org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:898)
>         at
> org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:962)
>         at
> org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:631)
>         at
> org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatch(ParameterizedSQLBatchWritingMechanism.java:149)
>         at
> org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatchedStatements(ParameterizedSQLBatchWritingMechanism.java:134)
>         at
> org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.appendCall(ParameterizedSQLBatchWritingMechanism.java:82)
> .......
> *Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value
> violates unique constraint "clusterservices_pkey"*
> *  Detail: Key (service_name, cluster_id)=(KNOX, 2) already exists.*
>         at
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
>         at
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)
>
> What is the way around? Am I supposed to manually remove the Ambari
> related database/tables, in which scenario which db/table should we update
> manually?
>
> Regards,
> DP
>

Re: Issue removing and re-adding the components in Ambari

Posted by Alejandro Fernandez <af...@hortonworks.com>.
Hi Darpan,

I suspect that the curl call to delete KNOX only removed it from some of the database tables.
Removing a services does not make any modifications to the actual agents, such as removing bits and configs.
If you re-add that service you may have to make sure that no other tables have references to it. E.g.

DELETE FROM hostcomponentstate WHERE service_name IN ('KNOX');
DELETE FROM hostcomponentdesiredstate WHERE service_name IN ('KNOX');
DELETE FROM servicecomponentdesiredstate WHERE service_name IN ('KNOX');
DELETE FROM servicedesiredstate WHERE service_name IN ('KNOX');
DELETE FROM clusterservices WHERE service_name IN ('KNOXr');

Thanks,
Alejandro

From: Darpan Patel <da...@gmail.com>>
Reply-To: "user@ambari.apache.org<ma...@ambari.apache.org>" <us...@ambari.apache.org>>
Date: Tuesday, December 8, 2015 at 7:32 AM
To: "user@ambari.apache.org<ma...@ambari.apache.org>" <us...@ambari.apache.org>>, "dev@ambari.apache.org<ma...@ambari.apache.org>" <de...@ambari.apache.org>>
Subject: Issue removing and re-adding the components in Ambari

Hi folks,

I am running Version 2.1.2 of Ambari , HDP 2.3 on multinode cluster.
I was facing the issues in Knox component so decided to remove the service and re-install it.
So I removed issued following command and it disappeared through Ambari web portal.
// valid admin
curl -v -u admin:Ambari-AdminPassword -H "X-Requested-By:ambari" -X DELETE "http://AMBARI_HOST:8080/api/v1/clusters/SecureCluster/services/KNOX"

However when I check in the /usr/hdp/2.3.2.0-2950 directory I found that knox-server and it's directories were not removed. I manually deleted this directory and re-initiated the Knox setup through Ambari. It goes up to step 6 and shows a popup saying : Internal Server error.


When I check the Ambari-server logs it looks like service is already present.

Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "clusterservices_pkey"
  Detail: Key (service_name, cluster_id)=(KNOX, 2) already exists.
Error Code: 0
Call: INSERT INTO clusterservices (service_name, service_enabled, cluster_id) VALUES (?, ?, ?)
        bind => [3 parameters bound]
Query: InsertObjectQuery(org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity@fadf9954)
        at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1611)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:898)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:962)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:631)
        at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatch(ParameterizedSQLBatchWritingMechanism.java:149)
        at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatchedStatements(ParameterizedSQLBatchWritingMechanism.java:134)
        at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.appendCall(ParameterizedSQLBatchWritingMechanism.java:82)
.......
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "clusterservices_pkey"
  Detail: Key (service_name, cluster_id)=(KNOX, 2) already exists.
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)

What is the way around? Am I supposed to manually remove the Ambari related database/tables, in which scenario which db/table should we update manually?

Regards,
DP

Re: Issue removing and re-adding the components in Ambari

Posted by Alejandro Fernandez <af...@hortonworks.com>.
Hi Darpan,

I suspect that the curl call to delete KNOX only removed it from some of the database tables.
Removing a services does not make any modifications to the actual agents, such as removing bits and configs.
If you re-add that service you may have to make sure that no other tables have references to it. E.g.

DELETE FROM hostcomponentstate WHERE service_name IN ('KNOX');
DELETE FROM hostcomponentdesiredstate WHERE service_name IN ('KNOX');
DELETE FROM servicecomponentdesiredstate WHERE service_name IN ('KNOX');
DELETE FROM servicedesiredstate WHERE service_name IN ('KNOX');
DELETE FROM clusterservices WHERE service_name IN ('KNOXr');

Thanks,
Alejandro

From: Darpan Patel <da...@gmail.com>>
Reply-To: "user@ambari.apache.org<ma...@ambari.apache.org>" <us...@ambari.apache.org>>
Date: Tuesday, December 8, 2015 at 7:32 AM
To: "user@ambari.apache.org<ma...@ambari.apache.org>" <us...@ambari.apache.org>>, "dev@ambari.apache.org<ma...@ambari.apache.org>" <de...@ambari.apache.org>>
Subject: Issue removing and re-adding the components in Ambari

Hi folks,

I am running Version 2.1.2 of Ambari , HDP 2.3 on multinode cluster.
I was facing the issues in Knox component so decided to remove the service and re-install it.
So I removed issued following command and it disappeared through Ambari web portal.
// valid admin
curl -v -u admin:Ambari-AdminPassword -H "X-Requested-By:ambari" -X DELETE "http://AMBARI_HOST:8080/api/v1/clusters/SecureCluster/services/KNOX"

However when I check in the /usr/hdp/2.3.2.0-2950 directory I found that knox-server and it's directories were not removed. I manually deleted this directory and re-initiated the Knox setup through Ambari. It goes up to step 6 and shows a popup saying : Internal Server error.


When I check the Ambari-server logs it looks like service is already present.

Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "clusterservices_pkey"
  Detail: Key (service_name, cluster_id)=(KNOX, 2) already exists.
Error Code: 0
Call: INSERT INTO clusterservices (service_name, service_enabled, cluster_id) VALUES (?, ?, ?)
        bind => [3 parameters bound]
Query: InsertObjectQuery(org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity@fadf9954)
        at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1611)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:898)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:962)
        at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:631)
        at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatch(ParameterizedSQLBatchWritingMechanism.java:149)
        at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.executeBatchedStatements(ParameterizedSQLBatchWritingMechanism.java:134)
        at org.eclipse.persistence.internal.databaseaccess.ParameterizedSQLBatchWritingMechanism.appendCall(ParameterizedSQLBatchWritingMechanism.java:82)
.......
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "clusterservices_pkey"
  Detail: Key (service_name, cluster_id)=(KNOX, 2) already exists.
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)

What is the way around? Am I supposed to manually remove the Ambari related database/tables, in which scenario which db/table should we update manually?

Regards,
DP