3.4. 设置 Ceph


对于这个 Red Hat Quay 配置,我们创建一个带有几个其他支持节点的三节点 Ceph 集群,如下所示:

  • ceph01、ceph02 和 ceph03 - Ceph Monitor、Ceph Manager 和 Ceph OSD 节点
  • ceph04 - Ceph RGW 节点
  • ceph05 - Ceph Ansible 管理节点

有关安装 Ceph 节点的详细信息,请参阅在 Red Hat Enterprise Linux 上安装 Red Hat Ceph Storage

设置 Ceph 存储集群后,创建 Ceph 对象网关(也称为 RADOS 网关)。详情请参阅安装 Ceph 对象网关

3.4.1. 安装每个 Ceph 节点

在 ceph01、ceph02、ceph03、ceph04 和 ceph05 上,执行以下操作:

  1. 查看 安装 Red Hat Ceph Storage 要求时设置 Ceph 节点的先决条件。特别是:

  2. 准备 OSD 存储(仅限 ceph01、ceph02 和 ceph03)。在三个 OSD 节点上设置 OSD 存储(ceph01、ceph02 和 ceph03)。如需了解有关稍后要进入 Ansible 配置的受支持存储类型的详细信息,请参阅 表 3.2 中的 OSD Ansible 设置。在本例中,每个 OSD 节点上都配置与操作系统独立的、未格式化的块设备(/dev/sdb)。如果您要在裸机上安装,您可能需要为机器添加额外的硬盘驱动器。
  3. 安装 Red Hat Enterprise Linux 服务器版本,如 RHEL 7 安装指南 中所述。
  4. 注册并订阅每个 Ceph 节点,如 注册 Red Hat Ceph Storage 节点 中所述。以下是如何订阅所需的仓库:

    # subscription-manager repos --disable=*
    # subscription-manager repos --enable=rhel-7-server-rpms
    # subscription-manager repos --enable=rhel-7-server-extras-rpms
    # subscription-manager repos --enable=rhel-7-server-rhceph-3-mon-rpms
    # subscription-manager repos --enable=rhel-7-server-rhceph-3-osd-rpms
    # subscription-manager repos --enable=rhel-7-server-rhceph-3-tools-rpms
  5. 在每个节点上创建一个具有 root 特权的 ansible 用户。选择您喜欢的任何名称。例如:

    # USER_NAME=ansibleadmin
    # useradd $USER_NAME -c "Ansible administrator"
    # passwd $USER_NAME
    New password: *********
    Retype new password: *********
    # cat << EOF >/etc/sudoers.d/admin
    admin ALL = (root) NOPASSWD:ALL
    EOF
    # chmod 0440 /etc/sudoers.d/$USER_NAME

3.4.2. 配置 Ceph Ansible 节点(ceph05)

