doc-exports/docs/cce/umn/cce_bestpractice_0006.html
Dong, Qiu Jian 3d9cca138b CCE UMN: Added the support of the OS for features and cluster versions.
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com>
Co-authored-by: Dong, Qiu Jian <qiujiandong1@huawei.com>
Co-committed-by: Dong, Qiu Jian <qiujiandong1@huawei.com>
2023-06-20 14:52:27 +00:00

52 lines
10 KiB
HTML

<a name="cce_bestpractice_0006"></a><a name="cce_bestpractice_0006"></a>
<h1 class="topictitle1">Preparing the Application Runtime</h1>
<div id="body1513920519450"><p id="cce_bestpractice_0006__p1876119217415">After application analysis, you have gained the understanding of the OS and runtime required for running the application. You need to make the following preparations:</p>
<ul id="cce_bestpractice_0006__ul5419185114438"><li id="cce_bestpractice_0006__li030420315314"><a href="#cce_bestpractice_0006__section411319276259">Installing Docker</a>: During application containerization, you need to build a container image. To do so, you have to prepare a PC and install Docker on it.</li><li id="cce_bestpractice_0006__li6419551124313"><a href="#cce_bestpractice_0006__section7944139145718">Obtaining the base image tag</a>: Determine the base image based on the OS on which the application runs. In this example, the application runs on CentOS 7.1 and the base image can be obtained from an open-source image repository.</li><li id="cce_bestpractice_0006__li1021595644310"><a href="#cce_bestpractice_0006__section44401821348">Obtaining the runtime</a>: Obtain the runtime of the application and the MongoDB database with which the application interconnects.</li></ul>
<div class="section" id="cce_bestpractice_0006__section411319276259"><a name="cce_bestpractice_0006__section411319276259"></a><a name="section411319276259"></a><h4 class="sectiontitle">Installing Docker</h4><p id="cce_bestpractice_0006__p42063811352">Docker is compatible with almost all operating systems. Select a Docker version that best suits your needs.</p>
<div class="note" id="cce_bestpractice_0006__note52212683315"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="cce_bestpractice_0006__p622216123312">SWR uses Docker 1.11.2 or later to upload images. </p>
<p id="cce_bestpractice_0006__p1988211483713">You are advised to install Docker and build images as user <strong id="cce_bestpractice_0006__b6889455231">root</strong>. Obtain the password of user <strong id="cce_bestpractice_0006__b2541181315286">root</strong> of the host where Docker is to be installed in advance.</p>
</div></div>
<ol id="cce_bestpractice_0006__ol2641214343"><li id="cce_bestpractice_0006__li36432111347"><span>Log in as user <strong id="cce_bestpractice_0006__b927994211590">root</strong> to the device on which Docker is about to be installed.</span></li><li id="cce_bestpractice_0006__li168147577340"><span>Run the following commands to quickly install Docker on the device running Linux: </span><p><p id="cce_bestpractice_0006__p1612016158363"><strong id="cce_bestpractice_0006__b1990133420368">curl -fsSL get.docker.com -o get-docker.sh</strong></p>
<p id="cce_bestpractice_0006__p17133152319369"><strong id="cce_bestpractice_0006__b1999273453619">sh get-docker.sh</strong></p>
</p></li><li id="cce_bestpractice_0006__li1345359153715"><span>Run the following command to query the Docker version:</span><p><div class="p" id="cce_bestpractice_0006__p20723585307"><strong id="cce_bestpractice_0006__b12635134113713">docker version</strong><pre class="screen" id="cce_bestpractice_0006__screen9836172713719">Client:
<strong id="cce_bestpractice_0006__b575232115612">Version: 17.12.0-ce</strong>
API Version:1.35
...</pre>
</div>
<p id="cce_bestpractice_0006__p10725201012383"><strong id="cce_bestpractice_0006__b137991814537">Version</strong> indicates the version number. </p>
</p></li></ol>
</div>
<div class="section" id="cce_bestpractice_0006__section7944139145718"><a name="cce_bestpractice_0006__section7944139145718"></a><a name="section7944139145718"></a><h4 class="sectiontitle">Obtaining the Base Image Tag</h4><p id="cce_bestpractice_0006__p152721651175710">Determine the base image based on the OS on which the application runs. In this example, the application runs on CentOS 7.1 and the base image can be obtained from an open-source image repository.</p>
<div class="note" id="cce_bestpractice_0006__note7386131471320"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="cce_bestpractice_0006__p15386181491311">Search for the image tag based on the OS on which the application runs.</p>
</div></div>
<ol id="cce_bestpractice_0006__ol13116785815"><li id="cce_bestpractice_0006__li163117785818"><span>Visit the Docker website.</span></li><li id="cce_bestpractice_0006__li657419331408"><span>Search for CentOS. The image corresponding to CentOS 7.1 is <strong id="cce_bestpractice_0006__b12557428627">centos7.1.1503</strong>. You need to use this image name when compiling the Dockerfile.</span><p><div class="fignone" id="cce_bestpractice_0006__fig683828716"><span class="figcap"><b>Figure 1 </b>Obtaining the CentOS version</span><br><span><img id="cce_bestpractice_0006__image1283912811113" src="en-us_image_0091280734.png"></span></div>
</p></li></ol>
</div>
<div class="section" id="cce_bestpractice_0006__section44401821348"><a name="cce_bestpractice_0006__section44401821348"></a><a name="section44401821348"></a><h4 class="sectiontitle">Obtaining the Runtime</h4><p id="cce_bestpractice_0006__p171821930192710">In this example, the web application of the Tomcat type is used. This application requires the runtime of Tomcat 7.0, and Tomcat requires JDK 1.8. In addition, the application must interconnect with the MongoDB database in advance.</p>
<div class="note" id="cce_bestpractice_0006__note89901713101415"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="cce_bestpractice_0006__p1991131361419">Download the environment required by the application.</p>
</div></div>
<ol id="cce_bestpractice_0006__ol173142620419"><li id="cce_bestpractice_0006__li1774314119619"><span>Download Tomcat, JDK, and MongoDB installation packages of the specific versions.</span><p><ol type="a" id="cce_bestpractice_0006__ol1766215521666"><li id="cce_bestpractice_0006__li14463415333">Download JDK 1.8.<p id="cce_bestpractice_0006__p12862174218338"><a name="cce_bestpractice_0006__li14463415333"></a><a name="li14463415333"></a>Download address: <a href="https://www.oracle.com/java/technologies/jdk8-downloads.html" target="_blank" rel="noopener noreferrer">https://www.oracle.com/java/technologies/jdk8-downloads.html</a>.</p>
</li><li id="cce_bestpractice_0006__li4766155315518">Download Tomcat 7.0 from http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.82/bin/apache-tomcat-7.0.82.tar.gz.</li><li id="cce_bestpractice_0006__li15306161318614">Download MongoDB 3.2 from https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.9.tgz.</li></ol>
</p></li><li id="cce_bestpractice_0006__li4699271588"><span>Log in as user <strong id="cce_bestpractice_0006__b7490132544418">root</strong> to the device running Docker.</span></li><li id="cce_bestpractice_0006__li5541955"><span>Run the following commands to create the directory where the application is to be stored: For example, set the directory to <strong id="cce_bestpractice_0006__b16506121810401">apptest</strong>.</span><p><p id="cce_bestpractice_0006__p1543624854918"><strong id="cce_bestpractice_0006__b192895317179">mkdir apptest</strong></p>
<p id="cce_bestpractice_0006__p164638508496"><strong id="cce_bestpractice_0006__b10292203111172">cd apptest</strong></p>
</p></li><li id="cce_bestpractice_0006__li9663957664"><span>Use Xshell to save the downloaded dependency files to the <strong id="cce_bestpractice_0006__b1322811288407">apptest</strong> directory.</span></li><li id="cce_bestpractice_0006__li2046116913533"><span>Run the following commands to decompress the dependency files:</span><p><p id="cce_bestpractice_0006__p1647617536536"><strong id="cce_bestpractice_0006__b1447514329544">tar -zxf apache-tomcat-7.0.82.tar.gz</strong></p>
<p id="cce_bestpractice_0006__p144279565533"><strong id="cce_bestpractice_0006__b1847623211543">tar -zxf jdk-8u151-linux-x64.tar.gz</strong></p>
<p id="cce_bestpractice_0006__p1471595125317"><strong id="cce_bestpractice_0006__b174775326548">tar -zxf mongodb-linux-x86_64-rhel70-3.2.9.tgz</strong></p>
</p></li><li id="cce_bestpractice_0006__li15362115311206"><span>Save the enterprise application (for example, <strong id="cce_bestpractice_0006__b842352706172352">apptest.war</strong>) in the <strong id="cce_bestpractice_0006__b881016816537">webapps/apptest</strong> directory of the Tomcat runtime environment.</span><p><div class="note" id="cce_bestpractice_0006__note17371546141413"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="cce_bestpractice_0006__p1381446151420"><strong id="cce_bestpractice_0006__b658985375311">apptest.war</strong> is used as an example only. Use your own application for actual configuration.</p>
</div></div>
<p id="cce_bestpractice_0006__p1570653292311"><strong id="cce_bestpractice_0006__b19467948182319">mkdir -p apache-tomcat-7.0.82/webapps/app<strong id="cce_bestpractice_0006__b19922431202615">test</strong></strong></p>
<p id="cce_bestpractice_0006__p19802133614234"><strong id="cce_bestpractice_0006__b746944842310">cp apptest.war apache-tomcat-7.0.82/webapps/<strong id="cce_bestpractice_0006__b178901625122410">app<strong id="cce_bestpractice_0006__b194901336112616">test</strong></strong></strong></p>
<p id="cce_bestpractice_0006__p7903440172313"><strong id="cce_bestpractice_0006__b84711248192316">cd apache-tomcat-7.0.82/webapps/<strong id="cce_bestpractice_0006__b731315281244">app<strong id="cce_bestpractice_0006__b1489344119266">test</strong></strong></strong></p>
<p id="cce_bestpractice_0006__p96029435238"><strong id="cce_bestpractice_0006__b17472194814239">./../../../jdk1.8.0_151/bin/jar -xf <strong id="cce_bestpractice_0006__b87007317245">app</strong><strong id="cce_bestpractice_0006__b354064782617">test</strong>.war</strong></p>
<p id="cce_bestpractice_0006__p18405171910227"><strong id="cce_bestpractice_0006__b124736480237">rm -rf apptest.war</strong></p>
</p></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="cce_bestpractice_0340.html">Procedure</a></div>
</div>
</div>