doc-exports/docs/cce/umn/cce_bestpractice_0007.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

31 lines
3.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<a name="cce_bestpractice_0007"></a><a name="cce_bestpractice_0007"></a>
<h1 class="topictitle1">Compiling a Startup Script</h1>
<div id="body1514888645779"><p id="cce_bestpractice_0007__p11680173855217">During application containerization, you need to prepare a startup script. The method of compiling this script is the same as that of compiling a shell script. The startup script is used to:</p>
<ul id="cce_bestpractice_0007__ul108719233164"><li id="cce_bestpractice_0007__li17871723131610">Start up the software on which the application depends.</li><li id="cce_bestpractice_0007__li66702333163">Set the configurations that need to be changed as the environment variables.</li></ul>
<div class="note" id="cce_bestpractice_0007__note1175919268159"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="cce_bestpractice_0007__p3759226201510">Startup scripts vary according to applications. You need to compile the script based on your service requirements.</p>
</div></div>
<div class="section" id="cce_bestpractice_0007__section614193211244"><h4 class="sectiontitle">Procedure</h4><ol id="cce_bestpractice_0007__ol12691427986"><li id="cce_bestpractice_0007__li4699271588"><span>Log in as user <strong id="cce_bestpractice_0007__b437941010111">root</strong> to the device running Docker.</span></li><li id="cce_bestpractice_0007__li5541955"><span>Run the following commands to create the directory where the application is to be stored:</span><p><p id="cce_bestpractice_0007__p1543624854918"><strong id="cce_bestpractice_0007__b19359102434716">mkdir apptest</strong></p>
<p id="cce_bestpractice_0007__p164638508496"><strong id="cce_bestpractice_0007__b16360162410473">cd apptest</strong></p>
</p></li><li id="cce_bestpractice_0007__li12314175319811"><a name="cce_bestpractice_0007__li12314175319811"></a><a name="li12314175319811"></a><span>Compile a script file. The name and content of the script file vary according to applications. You need to compile the script file based on your application. The following example is only for your reference. </span><p><div class="p" id="cce_bestpractice_0007__p1356504517243"><strong id="cce_bestpractice_0007__b66258351139">vi </strong><strong id="cce_bestpractice_0007__b1626123514132">start_tomcat_and_mongo.sh</strong><pre class="screen" id="cce_bestpractice_0007__screen1620995616122">#!/bin/bash
# Load system environment variables.
source /etc/profile
# Start MongoDB. The data is stored in <strong id="cce_bestpractice_0007__b144241927145017">/usr/local/mongodb/data</strong>.
./usr/local/mongodb/bin/mongod --dbpath=<strong id="cce_bestpractice_0007__b32821271555">/usr/local/mongodb/data</strong> --logpath=/usr/local/mongodb/logs --port=27017 fork
# These three script commands indicate that the contents related to the MySQL database in the environment variables are written into the configuration file when Docker is started.
sed -i "s|mysql://.*/awcp_crmtile|mysql://$<strong id="cce_bestpractice_0007__b11772153512546">MYSQL_URL/$MYSQL_DB</strong>|g" /root/apache-tomcat-7.0.82/webapps/awcp/WEB-INF/classes/conf/jdbc.properties
sed -i "s|username=.*|username=$<strong id="cce_bestpractice_0007__b19591183905414">MYSQL_USER</strong>|g" /root/apache-tomcat-7.0.82/webapps/awcp/WEB-INF/classes/conf/jdbc.properties
sed -i "s|password=.*|password=$<strong id="cce_bestpractice_0007__b91944414548">MYSQL_PASSWORD</strong>|g" /root/apache-tomcat-7.0.82/webapps/awcp/WEB-INF/classes/conf/jdbc.properties
# Start Tomcat.
bash /root/apache-tomcat-7.0.82/bin/catalina.sh run</pre>
</div>
</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>