Red Hat Training

A Red Hat training course is available for Red Hat Ceph Storage

附录 B. 手动安装 Red Hat Ceph Storage

重要

红帽不支持或测试手动部署的集群的升级。因此,红帽建议使用 Ansible 来使用 Red Hat Ceph Storage 3 部署新集群。详情请查看 第 3 章 部署 Red Hat Ceph Storage

您可以使用命令行实用程序(如 Yum)来安装手动部署的集群。

所有 Ceph 集群需要至少一个 monitor,并且至少与集群中存储的对象副本数量相同。红帽建议在生产环境中使用三个监视器,至少三个对象存储设备 (OSD)。

使用命令行界面安装 Ceph 存储集群涉及以下步骤:

B.1. 先决条件

为 Red Hat Ceph Storage 配置网络时间协议

所有 Ceph 监控器和 OSD 节点都需要配置网络时间协议(NTP)。确保 Ceph 节点是 NTP 对等节点。NTP 有助于抢占时钟偏移所带来的问题。

注意

在使用 Ansible 部署 Red Hat Ceph Storage 集群时,Ansible 会自动安装、配置和启用 NTP。

先决条件
  • 网络访问有效时间源.
步骤: 为 RHCS 配置网络时间协议

root 用户身份,在存储集群中的所有 RHCS 节点上执行以下步骤。

  1. 安装 ntp 软件包:

    # yum install ntp
  2. 启动并确定 NTP 服务在重启后可以保持启动状态:

    # systemctl start ntpd
    # systemctl enable ntpd
  3. 确保 NTP 正确同步时钟:

    $ ntpq -p
其它资源

监控 Bootstrapping

引导 monitor 和扩展 Ceph 存储集群需要以下数据:

唯一标识符
文件系统标识符(fsid)是集群的唯一标识符。fsid 最初在 Ceph 存储集群主要用于 Ceph 文件系统时使用。Ceph 现在也支持原生接口、块设备和对象存储网关接口,因此 fsid 可能会有一些问题。
集群名称

Ceph 集群具有集群名称,这是不含空格的简单字符串。默认集群名称为 ceph,但您可以指定不同的集群名称。当您使用多个集群时,覆盖默认集群名称特别有用。

当您在多站点架构中运行多个集群时,集群名称(如 us-west,us-east )标识当前命令行会话的集群。

注意

若要识别命令行界面上的集群名称,请使用集群名称指定 Ceph 配置文件,如 ceph.confus-west.confus-east.conf 等。

例如:

# ceph --cluster us-west.conf ...

Monitor 名称
集群中的每一个 Monitor 实例都有唯一的名称。在常见做法中,Ceph monitor 名称是节点名称。红帽建议每个节点一个 Ceph 监控器,而不与 Ceph 监控守护进程共同定位 Ceph OSD 守护进程。要获得较短的节点名称,请使用 hostname -s 命令。
Monitor Map

启动初始 Monitor 要求您生成 Monitor Map。Monitor map 需要:

  • 文件系统识别符(fsid)
  • 使用集群名称或 ceph 的默认集群名称
  • 至少一个主机名及其 IP 地址。
监控密钥环
Monitor 使用 secret 密钥相互通信。您必须使用 Monitor secret 密钥生成密钥环,并在引导初始 Monitor 时提供密钥环。
管理员密钥环
要使用 ceph 命令行界面实用程序,请创建 client.admin 用户并生成其密钥环。此外,您必须将 client.admin 用户添加到 monitor 密钥环中。

强制要求不表示创建 Ceph 配置文件。但是,作为一种最佳实践,红帽建议创建一个 Ceph 配置文件并使用 fsid 填充它的数据,mon initial membersmon host 是最小设置。

您还可以在运行时获取和设置所有 Monitor 设置。但是,Ceph 配置文件可能仅包含覆盖默认值的设置。当您向 Ceph 配置文件添加设置时,这些设置将覆盖默认设置。在 Ceph 配置文件中维护这些设置可以更加轻松地维护集群。

