本文介绍了AWS创建失败:服务已存在。 (服务:AWSServiceDiscovery;状态代码:400;错误代码:ServiceAlreadyExists;请求ID)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是aws的新手,尝试在ECS集群中创建EC2服务时遇到了一些问题。



我能够成功创建全新的服务( service1)在cluster1中,但是之后,我决定删除cluster1并创建cluster2。当我尝试在cluster2中重新创建service1时出现了问题。每当我尝试添加服务时,都会出现以下错误

 创建失败:服务已存在。 (服务:AWSServiceDiscovery;状态代码:400;错误代码:ServiceAlreadyExists;请求ID:d854025e-ebcc-11e8-84ab-b3bac906f2ef)

有人知道如何解决此问题吗?我曾尝试注销任务定义,但没有成功。 cluster1已被删除,并且cluster2中没有任何服务。

解决方案

以下是完整答案。创建AWS ECS服务时,还为其选择了可选的ServiceDiscovery,它在Route53中创建了名称空间(.local)和服务(与ECS服务同名)。



删除ECS服务&集群,它不会自动删除Route53命名空间/服务条目。现在,由于新的ECS服务与ServiceDiscovery服务具有相同的名称,因此出现服务已存在错误。您有3个选择。 1.清理Route53命名空间和服务。 2.如果要继续使用ServiceDiscovery功能,请重新使用Route53服务。 3.创建ECS服务时不要启用服务发现集成。



选项1 -




  • 您无法通过控制台删除Route53 ServiceDiscovery命名空间和服务。您将需要使用AWS CLI。(确保已使用与创建ECS的帐户相同的AWS Key配置了CLI)


    i am new to aws and encountred some problem while trying to create a EC2 service in a ECS cluster.

    i was able to successfully create a brand new service (service1) in cluster1, but afterwards, i decided to delete cluster1 and create cluster2. The problem came when i try to re-create service1 in cluster2. whenever i try to add the service, i will get the following error

    creation failed: Service already exists. (Service: AWSServiceDiscovery; Status Code: 400; Error Code: ServiceAlreadyExists; Request ID: d854025e-ebcc-11e8-84ab-b3bac906f2ef)
    

    anyone know how to resolve this problem? i have tried deregistering the task definition but it didn't work. cluster1 has been deleted and there are no services in cluster2

    解决方案

    Here is full answer. When you created AWS ECS Service and you have also selected optional ServiceDiscovery for it as well which created an namespace(.local) and service(with same name as ECS Service) in Route53.

    When you deleted ECS service & cluster, it won't automatically delete Route53 namespace/service entries. Now, you are getting Service already exists error since your new ECS Service matches with same name as ServiceDiscovery service. You have 3 options. 1. Clean up Route53 namespaces and services. 2. Re-use Route53 Service if you want to continue to use ServiceDiscovery feature. 3. Don't enable service discovery integration when you are creating ECS Service.

    Option 1 -

    • You cannot delete Route53 ServiceDiscovery namespaces and service via Console. You will need to use AWS CLI.(Make sure you have configured CLI with AWS Keys same as the account where you have created ECS) https://docs.aws.amazon.com/cli/latest/reference/servicediscovery/index.html
    • List the Namespaces & Services with CLI using following commands and sample output you should get.
    • aws servicediscovery list-services

    • aws servicediscovery list-namespaces

    • Delete the Service first with command. aws servicediscovery delete-service --id "srv-x4acveybedar32mv" . Result is empty response from CLI.
    • Delete the namespace with command. aws servicediscovery delete-namespace --id "ns-3yd7pskwsxhwlq67"

    • That's all. Now, you can re-create ECS services which you wanted.

    Note -

    Sometimes, DNS cleanup operations will take couple of minutes to reflect properly so just give always few minutes before retrying.

    Option 2 -

    • Re-use Route53 Services by selecting exiting one instead of creating with same name.

    这篇关于AWS创建失败:服务已存在。 (服务:AWSServiceDiscovery;状态代码:400;错误代码:ServiceAlreadyExists;请求ID)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:47