Files
doc-exports/docs/cce/umn/cce_qs_0004.html
qiujiandong1 71d5c814e7 CCE UMN 20250311 version
Reviewed-by: Eotvos, Oliver <oliver.eotvos@t-systems.com>
Co-authored-by: qiujiandong1 <qiujiandong1@huawei.com>
Co-committed-by: qiujiandong1 <qiujiandong1@huawei.com>
2025-06-16 14:58:53 +00:00

32 lines
9.3 KiB
HTML

<a name="cce_qs_0004"></a><a name="cce_qs_0004"></a>
<h1 class="topictitle1">Step 1: Deploying MySQL</h1>
<div id="body1523431192560"><p id="cce_qs_0004__p11835182117249">WordPress must be used together with MySQL. WordPress runs the content management program while MySQL serves as a database to store data.</p>
<div class="section" id="cce_qs_0004__section1949252765716"><h4 class="sectiontitle">Prerequisites</h4><p id="cce_qs_0004__p169822101212">You have created a CCE cluster that contains a node with 4 vCPUs and 8 GiB memory. For details on how to create a cluster, see <a href="cce_qs_0008.html">Creating a Kubernetes Cluster</a>.</p>
</div>
<div class="section" id="cce_qs_0004__section13528183612816"><h4 class="sectiontitle">Operations on the Console</h4><ol id="cce_qs_0004__ol162711945486"><li id="cce_qs_0004__li2525844162213"><span>Log in to the CCE console.</span></li><li id="cce_qs_0004__li482679122317"><span>Click the name of the target cluster to access the cluster console.</span></li><li id="cce_qs_0004__li1885962692419"><span>In the navigation pane, choose <strong id="cce_qs_0004__b193563154917">Workloads</strong>. Then, click <strong id="cce_qs_0004__b093563154915">Create Workload</strong> in the upper right corner.</span></li><li id="cce_qs_0004__li182796474816"><span>Configure the basic information about the workload.</span><p><ul id="cce_qs_0004__ul17871352121219"><li id="cce_qs_0004__li8870175211213"><strong id="cce_qs_0004__b5433057153316">Workload Type</strong>: Select <strong id="cce_qs_0004__b2434145733313">StatefulSet</strong>.</li><li id="cce_qs_0004__li687025231210"><strong id="cce_qs_0004__b124941359153315">Workload Name</strong>: Set it to <strong id="cce_qs_0004__b549445973313">mysql</strong>.</li><li id="cce_qs_0004__li38711352101218"><strong id="cce_qs_0004__b2791449348">Namespace</strong>: Select <strong id="cce_qs_0004__b207911463411">default</strong>.</li><li id="cce_qs_0004__li987185216128"><strong id="cce_qs_0004__b11281153410212">Pods</strong>: In this example, change the quantity to 1, which means, there is only one pod running in the <strong id="cce_qs_0004__b97321821192217">mysql</strong> workload.</li></ul>
</p></li><li id="cce_qs_0004__li62088814718"><span>Configure the basic information about the container.</span><p><p id="cce_qs_0004__p142359834711">Enter <strong id="cce_qs_0004__b1779495984519">mysql:5.7</strong> in the <strong id="cce_qs_0004__b9794115916453">Image Name</strong> text box.</p>
</p></li><li id="cce_qs_0004__li104211323164813"><span>Click <span class="uicontrol" id="cce_qs_0004__uicontrol165921449152515"><b>Environment Variables</b></span> and add four environment variables. You can check <a href="https://github.com/docker-library/docs/tree/master/mysql" target="_blank" rel="noopener noreferrer">MySQL</a> to view the environment variables that can be configured.</span><p><ul id="cce_qs_0004__ul1426523144815"><li id="cce_qs_0004__li154261023194818"><strong id="cce_qs_0004__b2447143922620">MYSQL_ROOT_PASSWORD</strong>: password of the <strong id="cce_qs_0004__b19106843192618">root</strong> user of the MySQL database, which can be customized.</li><li id="cce_qs_0004__li9426523174811"><strong id="cce_qs_0004__b109815292611">MYSQL_DATABASE</strong>: name of the database to be created when the image is started, which can be customized.</li><li id="cce_qs_0004__li742632344818"><strong id="cce_qs_0004__b181801533274">MYSQL_USER</strong>: database user name, which can be customized.</li><li id="cce_qs_0004__li17426112314817"><strong id="cce_qs_0004__b51683811276">MYSQL_PASSWORD</strong>: database user password, which can be customized.</li></ul>
</p></li><li id="cce_qs_0004__li11730183918541"><span>Click <span class="uicontrol" id="cce_qs_0004__uicontrol148771722715"><b>Lifecycle</b></span> and configure <span class="uicontrol" id="cce_qs_0004__uicontrol2861017152713"><b>Startup Command</b></span>.</span><p><ul id="cce_qs_0004__ul37606582550"><li id="cce_qs_0004__li1760175816558">Command:<pre class="screen" id="cce_qs_0004__screen18998141919567">/bin/bash</pre>
</li><li id="cce_qs_0004__li1081911325612">Running parameters:<pre class="screen" id="cce_qs_0004__screen1514632645616">-c
rm -rf /var/lib/mysql/lost+found;docker-entrypoint.sh mysqld;</pre>
</li></ul>
</p></li><li id="cce_qs_0004__li65841249184118"><span>Click <strong id="cce_qs_0004__b132921610325">Data Storage</strong>, click <strong id="cce_qs_0004__b910825772612">Add Volume</strong>, select <strong id="cce_qs_0004__b169581940172618">VolumeClaimTemplate (VTC)</strong> from the drop-down list, and add an EVS disk for MySQL.</span><p><p id="cce_qs_0004__p16928209521">Click <strong id="cce_qs_0004__b5974133102815">Create PVC</strong> and configure the following parameters (Keep default for other parameters):</p>
<ul id="cce_qs_0004__ul11781435315"><li id="cce_qs_0004__li71711147533"><strong id="cce_qs_0004__b57719314294">PVC Type</strong>: Select <strong id="cce_qs_0004__b137601147297">EVS</strong>.</li><li id="cce_qs_0004__li17239172516534"><strong id="cce_qs_0004__b187061696293">PVC Name</strong>: Enter a name, for example, <strong id="cce_qs_0004__b9248748132311">mysql</strong>.</li><li id="cce_qs_0004__li9173103015315"><strong id="cce_qs_0004__b3815209290">Creation Mode</strong>: Only <strong id="cce_qs_0004__b78911332102917">Dynamically provision</strong> is supported.</li><li id="cce_qs_0004__li96917365544"><strong id="cce_qs_0004__b1670935452912">Storage Classes</strong>: The default value is <strong id="cce_qs_0004__b173191152132910">csi-disk</strong>.</li><li id="cce_qs_0004__li18773451135420"><strong id="cce_qs_0004__b1353659152913">AZ</strong>: Select an AZ. The EVS disk can only be attached to nodes in the same AZ. After an EVS disk is created, the AZ where the disk locates cannot be changed.</li><li id="cce_qs_0004__li15284202518553"><strong id="cce_qs_0004__b395933610306">Disk Type</strong>: Select a proper type as required.</li><li id="cce_qs_0004__li14274756185520"><strong id="cce_qs_0004__b536115214302">Capacity (GiB)</strong>: Enter the capacity as required. The default value is <strong id="cce_qs_0004__b89591401311">10</strong> GiB.</li></ul>
<p id="cce_qs_0004__p17303172834611">Click <strong id="cce_qs_0004__b198492623118">Create</strong> and enter the path for mounting the storage volume to the container. The default path used by MySQL is <span class="filepath" id="cce_qs_0004__filepath1891814125117"><b>/var/lib/mysql</b></span>.</p>
</p></li><li id="cce_qs_0004__li128646101544"><span>In the <strong id="cce_qs_0004__b819692063219">Headless Service Parameters</strong> area, configure a headless Service.</span><p><p id="cce_qs_0004__p14693442847">A headless Service needs to be configured for networking between StatefulSet pods. It generates a domain name for each pod to access a specific StatefulSet pod. For a MySQL database that has master/slave relationship and multiple replicas, a headless Service is needed to read and write data from and into one MySQL database server (known as a source) and copy the data to other replicas. In this example, there is only one pod running in the MySQL workload. Therefore, the headless Service is not used. In this case, enter <strong id="cce_qs_0004__b126771120134415">3306</strong> for both the Service port and container port. For details about the replicated MySQL examples, see <a href="https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/" target="_blank" rel="noopener noreferrer">Run a Replicated Stateful Application</a>.</p>
</p></li><li id="cce_qs_0004__li8470111712489"><span>In the <span class="uicontrol" id="cce_qs_0004__uicontrol1050857135219"><b>Service Settings</b></span> area, click the plus sign (+) and create a Service for accessing MySQL from WordPress.</span><p><p id="cce_qs_0004__p1648641704815">Select <strong id="cce_qs_0004__b1743094331611">ClusterIP</strong> for <strong id="cce_qs_0004__b184301843111612">Service Type</strong>, enter <strong id="cce_qs_0004__b18430194315163">mysql</strong>in the <strong id="cce_qs_0004__b343114341620">Service Name</strong> text box, set both the <strong id="cce_qs_0004__b343119439160">Container Port</strong> and <strong id="cce_qs_0004__b24318436167">Service Port</strong> to <strong id="cce_qs_0004__b16431194331616">3306</strong>, and click <strong id="cce_qs_0004__b20431194320165">OK</strong>.</p>
<p id="cce_qs_0004__p1748611734813">The default access port in the MySQL image is 3306. In this example, both the container port and Service port are set to <strong id="cce_qs_0004__b15396171317116">3306</strong> for convenience. The access port can be changed to another port.</p>
<p id="cce_qs_0004__p3486101764817">In this way, the MySQL workload can be accessed through <em id="cce_qs_0004__i109201132479">{Service name}:{Access port}</em>, for example, <strong id="cce_qs_0004__b1792031311472">mysql:3306</strong>, from within the cluster.</p>
</p></li><li id="cce_qs_0004__li151183363920"><span>Click <strong id="cce_qs_0004__b713842927">Create Workload</strong>.</span><p><p id="cce_qs_0004__p10133182724917">Wait until the workload is created.</p>
<p id="cce_qs_0004__p4295124231313">The created workload will be displayed on the <strong id="cce_qs_0004__b4686162224716">StatefulSets</strong> tab.</p>
</p></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="cce_qs_0007.html">Deploying WordPress and MySQL That Depend on Each Other</a></div>
</div>
</div>