要引导初始 Monitor,请执行以下步骤:

  1. 启用 Red Hat Ceph Storage 3 monitor 存储库:

    [root@monitor ~]# subscription-manager repos --enable=rhel-7-server-rhceph-3-mon-els-rpms
  2. 在初始监控节点上,以 root 用户身份安装 ceph-mon 软件包:

    # yum install ceph-mon
  3. root 用户身份,在 /etc/ceph/ 目录中创建 Ceph 配置文件。默认情况下,Ceph 使用 ceph.conf,其中 ceph 反映了集群名称:

    语法

    # touch /etc/ceph/<cluster_name>.conf

    示例

    # touch /etc/ceph/ceph.conf

  4. root 用户身份,为集群生成唯一标识符,并将唯一标识符添加到 Ceph 配置文件的 [global] 部分:

    语法

    # echo "[global]" > /etc/ceph/<cluster_name>.conf
    # echo "fsid = `uuidgen`" >> /etc/ceph/<cluster_name>.conf

    示例

    # echo "[global]" > /etc/ceph/ceph.conf
    # echo "fsid = `uuidgen`" >> /etc/ceph/ceph.conf

  5. 查看当前的 Ceph 配置文件:

    $ cat /etc/ceph/ceph.conf
    [global]
    fsid = a7f64266-0894-4f1e-a635-d0aeaca0e993
  6. root 用户身份,将初始 monitor 添加到 Ceph 配置文件:

    语法

    # echo "mon initial members = <monitor_host_name>[,<monitor_host_name>]" >> /etc/ceph/<cluster_name>.conf

    示例

    # echo "mon initial members = node1" >> /etc/ceph/ceph.conf

  7. root 用户身份,将初始 monitor 的 IP 地址添加到 Ceph 配置文件:

    语法

    # echo "mon host = <ip-address>[,<ip-address>]" >> /etc/ceph/<cluster_name>.conf

    示例

    # echo "mon host = 192.168.0.120" >> /etc/ceph/ceph.conf

    注意

    要使用 IPv6 地址,请将 ms bind ipv6 选项设置为 true。详情请参阅 Red Hat Ceph Storage 3 配置指南中的 Bind 部分。

  8. root 用户身份,为集群创建密钥环并生成 monitor secret 密钥:

    语法

    # ceph-authtool --create-keyring /tmp/<cluster_name>.mon.keyring --gen-key -n mon. --cap mon '<capabilites>'

    示例

    # ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'
    creating /tmp/ceph.mon.keyring

  9. root 用户身份生成管理员密钥环,生成 <cluster_name>.client.admin.keyring 用户,并将该用户添加到密钥环中:

    语法

    # ceph-authtool --create-keyring /etc/ceph/<cluster_name>.client.admin.keyring --gen-key -n client.admin --set-uid=0 --cap mon '<capabilites>' --cap osd '<capabilites>' --cap mds '<capabilites>'

    示例

    # ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin --set-uid=0 --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow'
    creating /etc/ceph/ceph.client.admin.keyring

  10. root 用户身份,将 <cluster_name>.client.admin.keyring 密钥添加到 <cluster_name>.mon.keyring:

    语法

    # ceph-authtool /tmp/<cluster_name>.mon.keyring --import-keyring /etc/ceph/<cluster_name>.client.admin.keyring

    示例

    # ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring
    importing contents of /etc/ceph/ceph.client.admin.keyring into /tmp/ceph.mon.keyring

  11. 生成 Monitor map。使用初始 monitor 的节点名称、IP 地址和 fsid 指定,并将其保存为 /tmp/monmap

    语法

    $ monmaptool --create --add <monitor_host_name> <ip-address> --fsid <uuid> /tmp/monmap

    示例

    $ monmaptool --create --add node1 192.168.0.120 --fsid a7f64266-0894-4f1e-a635-d0aeaca0e993 /tmp/monmap
    monmaptool: monmap file /tmp/monmap
    monmaptool: set fsid to a7f64266-0894-4f1e-a635-d0aeaca0e993
    monmaptool: writing epoch 0 to /tmp/monmap (1 monitors)

  12. 作为初始监控节点上的 root 用户,创建一个默认数据目录:

    语法

    # mkdir /var/lib/ceph/mon/<cluster_name>-<monitor_host_name>

    示例

    # mkdir /var/lib/ceph/mon/ceph-node1

  13. root 用户身份,使用 monitor 映射和密钥环填充初始 monitor 守护进程:

    语法

    # ceph-mon [--cluster <cluster_name>] --mkfs -i <monitor_host_name> --monmap /tmp/monmap --keyring /tmp/<cluster_name>.mon.keyring

    示例

    # ceph-mon --mkfs -i node1 --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring
    ceph-mon: set fsid to a7f64266-0894-4f1e-a635-d0aeaca0e993
    ceph-mon: created monfs at /var/lib/ceph/mon/ceph-node1 for mon.node1

  14. 查看当前的 Ceph 配置文件:

    # cat /etc/ceph/ceph.conf
    [global]
    fsid = a7f64266-0894-4f1e-a635-d0aeaca0e993
    mon_initial_members = node1
    mon_host = 192.168.0.120

    有关各种 Ceph 配置设置的更多详细信息,请参见 Red Hat Ceph Storage 3 配置指南 。以下 Ceph 配置文件示例列出了一些最常见的配置设置:

    示例

    [global]
    fsid = <cluster-id>
    mon initial members = <monitor_host_name>[, <monitor_host_name>]
    mon host = <ip-address>[, <ip-address>]
    public network = <network>[, <network>]
    cluster network = <network>[, <network>]
    auth cluster required = cephx
    auth service required = cephx
    auth client required = cephx
    osd journal size = <n>
    osd pool default size = <n>  # Write an object n times.
    osd pool default min size = <n> # Allow writing n copy in a degraded state.
    osd pool default pg num = <n>
    osd pool default pgp num = <n>
    osd crush chooseleaf type = <n>

  15. root 用户身份,创建 done 文件:

    语法

    # touch /var/lib/ceph/mon/<cluster_name>-<monitor_host_name>/done

    示例

    # touch /var/lib/ceph/mon/ceph-node1/done

  16. root 用户身份,更新新创建的目录和文件的所有者和组权限:

    语法

    # chown -R <owner>:<group> <path_to_directory>

    示例

    # chown -R ceph:ceph /var/lib/ceph/mon
    # chown -R ceph:ceph /var/log/ceph
    # chown -R ceph:ceph /var/run/ceph
    # chown ceph:ceph /etc/ceph/ceph.client.admin.keyring
    # chown ceph:ceph /etc/ceph/ceph.conf
    # chown ceph:ceph /etc/ceph/rbdmap

    注意

    如果 Ceph 监控节点与 OpenStack 控制器节点在一起,则 Glance 和 Cinder 密钥环文件必须分别归 glancecinder 所有。例如:

    # ls -l /etc/ceph/
    ...
    -rw-------.  1 glance glance      64 <date> ceph.client.glance.keyring
    -rw-------.  1 cinder cinder      64 <date> ceph.client.cinder.keyring
    ...
  17. 对于带有自定义名称的存储集群,以 root 用户身份添加以下行:

    语法

    # echo "CLUSTER=<custom_cluster_name>" >> /etc/sysconfig/ceph

    示例

    # echo "CLUSTER=test123" >> /etc/sysconfig/ceph

  18. root 用户身份,在初始监控节点上启动并启用 ceph-mon 进程:

    语法

    # systemctl enable ceph-mon.target
    # systemctl enable ceph-mon@<monitor_host_name>
    # systemctl start ceph-mon@<monitor_host_name>

    示例

    # systemctl enable ceph-mon.target
    # systemctl enable ceph-mon@node1
    # systemctl start ceph-mon@node1

  19. root 用户身份,验证 monitor 守护进程是否正在运行:

    语法

    # systemctl status ceph-mon@<monitor_host_name>

    示例

    # systemctl status ceph-mon@node1
    ● ceph-mon@node1.service - Ceph cluster monitor daemon
       Loaded: loaded (/usr/lib/systemd/system/ceph-mon@.service; enabled; vendor preset: disabled)
       Active: active (running) since Wed 2018-06-27 11:31:30 PDT; 5min ago
     Main PID: 1017 (ceph-mon)
       CGroup: /system.slice/system-ceph\x2dmon.slice/ceph-mon@node1.service
               └─1017 /usr/bin/ceph-mon -f --cluster ceph --id node1 --setuser ceph --setgroup ceph
    
    Jun 27 11:31:30 node1 systemd[1]: Started Ceph cluster monitor daemon.
    Jun 27 11:31:30 node1 systemd[1]: Starting Ceph cluster monitor daemon...

要将更多 Red Hat Ceph Storage Monitor 添加到存储集群中,请参阅 Red Hat Ceph Storage 3 管理指南中的添加 Monitor 部分。