如何删除Apache Mesos中的孤立任务?

时间:2016-10-18 01:40:43

标签: mesos marathon

问题可能是由Mesos和Marathon引起的out of sync,但GitHub上提到的解决方案对我不起作用。

当我找到孤儿的任务时:

enter image description here

我的工作是:

  1. 重启Marathon

  2. Marathon不会同步孤立的任务,但会启动新任务。

  3. 孤立的任务仍占用资源,因此我必须将其删除。

  4. 我在框架ef169d8a-24fc-41d1-8b0d-c67718937a48-0000

    下找到所有孤立的任务
    curl -XGET `http://c196:5050/master/frameworks
    

    表明该框架为unregistered_frameworks

    {
        "frameworks": [
            .....
        ],
        "completed_frameworks": [ ],
        "unregistered_frameworks": [
            "ef169d8a-24fc-41d1-8b0d-c67718937a48-0000",
            "ef169d8a-24fc-41d1-8b0d-c67718937a48-0000",
            "ef169d8a-24fc-41d1-8b0d-c67718937a48-0000"
        ]
    }
    
  5. 尝试按框架ID删除框架(以便框架下的任务也将被删除)

    curl -XPOST http://c196:5050/master/teardown -d 'frameworkId=ef169d8a-24fc-41d1-8b0d-c67718937a48-0000'
    

    但获取No framework found with specified ID

  6. 那么,如何删除孤立的任务?

1 个答案:

答案 0 :(得分:1)

有两个选项

  1. 使用相同的框架ID注册框架。进行和解并杀死您收到的所有任务。例如,您可以按照以下方式执行此操作

    • 下载代码git clone https://github.com/janisz/mesos-cookbook.git
    • 更改目录cd mesos-cookbook/4_understanding_frameworks
    • scheduler.go更改主网址
    • 如果您想模仿其他框架,请创建/tmp/framework.json并将其填入FrameworkInfo数据:

      {
        "id": "<mesos-framewokr-id>",
        "user": "<framework-user>",
        "name": "<framework-name>",
        "failover_timeout": 3600,
        "checkpoint": true,
        "hostname": "<hostname>",
        "webui_url": "<framework-web-ui>"
      }
      
    • 运行go run scheduler.go scheduler.pb.go mesos.pb.go

    • 获取所有任务的列表curl localhost:9090
    • 使用curl删除任务-X DELETE“http://10.10.10.10:9090/?id=task_id
  2. 等到failover_timeout,因此Mesos会为您删除此任务。

相关问题