1)下載相關(guān)驚喜
manager-node節(jié)點(diǎn)(182.48.115.237)
[root@manager-node ~]
# docker pull progrium/consul
[root@manager-node ~]
# docker pull rethinkdb
[root@manager-node ~]
# docker pull shipyard/shipyard
[root@manager-node ~]
# docker pull gliderlabs/registrator
node1和node2節(jié)點(diǎn)上
[root@node1 ~]
# docker pull progrium/consul
[root@node1 ~]
# docker pull gliderlabs/registrator
2)啟動(dòng)consul
manager-node節(jié)點(diǎn)(182.48.115.237)
[root@manager-node ~]
# docker run -d -p 8300:8300 -p 8301:8301 -p 8301:8301/udp -p 8302:8302 -p 8302:8302/udp -p 8400:8400 -p 8500:8500 -p 8600:53 -p 8600:53/udp -h manager-node --restart=always --name=consul progrium/consul -server -bootstrap -ui-dir=/ui -advertise 182.48.115.237 -client 0.0.0.0
----------------------------------------------------------------------------------------------
解釋下各個(gè)參數(shù):
-d 容器在后臺(tái)運(yùn)行, detached mode
--restart=always 重啟模式, always 表示永遠(yuǎn)
-p 8400:8400 映射 consul的 rpc 端口8400
-p 8500:8500 映射到公共 IP 這樣方便我們使用 UI 界面.
-p 8600:53
/udp
綁定udp 端口53(默認(rèn) DNS端口)在 docker0 bridge 地址上.
-advertise 182.48.115.237 服務(wù)對(duì)外公布的 IP, 這里特意設(shè)置為182.48.115.237, 否則 service 會(huì)顯示為內(nèi)部的容器的 IP 地址, 這樣就訪問(wèn)不到了.
-client 0.0.0.0 consul 監(jiān)聽的地址.
刪除consule命令(下面命令中的
"consul"
是啟動(dòng)consul命令中的--name后面的設(shè)置名)
# docker rm -f consul
----------------------------------------------------------------------------------------------
node1節(jié)點(diǎn)(182.48.115.238)
[root@node1 ~]
# docker run -d --restart=always -p 8300:8300 -p 8301:8301 -p 8301:8301/udp -p 8302:8302 -p 8302:8302/udp -p 8400:8400 -p 8500:8500 -h node1 --name=consul progrium/consul -server -join 182.48.115.237 -advertise 182.48.115.238 -client 0.0.0.0
node2節(jié)點(diǎn)(182.48.115.239)
[root@node2 ~]
# docker run -d --restart=always -p 8300:8300 -p 8301:8301 -p 8301:8301/udp -p 8302:8302 -p 8302:8302/udp -p 8400:8400 -p 8500:8500 -h node2 --name=consul progrium/consul -server -join 182.48.115.237 -advertise 182.48.115.239 -client 0.0.0.0
3)安裝Swarm+Shipyard
manager-node節(jié)點(diǎn)(182.48.115.237)
[root@manager-node ~]
# docker run -d --restart=always --name shipyard-rethinkdb rethinkdb
[root@manager-node ~]
# docker run -d -p 3375:3375 --restart=always --name shipyard-swarm-manager swarm:latest manage --host tcp://0.0.0.0:3375 consul://182.48.115.237:8500
node1節(jié)點(diǎn)(182.48.115.238)
[root@node1 ~]
# docker run -d --restart=always --name shipyard-swarm-agent swarm:latest join --addr 182.48.115.238:2375 consul://182.48.115.237:8500
node2節(jié)點(diǎn)(182.48.115.239)
[root@node2 ~]
# docker run -d --restart=always --name shipyard-swarm-agent swarm:latest join --addr 182.48.115.239:2375 consul://182.48.115.237:8500
接著再回到manager-node節(jié)點(diǎn)上如下操作
[root@manager-node web]
# docker run -d --restart=always --name shipyard-controller --link shipyard-rethinkdb:rethinkdb --link shipyard-swarm-manager:swarm -p 8080:8080 shipyard/shipyard:latest server -d tcp://swarm:3375
然后就可以在瀏覽器訪問(wèn)182.48.115.237這臺(tái)機(jī)器的8080端口, 就能看到shipyard的登錄頁(yè)面拉, 默認(rèn)賬戶是 admin, 密碼shipyard.