測試mesos-dns是否生效方案(mesos-dns服務)

1) 在marathon中啓動mesos-dnshtml

2) 啓動一個nginx的docker,裏面默認監聽的是80端口.nginx

    nginx的docker.jsonweb

[root@centos7 mywork]# cat docker_nginx.json 
{
  "id":"nginx",
  "cpus":0.2,
  "mem":20.0,
  "instances": 2,
  "container": {
    "type":"DOCKER",
    "docker": {
     "image": "nginx",
     "network": "BRIDGE",
     "portMappings":[{"containerPort":80,"hostPort":0,"servicePort":0,"protocol":"tcp"}]
    }
  }
}

docker鏡像能夠本身製做,或者使用官方的.docker

注意network是bridge,json

這時候使用marathon部署centos

curl -X POST http://marathon_host:8080/v2/apps -d @docker_nginx.json -H "Content-type: application/json"

注意裏面的marathon_host是marathon的主機ip地址bash

而後啓動成功了docker,能夠查看docker啓動參數服務器

[root@centos7 mywork]# docker ps 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                            NAMES
d10449254a57        nginx               "nginx -g 'daemon off"   6 minutes ago       Up 6 minutes        443/tcp, 0.0.0.0:31762->80/tcp   mesos-10d09140-00f7-4c4f-be72-bc3309fa87da-S0.c7737b67-8665-488f-b18c-42273e8b0129
1c3fb8b48ac1        nginx               "nginx -g 'daemon off"   6 minutes ago       Up 6 minutes        443/tcp, 0.0.0.0:31437->80/tcp   mesos-10d09140-00f7-4c4f-be72-bc3309fa87da-S0.8fb96e2a-b92e-44fb-8319-afb4e7a67737

能夠了,端口已經映射出來了,啓動了2個nginx容器,其中一個是31762對應裏面的80,另一個是31437對應裏面的80,這裏的hostPort在配置文件裏面是0,因此端口是隨機的.app

使用dig測試,可否發現以上啓動的2個鏡像主機框架

[root@centos7 ~]# dig _nginx._tcp.marathon.mesos SRV

; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.3 <<>> _nginx._tcp.marathon.mesos SRV
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46384
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 2

;; QUESTION SECTION:
;_nginx._tcp.marathon.mesos.    IN      SRV

;; ANSWER SECTION:
_nginx._tcp.marathon.mesos. 60  IN      SRV     0 0 31437 nginx-fkt8j-s0.marathon.mesos.
_nginx._tcp.marathon.mesos. 60  IN      SRV     0 0 31762 nginx-wgiaq-s0.marathon.mesos.

;; ADDITIONAL SECTION:
nginx-fkt8j-s0.marathon.mesos. 60 IN    A       172.17.0.2
nginx-wgiaq-s0.marathon.mesos. 60 IN    A       172.17.0.3

;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: 五 5月 20 10:32:17 CST 2016
;; MSG SIZE  rcvd: 204

主要注意,將centos7_1(mesos-dns的主機)

[root@centos7 ~]# cat /etc/resolv.conf 
# Generated by NetworkManager
nameserver mesos-dns部署所在的主機ip

其中mesos-dns部署所在的主機ip須要修改一下,

dig的具體指令怎麼使用,請查看

http://blog.csdn.net/dyllove98/article/details/8898070

使用 dig _nginx._tcp.marathon.mesos SRV

其中nginx爲部署的應用名稱, marathon是框架名稱, mesos是domain

發現了2臺服務器

直接請求服務器後面對應的ip好像不行,由於network設置的是bridge

那就直接請求nginx-fkt8j-s0.marathon.mesos

[root@centos7 ~]# curl nginx-fkt8j-s0.marathon.mesos
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

 說明dns已經生效,須要在mesos-slave的全部機器上,都加上mesos-dns的主機名到/etc/resolv.conf

相關文章
相關標籤/搜索