构建RAID

<p class="shortdesc"></p> <section class="section prereq" id="Build__prereq_qq5_5p4_tlb"><div class="tasklabel"><h2 class="doc-tairway">前提条件</h2></div> <p class="p">已经完成云硬盘的创建,并且挂载在对应的云服务器上。请参见<a class="xref" href="https://pinganyun.com/ssr/help/storage/ebs/quickstart.createdrive.separately" target="_blank">创建云硬盘</a>。</p> </section> <section class="section context" id="Build__context_ing_5p4_tlb"><div class="tasklabel"><h2 class="doc-tairway">背景信息</h2></div> <p class="p">本文以/dev/vdd、/dev/vde、/dev/vdf和/dev/vdg四块云硬盘为例说明如何创建RAID10。如下图所示,系统已经挂载了四块云硬盘,大小是20G。</p> <img class="image" id="Build__image_vym_z54_tlb" src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20200707171843-123b05199e90.png"> </section> <section id="Build__steps_bgk_1v4_tlb"><div class="tasklabel"><h2 class="doc-tairway">操作步骤</h2></div><ol class="ol steps" id="Build__steps_bgk_1v4_tlb"><li class="li step stepexpand"> <span class="ph cmd"> 以root用户登录云服务器ECS。</span> </li><li class="li step stepexpand"> <span class="ph cmd">安装mdadm工具。</span> <div class="itemgroup info"> <pre class="pre codeblock"><code>yum install mdadm -y</code></pre> <img class="image" id="Build__image_ixm_wz4_tlb" src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20200707171843-14b85d929585.png" width="800"> </div> </li><li class="li step stepexpand"> <span class="ph cmd">创建RAID阵列。</span> <div class="itemgroup info"> <pre class="pre codeblock"><code>mdadm -Cv <RAID阵列设备名> -a yes -n <磁盘数量> -l RAID<级别> <磁盘1> <磁盘2> <磁盘3>...</code></pre> <p class="p">命令示例</p> <pre class="pre codeblock"><code>mdadm -Cv /dev/md0 -a yes -n 4 -l 10 /dev/vdd /dev/vde /dev/vdf /dev/vdg</code></pre> <img class="image" id="Build__image_y2g_b1p_tlb" src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20200707171843-1d585858998d.png" width="800"> </div> </li><li class="li step stepexpand"> <span class="ph cmd">格式化RAID阵列。</span> <div class="itemgroup info"> <pre class="pre codeblock"><code>mkfs.<文件格式><RAID阵列设备名></code></pre> <p class="p">命令示例</p> <pre class="pre codeblock"><code>mkfs.ext4 /dev/md0</code></pre> <img class="image" id="Build__image_kgh_qbp_tlb" src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20200707171843-1996d51a97f3.png" width="800"> </div> </li><li class="li step stepexpand"> <span class="ph cmd">创建挂载目录。</span> <div class="itemgroup info"> <pre class="pre codeblock"><code>mkdir <挂载目录></code></pre> <p class="p">命令示例</p> <pre class="pre codeblock"><code>mkdir /RAID10</code></pre> </div> </li><li class="li step stepexpand"> <span class="ph cmd">挂载RAID阵列设备名。</span> <div class="itemgroup info"> <pre class="pre codeblock"><code>mount <RAID阵列设备名> <挂载目录></code></pre> <p class="p">命令示例</p> <pre class="pre codeblock"><code>mount /dev/md0 /RAID10</code></pre> </div> </li><li class="li step stepexpand"> <span class="ph cmd">查看RAID阵列的挂载结果。</span> <div class="itemgroup info"> <pre class="pre codeblock"><code>df -h</code></pre> <img class="image" id="Build__image_c4n_sbp_tlb" src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20200707171844-1d325a85971d.png" width="800"> </div> </li><li class="li step stepexpand"> <span class="ph cmd">云服务器系统启动时自动挂载RAID阵列。</span> <div class="itemgroup info"> <ol class="ol" type="a" id="Build__ol_skl_z1p_tlb"> <li class="li">执行<code class="ph codeph">vi /etc/fstab</code>命令,打开/etc/fstab。</li> <li class="li">输入<code class="ph codeph">i</code>,进入编辑模式。</li> <li class="li">在后面增加一行,输入<code class="ph codeph">dev/md0 /RAID10 ext4 defaults 0 0</code>。<img class="image" id="Build__image_lyk_tbp_tlb" src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20200707171844-193e232d9549.png" width="800"></li> <li class="li"> 完成后,按“Esc”键,输入<code class="ph codeph">:wq</code>,保存退出文件。</li> </ol> </div> </li><li class="li step stepexpand"> <span class="ph cmd">查看磁盘阵列信息。</span> <div class="itemgroup info"> <pre class="pre codeblock"><code>mdadm <RAID阵列设备名></code></pre> <p class="p">命令示例</p> <pre class="pre codeblock"><code>mdadm -D /dev/md0</code></pre> <img class="image" id="Build__image_tbd_xbp_tlb" src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20200707171844-178df2a09153.png" width="800"> </div> </li></ol></section>
以上内容是否解决了您的问题?
请补全提交信息!
咨询·建议

电话咨询

400-151-8800

邮件咨询

cloud@pingan.com

在线客服

工单支持

解决云产品相关技术问题