如何在 Docker 容器中运行支持 OData 的 JBoss 数据虚拟化 GA
大家好,我们今天来学习如何在一个 Docker 容器中运行支持 OData(译者注:Open Data Protocol,开放数据协议) 的 JBoss 数据虚拟化 6.0.0 GA(译者注:GA,General Availability,具体定义可以查看WIKI)。JBoss 数据虚拟化是数据提供和集成解决方案平台,将多种分散的数据源转换为一种数据源统一对待,在正确的时间将所需数据传递给任意的应用或者用户。JBoss 数据虚拟化可以帮助我们将数据快速组合和转换为可重用的商业友好的数据模型,通过开放标准接口简单可用。它提供全面的数据抽取、联合、集成、转换,以及传输功能,将来自一个或多个源的数据组合为可重复使用和共享的灵活数据。要了解更多关于 JBoss 数据虚拟化的信息,可以查看它的官方文档。Docker 是一个提供开放平台用于打包,装载和以轻量级容器运行任何应用的开源平台。使用 Docker 容器我们可以轻松处理和启用支持 OData 的 JBoss 数据虚拟化。
下面是该指南中在 Docker 容器中运行支持 OData 的 JBoss 数据虚拟化的简单步骤。
1. 克隆仓库
首先,我们要用 git 命令从 https://github.com/jbossdemocentral/dv-odata-docker-integration-demo 克隆带数据虚拟化的 OData 仓库。假设我们的机器上运行着 Ubuntu 15.04 linux 发行版。我们要使用 apt-get 命令安装 git。
<span class="com">#</span><span class="kwd">apt-get</span><span class="pln"> install </span><span class="kwd">git</span>
安装完 git 之后,我们运行下面的命令克隆仓库。
<span class="com">#</span><span class="kwd">git</span><span class="kwd">clone</span><span class="pln"> https</span><span class="pun">:</span><span class="com">//github.com/jbossdemocentral/dv-odata-docker-integration-demo</span>
<span class="typ">Cloning</span><span class="pln"> into </span><span class="str">'dv-odata-docker-integration-demo'</span><span class="pun">...</span>
<span class="pln">remote</span><span class="pun">:</span><span class="typ">Counting</span><span class="pln"> objects</span><span class="pun">:</span><span class="lit">96</span><span class="pun">,</span><span class="kwd">done</span><span class="pun">.</span>
<span class="pln">remote</span><span class="pun">:</span><span class="typ">Total</span><span class="lit">96</span><span class="pun">(</span><span class="pln">delta </span><span class="lit">0</span><span class="pun">),</span><span class="pln"> reused </span><span class="lit">0</span><span class="pun">(</span><span class="pln">delta </span><span class="lit">0</span><span class="pun">),</span><span class="pln"> pack</span><span class="pun">-</span><span class="pln">reused </span><span class="lit">96</span>
<span class="typ">Unpacking</span><span class="pln"> objects</span><span class="pun">:</span><span class="lit">100</span><span class="pun">%</span><span class="pun">(</span><span class="lit">96</span><span class="pun">/</span><span class="lit">96</span><span class="pun">),</span><span class="kwd">done</span><span class="pun">.</span>
<span class="typ">Checking</span><span class="pln"> connectivity</span><span class="pun">...</span><span class="kwd">done</span><span class="pun">.</span>
2. 下载 JBoss 数据虚拟化安装器
现在,我们需要从下载页 http://www.jboss.org/products/datavirt/download/ 下载 JBoss 数据虚拟化安装器。下载了 jboss-dv-installer-6.0.0.GA-RedHat-4.jar 后,我们把它保存在名为 software 的目录下。
3. 创建 Docker 镜像
下一步,下载了 JBoss 数据虚拟化安装器之后,我们打算使用 Dockerfile 和刚从仓库中克隆的资源创建 docker 镜像。
<span class="com">#</span><span class="kwd">cd</span><span class="pln"> dv</span><span class="pun">-</span><span class="pln">odata</span><span class="pun">-</span><span class="pln">docker</span><span class="pun">-</span><span class="pln">integration</span><span class="pun">-</span><span class="pln">demo</span><span class="pun">/</span>
<span class="com">#</span><span class="pln"> docker build </span><span class="pun">-</span><span class="pln">t jbossdv600 </span><span class="pun">.</span>
<span class="pun">...</span>
<span class="typ">Step</span><span class="lit">22</span><span class="pun">:</span><span class="pln"> USER jboss</span>
<span class="pun">---></span><span class="typ">Running</span><span class="kwd">in</span><span class="lit">129f701febd0</span>
<span class="pun">---></span><span class="lit">342941381e37</span>
<span class="typ">Removing</span><span class="pln"> intermediate container </span><span class="lit">129f701febd0</span>
<span class="typ">Step</span><span class="lit">23</span><span class="pun">:</span><span class="pln"> EXPOSE </span><span class="lit">8080</span><span class="lit">9990</span><span class="lit">31000</span>
<span class="pun">---></span><span class="typ">Running</span><span class="kwd">in</span><span class="lit">61e6d2c26081</span>
<span class="pun">---></span><span class="lit">351159bb6280</span>
<span class="typ">Removing</span><span class="pln"> intermediate container </span><span class="lit">61e6d2c26081</span>
<span class="typ">Step</span><span class="lit">24</span><span class="pun">:</span><span class="pln"> CMD $JBOSS_HOME</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">standalone</span><span class="pun">.</span><span class="pln">sh </span><span class="pun">-</span><span class="pln">c standalone</span><span class="pun">.</span><span class="pln">xml </span><span class="pun">-</span><span class="pln">b </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span><span class="pun">-</span><span class="pln">bmanagement </span><span class="lit">0.0</span><span class="pun">.</span><span class="lit">0.0</span>
<span class="pun">---></span><span class="typ">Running</span><span class="kwd">in</span><span class="pln"> a9fed69b3000</span>
<span class="pun">---></span><span class="lit">407053dc470e</span>
<span class="typ">Removing</span><span class="pln"> intermediate container a9fed69b3000</span>
<span class="typ">Successfully</span><span class="pln"> built </span><span class="lit">407053dc470e</span>
注意:在这里我们假设你已经安装了 docker 并正在运行。
4. 启动 Docker 容器
创建了支持 oData 的 JBoss 数据虚拟化 Docker 镜像之后,我们打算运行 docker 容器并用 -P 标签指定端口。我们运行下面的命令来实现。
<span class="com">#</span><span class="pln"> docker run </span><span class="pun">-</span><span class="pln">p </span><span class="lit">8080</span><span class="pun">:</span><span class="lit">8080</span><span class="pun">-</span><span class="pln">d </span><span class="pun">-</span><span class="pln">t jbossdv600</span>
<span class="lit">7765dee9cd59c49ca26850e88f97c21f46859d2dc1d74166353d898773214c9c</span>
5. 获取容器 IP
启动了 Docker 容器之后,我们想要获取正在运行的 docker 容器的 IP 地址。要做到这点,我们运行后面添加了正在运行容器 id 号的 docker inspect 命令。
<span class="com">#</span><span class="pln"> docker inspect </span><span class="pun"><</span><span class="pln">$containerID</span><span class="pun">></span>
<span class="pun">...</span>
<span class="str">"NetworkSettings"</span><span class="pun">:</span><span class="pun">{</span>
<span class="str">"Bridge"</span><span class="pun">:</span><span class="str">""</span><span class="pun">,</span>
<span class="str">"EndpointID"</span><span class="pun">:</span><span class="str">"3e94c5900ac5954354a89591a8740ce2c653efde9232876bc94878e891564b39"</span><span class="pun">,</span>
<span class="str">"Gateway"</span><span class="pun">:</span><span class="str">"172.17.42.1"</span><span class="pun">,</span>
<span class="str">"GlobalIPv6Address"</span><span class="pun">:</span><span class="str">""</span><span class="pun">,</span>
<span class="str">"GlobalIPv6PrefixLen"</span><span class="pun">:</span><span class="lit">0</span><span class="pun">,</span>
<span class="str">"HairpinMode"</span><span class="pun">:</span><span class="kwd">false</span><span class="pun">,</span>
<span class="str">"IPAddress"</span><span class="pun">:</span><span class="str">"172.17.0.8"</span><span class="pun">,</span>
<span class="str">"IPPrefixLen"</span><span class="pun">:</span><span class="lit">16</span><span class="pun">,</span>
<span class="str">"IPv6Gateway"</span><span class="pun">:</span><span class="str">""</span><span class="pun">,</span>
<span class="str">"LinkLocalIPv6Address"</span><span class="pun">:</span><span class="str">""</span><span class="pun">,</span>
<span class="str">"LinkLocalIPv6PrefixLen"</span><span class="pun">:</span><span class="lit">0</span><span class="pun">,</span>
6. Web 界面
现在,如果一切如期望的那样进行,当我们用浏览器打开 http://container-ip:8080/ 和 http://container-ip:9990 时会看到支持 oData 的 JBoss 数据虚拟化登录界面和 JBoss 管理界面。管理验证的用户名和密码分别是 admin 和 redhat1!数据虚拟化验证的用户名和密码都是 user。之后,我们可以通过 web 界面在内容间导航。
注意: 强烈建议在第一次登录后尽快修改密码。
总结
终于我们成功地运行了跑着支持 OData 多源虚拟数据库的 JBoss 数据虚拟化 的 Docker 容器。JBoss 数据虚拟化真的是一个很棒的平台,它为多种不同来源的数据进行虚拟化,并将它们转换为商业友好的数据模型,产生通过开放标准接口简单可用的数据。使用 Docker 技术可以简单、安全、快速地部署支持 OData 多源虚拟数据库的 JBoss 数据虚拟化。如果你有任何疑问、建议或者反馈,请在下面的评论框中写下来,以便我们可以改进和更新内容。非常感谢!Enjoy:-)
更多Docker相关教程见以下内容:
Docker 的详细介绍:请点这里
Docker 的下载地址:请点这里
via: http://linoxide.com/linux-how-to/run-jboss-data-virtualization-ga-odata-docker-container/
作者:Arun Pyasi 译者:ictlyh 校对:wxy