登录 Ceph Ansible 节点(ceph05),并将它配置如下。您需要运行 ceph01、ceph02 和 ceph03 节点,以完成这些步骤。

  1. 在 Ansible 用户的主目录中,创建一个目录来存储从 ceph-ansible playbook 创建的临时值

    # USER_NAME=ansibleadmin
    # sudo su - $USER_NAME
    [ansibleadmin@ceph05 ~]$ mkdir ~/ceph-ansible-keys
  2. 为 ansible 用户启用无密码的 ssh。在 ceph05 上运行 ssh-keygen (将密码短语留空),然后运行 ssh-copy-id 将公钥复制到 ceph01、ceph02 和 ceph03 系统上的 Ansible 用户:

    # USER_NAME=ansibleadmin
    # sudo su - $USER_NAME
    [ansibleadmin@ceph05 ~]$ ssh-keygen
    [ansibleadmin@ceph05 ~]$ ssh-copy-id $USER_NAME@ceph01
    [ansibleadmin@ceph05 ~]$ ssh-copy-id $USER_NAME@ceph02
    [ansibleadmin@ceph05 ~]$ ssh-copy-id $USER_NAME@ceph03
    [ansibleadmin@ceph05 ~]$ exit
    #
  3. 安装 ceph-ansible 软件包:

    # yum install ceph-ansible
  4. 在这两个目录之间创建一个符号:

    # ln -s /usr/share/ceph-ansible/group_vars \
        /etc/ansible/group_vars
  5. 创建 Ceph 示例 yml 文件的副本以进行修改:

    # cd /usr/share/ceph-ansible
    # cp group_vars/all.yml.sample group_vars/all.yml
    # cp group_vars/osds.yml.sample group_vars/osds.yml
    # cp site.yml.sample site.yml
  6. 编辑复制的 group_vars/all.yml 文件。详情请参阅 表 3.1 中的常规 Ansible 设置。例如:

    ceph_origin: repository
    ceph_repository: rhcs
    ceph_repository_type: cdn
    ceph_rhcs_version: 3
    monitor_interface: eth0
    public_network: 192.168.122.0/24

    请注意,您的网络设备和地址范围可能会有所不同。

  7. 编辑复制的 group_vars/osds.yml 文件。详情请参阅 表 3.2 中的 OSD Ansible 设置。在本例中,每个 OSD 节点上的第二个磁盘设备(/dev/sdb)用于数据和日志存储:

    osd_scenario: collocated
    devices:
      - /dev/sdb
    dmcrypt: true
    osd_auto_discovery: false
  8. 编辑 /etc/ansible/hosts 清单文件,将 Ceph 节点识别为 Ceph 节点,作为 Ceph 监视器、OSD 和管理器节点。在本例中,存储设备也会在每个节点上识别:

    [mons]
    ceph01
    ceph02
    ceph03
    
    [osds]
    ceph01 devices="[ '/dev/sdb' ]"
    ceph02 devices="[ '/dev/sdb' ]"
    ceph03 devices="[ '/dev/sdb' ]"
    
    [mgrs]
    ceph01 devices="[ '/dev/sdb' ]"
    ceph02 devices="[ '/dev/sdb' ]"
    ceph03 devices="[ '/dev/sdb' ]"
  9. 将以下行添加到 /etc/ansible/ansible.cfg 文件中,将每个 Ansible playbook 运行的输出保存到 Ansible 用户的主目录中:

    retry_files_save_path = ~/
  10. 检查 Ansible 能否访问您配置为 Ansible 用户的所有 Ceph 节点:

    # USER_NAME=ansibleadmin
    # sudo su - $USER_NAME
    [ansibleadmin@ceph05 ~]$ ansible all -m ping
    ceph01 | SUCCESS => {
        "changed": false,
        "ping": "pong"
    }
    ceph02 | SUCCESS => {
        "changed": false,
        "ping": "pong"
    }
    ceph03 | SUCCESS => {
        "changed": false,
        "ping": "pong"
    }
    [ansibleadmin@ceph05 ~]$
  11. 运行 ceph-ansible playbook (以您的 Ansible 用户身份):

    [ansibleadmin@ceph05 ~]$ cd /usr/share/ceph-ansible/
    [ansibleadmin@ceph05 ~]$ ansible-playbook site.yml

    此时,Ansible playbook 将检查您的 Ceph 节点,并为您所请求的服务配置它们。如果有任何失败,请进行必要的更正并重新运行该命令。

  12. 登录到三个 Ceph 节点之一(ceph01、ceph02 或 ceph03),并检查 Ceph 集群的健康状态:

    # ceph health
    HEALTH_OK
  13. 在同一节点上,使用 rados 验证监控是否正常工作:

    # ceph osd pool create test 8
    # echo 'Hello World!' > hello-world.txt
    # rados --pool test put hello-world hello-world.txt
    # rados --pool test get hello-world fetch.txt
    # cat fetch.txt
    Hello World!

3.4.3. 安装 Ceph 对象网关

在 Ansible 系统上(ceph05),将 Ceph 对象网关配置为 Ceph Storage 集群(最终会在 ceph04 上运行)。详情请参阅安装 Ceph 对象网关

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.