【docker】--JBoss集群的搭建
2017-07-16 21:44
267 查看
【前言】
配置完成后的文件夹中要下面这些文件:
其中apptest.war就是你要放到docker中的程序。
【开始】
1、搭建网络
docker network create \
--driver=bridge \
--subnet=172.28.0.0/16 \
--ip-range=172.28.5.0/24 \
--gateway=172.28.5.254 \
wildnetwork
您可以使用所需的子网,范围和网关。只要做到正确
2、配置standalone.xml文件
在对应standalone-ha-*.xml文件的<interface></interface>里面添加:
standalone-ha-1.xml
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:172.28.5.0}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:172.28.5.0}"/>
</interface>
<interface name="private">
<inet-address value="${jboss.bind.address.private:172.28.5.0}"/>
</interface>
</interfaces>
standalone-ha-2.xml
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:172.28.5.2}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:172.28.5.2}"/>
</interface>
<interface name="private">
<inet-address value="${jboss.bind.address.private:172.28.5.2}"/>
</interface>
</interfaces>
standalone-ha-3.xml
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:172.28.5.3}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:172.28.5.3}"/>
</interface>
<interface name="private">
<inet-address value="${jboss.bind.address.private:172.28.5.3}"/>
</interface>
</interfaces>
3、编写Dockerfile
FROM jboss/wildfly
# Environment variable with default value
ARG APP_FILE=appfile.war
# Add your application to the deployment folder
ADD ${APP_FILE} /opt/jboss/wildfly/standalone/deployments/${APP_FILE}
# Add standalone-ha.xml - set your own network settings
ADD standalone-ha-1.xml /opt/jboss/wildfly/standalone/configuration/standalone-ha-1.xml
ADD standalone-ha-2.xml /opt/jboss/wildfly/standalone/configuration/standalone-ha-2.xml
ADD standalone-ha-3.xml /opt/jboss/wildfly/standalone/configuration/standalone-ha-3.xml
# Add user for adminstration purpose
RUN /opt/jboss/wildfly/bin/add-user.sh admin admin123 --silent4、构建镜像:
docker build -t wildfly-cluster --build-arg APP_FILE=apptest.war .这个单行命令将构建一个名为“wildfly-cluster”的映像(设备),部署“apptest.war”。不要忘记结束的点,这意味着在当前文件夹中有一个Docker文件。apptest.war
也应该在文件夹中。
我们把它们放在一起,并与一个负载平衡器:
docker run -d --name wild-balancer -p 80:80 \
--link wild1:wild1 \
--link wild2:wild2 \
--link wild3:wild3 \
--env-file ./env.list \
--network=wildnetwork \
--ip 172.28.5.4 jasonwyatt/nginx-loadbalancer
到此,JBoss集群在docker中就搭建成功了。现在试着去访问:HTTP://本地主机/
apptest /。
配置完成后的文件夹中要下面这些文件:
其中apptest.war就是你要放到docker中的程序。
【开始】
1、搭建网络
docker network create \
--driver=bridge \
--subnet=172.28.0.0/16 \
--ip-range=172.28.5.0/24 \
--gateway=172.28.5.254 \
wildnetwork
您可以使用所需的子网,范围和网关。只要做到正确
2、配置standalone.xml文件
在对应standalone-ha-*.xml文件的<interface></interface>里面添加:
standalone-ha-1.xml
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:172.28.5.0}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:172.28.5.0}"/>
</interface>
<interface name="private">
<inet-address value="${jboss.bind.address.private:172.28.5.0}"/>
</interface>
</interfaces>
standalone-ha-2.xml
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:172.28.5.2}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:172.28.5.2}"/>
</interface>
<interface name="private">
<inet-address value="${jboss.bind.address.private:172.28.5.2}"/>
</interface>
</interfaces>
standalone-ha-3.xml
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:172.28.5.3}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:172.28.5.3}"/>
</interface>
<interface name="private">
<inet-address value="${jboss.bind.address.private:172.28.5.3}"/>
</interface>
</interfaces>
3、编写Dockerfile
FROM jboss/wildfly
# Environment variable with default value
ARG APP_FILE=appfile.war
# Add your application to the deployment folder
ADD ${APP_FILE} /opt/jboss/wildfly/standalone/deployments/${APP_FILE}
# Add standalone-ha.xml - set your own network settings
ADD standalone-ha-1.xml /opt/jboss/wildfly/standalone/configuration/standalone-ha-1.xml
ADD standalone-ha-2.xml /opt/jboss/wildfly/standalone/configuration/standalone-ha-2.xml
ADD standalone-ha-3.xml /opt/jboss/wildfly/standalone/configuration/standalone-ha-3.xml
# Add user for adminstration purpose
RUN /opt/jboss/wildfly/bin/add-user.sh admin admin123 --silent4、构建镜像:
docker build -t wildfly-cluster --build-arg APP_FILE=apptest.war .这个单行命令将构建一个名为“wildfly-cluster”的映像(设备),部署“apptest.war”。不要忘记结束的点,这意味着在当前文件夹中有一个Docker文件。apptest.war
也应该在文件夹中。
我们把它们放在一起,并与一个负载平衡器:
docker run -d --name wild-balancer -p 80:80 \
--link wild1:wild1 \
--link wild2:wild2 \
--link wild3:wild3 \
--env-file ./env.list \
--network=wildnetwork \
--ip 172.28.5.4 jasonwyatt/nginx-loadbalancer
到此,JBoss集群在docker中就搭建成功了。现在试着去访问:HTTP://本地主机/
apptest /。
相关文章推荐
- Swarm搭建Docker集群
- docker搭建linux集群,搭建mpi环境,并使用MTT benchmark测试集群性能
- 搭建jboss集群共享session
- docker搭建redis3.2官方集群
- docker探索-swarm搭建docker集群(七)
- Docker中搭建zookeeper集群
- 一步一步详细搭建Spark集群在docker上
- JBOSS 5.0.0GA的集群搭建
- Docker 搭建 etcd 集群及管理
- docker搭建redis集群
- centos7搭建Docker Swarm 集群
- 使用Docker Toolbox快速搭建3节点的shipyard集群
- Docker swarm 集群监控平台搭建流程 (influxdb + cadvisor + grafana)
- docker swarm集群搭建
- 使用Docker在本地搭建Hadoop分布式集群
- docker应用-6(mysql+mycat 搭建数据库集群)
- 使用 Docker 一步搞定 ZooKeeper 集群的搭建
- 基于Docker快速搭建Hadoop集群
- 搭建ubuntu14.04的hadoop集群【docker容器充当服务器】