-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fab4bce
commit cfe7629
Showing
21 changed files
with
353 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
source/gluster/deploy/centos/add_centos7_gluster11_server/gluster_volume_rebalance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# 对名为 backup GlusterFS卷进行数据平衡分布 | ||
gluster volume reblance backup startup |
142 changes: 142 additions & 0 deletions
142
source/gluster/deploy/centos/deploy_centos7_gluster11_lvm_mdadm_raid6.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
.. _deploy_centos7_gluster11_lvm_mdadm_raid6: | ||
|
||
======================================== | ||
在软RAID6+LVM上CentOS 7 部署Gluster 11 | ||
======================================== | ||
|
||
.. note:: | ||
|
||
根据 :ref:`deploy_centos7_gluster11` 迭代改进部署方案 | ||
|
||
准备工作 | ||
=========== | ||
|
||
- :ref:`build_glusterfs_11_for_centos_7` | ||
- :ref:`gluster11_rpm_createrepo` | ||
|
||
安装和启动服务 | ||
=============== | ||
|
||
- 安装方法同 :ref:`deploy_centos7_gluster6` : | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/yum_install_glusterfs-server | ||
:caption: 在CentOS上安装GlusterFS | ||
|
||
输出显示将安装如下软件包: | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/yum_install_glusterfs-server_output | ||
:caption: 在CentOS上安装GlusterFS输出信息 | ||
|
||
- 启动GlusterFS管理服务: | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/systemctl_enable_glusterd | ||
:caption: 启动和激活GlusterFS管理服务 | ||
|
||
- 检查 ``glusterd`` 服务状态: | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/systemctl_status_glusterd | ||
:caption: 检查GlusterFS管理服务 | ||
|
||
输出显示服务运行正常: | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/systemctl_status_glusterd_output | ||
:caption: 检查GlusterFS管理服务显示运行正常 | ||
|
||
- 在所有需要的CentOS 7.2服务器节点都安装好上述 ``gluster-server`` 软件包( 使用 :ref:`pssh` ): | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/pssh_install_glusterfs-server | ||
:caption: 使用 :ref:`pssh` 批量安装 glusterfs-server | ||
|
||
如果简单ssh执行通过如下方式完成: | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/ssh_install_glusterfs-server | ||
:caption: 简单使用 :ref:`ssh` 顺序循环安装 glusterfs-server | ||
|
||
配置服务 | ||
========== | ||
|
||
- CentOS 7 默认启用了防火墙(视具体部署),确保服务器打开正确通讯端口: | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/centos7_open_ports_glusterfs | ||
:caption: 为GlusterFS打开CentOS防火墙端口 | ||
|
||
.. note:: | ||
|
||
- 在采用分布式卷的配置时,需要确保 ``brick`` 数量是 ``replica`` 数量的整数倍。举例,配置 ``replica 3`` ,则对应 ``bricks`` 必须是 ``3`` / ``6`` / ``9`` 依次类推 | ||
- 部署案例中,采用了 ``6`` 台服务器,每个服务器 ``12`` 块NVME磁盘: ``12*6`` (3的整数倍) | ||
|
||
- 配置gluster配对 **只需要在一台服务器上执行一次** : | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/gluster_peer_probe | ||
:language: bash | ||
:caption: 在 **一台** 服务器上 **执行一次** ``gluster peer probe`` | ||
|
||
- 完成后检查 ``gluster peer`` 状态: | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/gluster_peer_status | ||
:caption: 在 **一台** 服务器上执行 ``gluster peer status`` 检查peer是否创建并连接成功 | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/gluster_peer_status_output | ||
:caption: ``gluster peer status`` 输出显示 ``peer`` 是 ``Connected`` 状态则表明构建成功 | ||
:emphasize-lines: 5 | ||
|
||
创建GlusterFS卷 | ||
================== | ||
|
||
- 创建一个简单的脚本 ``create_gluster`` ,方便构建 ``replica 3`` 的分布式卷: | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/create_gluster | ||
:language: bash | ||
:caption: ``create_gluster`` 脚本,传递卷名作为参数就可以创建 ``replica 3`` 的分布式卷 | ||
|
||
.. note:: | ||
|
||
当 ``brick`` 数量是 ``replica`` 的整数倍(2倍或更多倍)时, :ref:`distributed_replicated_glusterfs_volume` 自动创建,能够同时获得高可用和高性能。但是对 ``brick`` 的排列有要求: 先 ``replica`` 后 ``distribute`` 。 | ||
|
||
所以为了能将数据分布到不同服务器上,我这里采用了特定的排列顺序: ``A:0,B:0,C:0,A:1,B:1,C:1,A:2,B2,C2...`` 以便让 ``replicas 3`` 能够精确分布到不同服务器上。 | ||
|
||
这种部署方式有利有弊: :ref:`best_practices_for_gluster` 我会详细探讨 | ||
|
||
- 将脚本加上执行权限:: | ||
|
||
chmod 755 create_gluster | ||
|
||
- 创建卷,举例是 ``backup`` : | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/create_gluster_backup_vol | ||
:language: bash | ||
:caption: ``create_gluster`` 脚本创建 ``backup`` 三副本分布式卷 | ||
|
||
- 如果创建卷错误,通过以下方式删除: | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/delete_gluster_backup_vol | ||
:language: bash | ||
:caption: 删除 ``backup`` 卷 | ||
|
||
.. note:: | ||
|
||
这里在执行 ``gluster volume`` 的 ``stop`` 和 ``delete`` 命令时,都添加了参数 ``--mode=script`` 是为了避免交互,方便脚本命令执行。日常运维则可以不用这个参数,方便交互确认。 | ||
|
||
- 完成后检查卷状态: | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/gluster_volume_status | ||
:language: bash | ||
:caption: 检查 ``backup`` 卷状态 | ||
|
||
挂载gluster卷 | ||
==================== | ||
|
||
- 在客户端服务器只需要安装 ``gluster-fuse`` 软件包: | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/install_gluster-fuse | ||
:caption: 安装GlusterFS客户端 ``gluster-fuse`` | ||
|
||
- 修改 ``/etc/fstab`` 添加如下内容: | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/gluster_fuse_fstab | ||
:caption: GlusterFS客户端的 ``/etc/fstab`` | ||
|
||
- 挂载存储卷: | ||
|
||
.. literalinclude:: deploy_centos7_gluster11/mount_gluster | ||
:caption: 挂载GlusterFS卷 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.. _lvmraid: | ||
|
||
========================= | ||
LVM RAID( ``lvmraid`` ) | ||
========================= | ||
|
||
参考 | ||
========= | ||
|
||
- `Configure RAID Logical Volumes on Oracle Linux <https://docs.oracle.com/en/learn/ol-lvmraid/>`_ | ||
- `Create RAID with LVM <https://blog.programster.org/create-raid-with-lvm>`_ | ||
- `Raid1 with LVM from scratch <https://wiki.gentoo.org/wiki/Raid1_with_LVM_from_scratch>`_ | ||
- `How to Create a RAID 5 System With LVM Tool and Recover Data After Failures <https://hetmanrecovery.com/recovery_news/how-to-create-software-raid-5-with-lvm.htm>`_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
.. _lvmraid_vs_mdadm: | ||
|
||
==================== | ||
lvmraid vs. mdadm | ||
==================== | ||
|
||
我在改进 :ref:`gluster_underlay_filesystem` ,对原有 :ref:`deploy_centos7_gluster11` 改进为 LVM on Software RAID,以实现清晰的GlusterFS ``brick`` ,支持GlusterFS的Scale out。 | ||
|
||
这里有一个 :ref:`linux_software_raid` 方案的选择问题: 究竟应该直接选择 :ref:`lvmraid` 来完成一个软件层包含RAID+LVM ,还是采用 :ref:`mdadm` 构建稳定的 :ref:`linux_software_raid` 再在其上构建LVM ? | ||
|
||
一句话概括 | ||
============= | ||
|
||
- :ref:`lvmraid` 是近年来逐渐在 :ref:`linux_lvm` 完善的新功能(特别是RAID5/6),RAID功能没有 ``mdadm`` 这样经历过长期的生产验证,并且也有反馈性能较差。 | ||
- :ref:`arch_linux` 社区文档同时提供了 :ref:`lvmraid` 以及 `archlinux: LVM on software RAID <https://wiki.archlinux.org/title/LVM_on_software_RAID>`_ 文档,采用 :ref:`mdadm` 实现软RAID方案更为常见 | ||
|
||
.. note:: | ||
|
||
我在生产环境采用 :ref:`mdadm` 构建稳定的 :ref:`mdadm_raid6` ,然后在软RAID之上使用 :ref:`linux_lvm` 构建卷管理,最终部署 :ref:`deploy_centos7_gluster11_lvm_mdadm_raid6` | ||
|
||
个人的实验室环境,我将模拟测试 :ref:`lvmraid` 进行对比和学习 | ||
|
||
LVM和mdadm差异 | ||
================ | ||
|
||
LVM和 :ref:`mdadm` 都是操作系统级别提供的存储管理软件: | ||
|
||
- LVM是磁盘控制器和操作系统之间的抽象层: 将多个磁盘空间合并为一个卷,然后划分为多个逻辑磁盘 | ||
- LVM可以提供动态添加磁盘容量功能,但是LVM自身不提供任何数据冗余 | ||
|
||
- LVM使用DM (Device Mapper)驱动程序来实现RAID, | ||
- LVM也支持绕过DM来创建RAID,但是通常性能较差 | ||
- 虽然LVM通过 :ref:`striped_lvm` 可以实现类似 ``RAID 0`` 的条代化性能优化(数据直接分发到多个磁盘),但是也带来了限制: 不得不使用正在使用磁盘数量的倍数来扩展磁盘,并且添加新磁盘组是,条代化不会同时在所有磁盘上进行,而是在每个磁盘组内部进行 | ||
- 不过 :ref:`lvmraid` 提供了统一的命令行接口,使用较为方便 | ||
|
||
- :ref:`mdadm` 主要就是提供冗余,直接和磁盘通信并且在物理层面上在磁盘之间分发数据 | ||
|
||
- 多个磁盘组成 :ref:`mdadm` RAID阵列在操作系统中显示为单独的磁盘驱动器 | ||
- 可以按照常规磁盘驱动器相同方式进行操作 | ||
- ``mdadm`` 在内核级别添加了RAID支持(而LVM是使用MD驱动程序来处理磁盘) | ||
- :ref:`mdadm` 构建的软RAID具有最高的性能,因为它们没有任何其他驱动程序和实用程序形式的“中间人”来向驱动器发送命令 | ||
- 通常应该使用 ``mdadm`` 来构建软件RAID,更快,更可靠 | ||
|
||
结合LVM和mdadm | ||
================= | ||
|
||
.. figure:: ../../../_static/linux/storage/lvm/mdadm-lvm.webp | ||
|
||
推荐方案是采用 ``LVM on software RAID`` : | ||
|
||
- 物理磁盘首先通过 :ref:`mdadm` 构建出 :ref:`linux_software_raid` | ||
- 在软RAID之上,采用 :ref:`linux_lvm` 实现逻辑卷的划分和调整,可以充分使用磁盘空间并实现quota | ||
|
||
参考 | ||
======= | ||
|
||
- `Comparison and difference between RAID lvm and mdadm <https://recoverhdd.com/blog/comparison-and-difference-between-raid-lvm-and-mdadm.html>`_ | ||
- `LVM vs mdadm software raid <https://www.reddit.com/r/linuxadmin/comments/fhoinz/lvm_vs_mdadm_software_raid/>`_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.. _linux_software_raid: | ||
|
||
================================= | ||
Linux 软RAID | ||
================================= | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
linux_software_raid_arch.rst | ||
mdadm.rst | ||
mdadm_raid6.rst | ||
|
||
.. only:: subproject and html | ||
|
||
Indices | ||
======= | ||
|
||
* :ref:`genindex` |
11 changes: 11 additions & 0 deletions
11
source/linux/storage/software_raid/linux_software_raid_arch.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.. _linux_software_raid_arch: | ||
|
||
======================= | ||
Linux软RAID架构 | ||
======================= | ||
|
||
参考 | ||
====== | ||
|
||
- `Red Hat Enterprise Linux 9 Docs > Managing storage devices > Chapter 18. Managing RAID <https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/managing_storage_devices/managing-raid_managing-storage-devices>`_ | ||
- `Red Hat Enterprise Linux 9 Docs > 管理存储设备 > 第18章 管理RAID <https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/9/html/managing_storage_devices/managing-raid_managing-storage-devices>`_ (中文版) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.. _mdadm: | ||
|
||
======================== | ||
mdadm 软RAID构建 | ||
======================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. _mdadm_raid6: | ||
|
||
===================== | ||
mdadm构建RAID6 | ||
===================== | ||
|
||
参考 | ||
====== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.. _mysql_query: | ||
|
||
================================= | ||
MySQL 查询 | ||
================================= | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
mysql_query_date_time.rst | ||
|
||
.. only:: subproject and html | ||
|
||
Indices | ||
======= | ||
|
||
* :ref:`genindex` |
Oops, something went wrong.