創(chuàng)建將托管發(fā)現(xiàn)服務(wù)的計(jì)算機(jī): docker-machine create -d=virtualbox consul-machine
Running pre-create checks...
Creating machine...
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available...
Detecting operating system of created instance...
Provisioning created instance...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
To see how to connect Docker to this machine, run: docker-machine env consul-machine
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f05d8dd11e7f progrium/consul "/bin/start -server -" 30 seconds ago Up 29 seconds 53/tcp, 53/udp, 8300-8302/tcp, 8400/tcp, 0.0.0.0:8500->8500/tcp, 8301-8302/udp consul_myconsul_1
使用Docker Machine創(chuàng)建Docker Swarm集群
Swarm與Machine完全集成在一起,因此是最簡(jiǎn)單的入門方法。
創(chuàng)建一個(gè)Swarm Master并指向Consul發(fā)現(xiàn)服務(wù): docker-machine create -d virtualbox --virtualbox-disk-size "5000" --swarm --swarm-master --swarm-discovery="consul://$(docker-machine ip consul-machine):8500" --engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500" --engine-opt="cluster-advertise=eth1:2376" swarm-master
Running pre-create checks...
Creating machine...
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available...
Detecting operating system of created instance...
Provisioning created instance...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Configuring swarm...
To see how to connect Docker to this machine, run: docker-machine env swarm-master
創(chuàng)建一個(gè)新計(jì)算機(jī)以加入該集群: docker-machine create -d virtualbox --virtualbox-disk-size "5000" --swarm --swarm-discovery="consul://$(docker-machine ip consul-machine):8500" --engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500" --engine-opt="cluster-advertise=eth1:2376" swarm-node-01
Running pre-create checks...
Creating machine...
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available...
Detecting operating system of created instance...
Provisioning created instance...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Configuring swarm...
To see how to connect Docker to this machine, run: docker-machine env swarm-node-01
創(chuàng)建第二個(gè)Swarm節(jié)點(diǎn)以加入該集群: docker-machine create -d virtualbox --virtualbox-disk-size "5000" --swarm --swarm-discovery="consul://$(docker-machine ip consul-machine):8500" --engine-opt="cluster-store=consul://$(docker-machine ip consul-machine):8500" --engine-opt="cluster-advertise=eth1:2376" swarm-node-02
Running pre-create checks...
Creating machine...
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available...
Detecting operating system of created instance...
Provisioning created instance...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Configuring swarm...
To see how to connect Docker to this machine, run: docker-machine env swarm-node-02
列出所有創(chuàng)建的計(jì)算機(jī): docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
consul-machine - virtualbox Running tcp://192.168.99.100:2376
swarm-master * virtualbox Running tcp://192.168.99.101:2376 swarm-master (master)
swarm-node-01 - virtualbox Running tcp://192.168.99.102:2376 swarm-master
swarm-node-02 - virtualbox Running tcp://192.168.99.103:2376 swarm-master
使用以下命令列出集群中的節(jié)點(diǎn): docker run swarm list consul://$(docker-machine ip consul-machine):8500
192.168.99.102:2376
192.168.99.103:2376
192.168.99.104:2376
可以使用REST API配置Couchbase服務(wù)器。 該應(yīng)用程序包含一個(gè)Maven配置文件,該配置文件允許使用travel-sample存儲(chǔ)桶配置Couchbase服務(wù)器。 可以通過(guò)以下方式調(diào)用: mvn install -Pcouchbase -Ddocker.host=$(docker-machine ip swarm-master). . .* Server auth using Basic with user 'Administrator'
> POST /sampleBuckets/install HTTP/1.1
> Authorization: Basic QWRtaW5pc3RyYXRvcjpwYXNzd29yZA==. . .} [data not shown]
* upload completely sent off: 17 out of 17 bytes
< HTTP/1.1 202 Accepted
* Server Couchbase Server is not blacklisted
< Server: Couchbase Server. . .
通過(guò)指定三個(gè)參數(shù)將應(yīng)用程序部署到WildFly:
運(yùn)行WildFly的主機(jī)IP地址
WildFly管理領(lǐng)域中用戶的用戶名
WildFly管理領(lǐng)域中指定的用戶密碼
mvn install -Pwildfly -Dwildfly.hostname=$(docker-machine ip swarm-node-01) -Dwildfly.username=admin -Dwildfly.password=Admin#007. . .Nov 29, 2015 12:11:14 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.3.1.Final
Nov 29, 2015 12:11:14 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.3.1.Final
Nov 29, 2015 12:11:15 AM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.9.Final
[INFO] Authenticating against security realm: ManagementRealm
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------. . .