如何手动部署Ceph octopus集群

58次阅读
没有评论

共计 9971 个字符,预计需要花费 25 分钟才能阅读完成。

这篇文章主要介绍了如何手动部署 Ceph octopus 集群,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让丸趣 TV 小编带着大家一起了解一下。

  基础配置

三台环境为 centos7.9,以下配置需要在每台机器上执行

配置 hosts 解析

cat   /etc/hosts  EOF 192.168.2.16 node1 192.168.2.19 node2 192.168.2.18 node3 EOF

关闭防火墙和 selinux

systemctl stop firewalld   systemctl disable firewalld setenforce 0   sed -i  s/SELINUX=enforcing/SELINUX=disabled/g  /etc/selinux/config

分别在三个节点设置主机名

hostnamectl set-hostname node1 hostnamectl set-hostname node2 hostnamectl set-hostname node3

配置主机时间同步

systemctl restart chronyd.service   systemctl enable chronyd.service

使用 yum 安装

安装 yum-plugin-priorities

yum install yum-plugin-priorities

安装依赖包

yum install snappy leveldb gdisk python-argparse gperftools-libs epel-release

添加 ceph 仓库

建议使用阿里的源,国外的太慢了

vim /etc/yum.repos.d/ceph.repo [ceph] name=ceph baseurl=http://mirrors.aliyun.com/ceph/rpm-15.2.8/el7/x86_64/ gpgcheck=0 [ceph-noarch] name=cephnoarch baseurl=http://mirrors.aliyun.com/ceph/rpm-15.2.8/el7/noarch/ gpgcheck=0

安装 ceph

yum install ceph -y

部署 monitor 节点

所有 Ceph 群集至少需要一个 monitor,并且至少需要与存储在群集上的对象副本一样多的 OSD。引导初始 mon 是部署 Ceph   存储群集的第一步,这里我直接在 node1、node2、node3 创建三个 mon。

在 node1 添加 monitor

为集群生成唯一的 fsid,fsid 是群集的唯一标识符,代表 Ceph 存储群集主要用于 Ceph 文件系统的文件系统 ID

uuidgen

创建 ceph 配置文件,将生成的 fsid 添加到配置文件中

vim /etc/ceph/ceph.repo [global] fsid=9c079a1f-6fc2-4c59-bd4d-e8bc232d33a4

为群集创建 keyring 并生成 monitor  keyring。monitor 通过密钥相互通信。必须生成具有 monitor 密钥的 keyring,并在引导初始 monitor 时提供 keyring。

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

生成管理员 keyring,生成用户并将用户添加到 client.admin keyring 中。要使用 CLI   工具,必须有一个用户,并且还必须将用户添加到 monitor keyring。

ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin --cap mon  allow *  --cap osd  allow *  --cap mds  allow *  --cap mgr  allow *

生成引导 osd 密钥,生成用户并将用户添加到 client.bootstrap-osd keyring 中。

ceph-authtool --create-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring --gen-key -n client.bootstrap-osd --cap mon  profile bootstrap-osd  --cap mgr  allow r

将生成的键添加到 ceph.mon.keyring

ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring ceph-authtool /tmp/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring

更改 ceph.mon.keyring 的所有者。

chown ceph:ceph /tmp/ceph.mon.keyring

使用主机名、主机 IP 地址和 FSID 生成 monitor 映射。将其保存为:/tmp/monmap

monmaptool --create --add node1 192.168.2.16 --add node2 192.168.2.19 --add node3 192.168.2.18 --fsid 9c079a1f-6fc2-4c59-bd4d-e8bc232d33a4 /tmp/monmap

查看生成的 monitor 映射文件

monmaptool --print /tmp/monmap

 

在 monitor 主机上创建默认数据目录,目录名是 {cluster-name}-{hostname} 格式

mkdir /var/lib/ceph/mon/ceph-node1 chmod 777 -R /var/lib/ceph/mon/ceph-node3

在 node1 节点对 monitor 进行初始化

ceph-mon --mkfs -i node1 --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring

可以查看数据目录生成的文件

编辑 ceph 配置文件

[global] fsid = 9c079a1f-6fc2-4c59-bd4d-e8bc232d33a4 mon initial members = node1,node2,node3 mon host = 192.168.2.16,192.168.2.19,192.168.2.18 mon clock drift allowed = .5 auth cluster required = cephx auth service required = cephx auth client required = cephx osd pool default size = 3 // 创建 pool 的时候默认 pool 是 3 副本  osd pool default min size = 2 //pool 最少可写的副本数为 2  osd pool default pg num = 8 osd pool default pgp num = 8 osd crush chooseleaf type = 0

将配置文件拷贝到其他节点

scp /etc/ceph/ceph.conf node2:/etc/ceph/ceph.conf scp /etc/ceph/ceph.conf node3:/etc/ceph/ceph.conf

将 mon keyring,mon map 及 admin keyring 拷贝到其他节点

scp /tmp/ceph.mon.keyring node2:/tmp/ceph.mon.keyring scp /etc/ceph/ceph.client.admin.keyring node2:/etc/ceph/ceph.client.admin.keyring scp /tmp/monmap node2:/tmp/monmap scp /tmp/ceph.mon.keyring node3:/tmp/ceph.mon.keyring scp /etc/ceph/ceph.client.admin.keyring node3:/etc/ceph/ceph.client.admin.keyring scp /tmp/monmap node3:/tmp/monmap

在 node2、node3 上添加 monitor

分别在这两个节点创建数据目录

mkdir /var/lib/ceph/mon/ceph-node2 chmod 777 -R /var/lib/ceph/mon/ceph-node2 mkdir /var/lib/ceph/mon/ceph-node3 chmod 777 -R /var/lib/ceph/mon/ceph-node3

分别在这两个节点对 monitor 进行初始化

ceph-mon --mkfs -i node2 --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring ceph-mon --mkfs -i node3 --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring

分别在三个节点启动 ceph-mon 服务

systemctl start ceph-mon@node1   systemctl enable ceph-mon@node1 systemctl start ceph-mon@node2   systemctl enable ceph-mon@node2 systemctl start ceph-mon@node3   systemctl enable ceph-mon@node3

image.png

可以看到提示 3 monitors have not enabled msgr2

执行以下命令恢复正常

ceph mon enable-msgr2

 

image.png

创建 MGR

在运行 ceph-mon 守护程序的每个节点上,还应该设置一个 ceph-mgr 守护程序。

创建密钥目录

所有 mgr 节点都要执行

sudo -u ceph mkdir /var/lib/ceph/mgr/ceph-`hostname -s` cd /var/lib/ceph/mgr/ceph-`hostname -s`

创建身份验证密钥

ceph auth get-or-create mgr.`hostname -s` mon  allow profile mgr  osd  allow *  mds  allow *    keyring

启动 mgr 守护进程

systemctl enable ceph-mgr@`hostname -s`   systemctl start ceph-mgr@`hostname -s`

看样子状态有点异常,在所有节点执行下面的命令之后重启机器即可解决

Module restful has failed dependency: No module named pecan

pip3 install pecan werkzeug

 

image.png

部署 osd

Ceph 提供了该 ceph-volume 实用程序,该实用程序可以准备逻辑卷,磁盘或分区以供 Ceph 使用。该 ceph-volume 实用程序通过增加索引来创建 OSD  ID。

创建 osd

在 node1 执行

ceph-volume lvm create --data /dev/sdb

上面的创建过程可以分为两个阶段(准备和激活):

ceph-volume lvm prepare --data /dev/sdb  查看 osd fsid ceph-volume lvm list ceph-volume lvm activate {ID} {FSID}

当创建完 osd 之后,我们发现 osd 服务已经起来了

当我们在 node2、node3 节点执行此命令的时候报错了,发现缺少密钥文件

拷贝密钥文件

scp /var/lib/ceph/bootstrap-osd/ceph.keyring node2:/var/lib/ceph/bootstrap-osd/ceph.keyring scp /var/lib/ceph/bootstrap-osd/ceph.keyring node3:/var/lib/ceph/bootstrap-osd/ceph.keyring

修改密钥属主属组

chown ceph.ceph /var/lib/ceph/bootstrap-osd/ceph.keyring

分别在 node2、node3 创建 osd

ceph-volume lvm create --data /dev/sdb

也可以分步执行

ceph-volume lvm prepare --data /dev/sdb ##获取 osd id  和 osd fsid ceph-volume lvm list ## 激活 osd ceph-volume lvm activate {ID} {FSID}

最后状态是这样的

 

添加 MDS

创建 mds 数据目录

mkdir -p /var/lib/ceph/mds/ceph-`hostname -s` chown -R ceph.ceph /var/lib/ceph/mds/ceph-`hostname -s`

创建 keyring

ceph-authtool --create-keyring /var/lib/ceph/mds/ceph-`hostname -s`/keyring --gen-key -n mds.`hostname -s`

导入 keyring 并设置权限

ceph auth add mds.`hostname -s` osd  allow rwx  mds  allow  mon  allow profile mds  -i /var/lib/ceph/mds/ceph-`hostname -s`/keyring chown ceph:ceph /var/lib/ceph/mds/ceph-`hostname -s`/keyring

修改 ceph.conf 配置文件

cat   /etc/ceph/ceph.conf  EOF [mds.node1] host = node1 [mds.node2] host = node2 [mds.node3] host = node3 EOF

启动 mds 服务

systemctl enable ceph-mds@`hostname -s`   systemctl start ceph-mds@`hostname -s`

现在状态应该是这样的

对象存储 RGW 安装

RGW 是 Ceph 对象存储网关服务 RADOS  Gateway 的简称,是一套基于 LIBRADOS 接口封装而实现的 FastCGI 服务,对外提供 RESTful 风格的对象存储数据访问和管理接口。RGW 基于 HTTP 协议标准,因此非常适用于 Web 类的互联网应用场景,用户通过使用 SDK 或者其他客户端工具,能够很方便地接入 RGW 进行图片、视频以及各类文件的上传或下载,并设置相应的访问权限,共享给其他用户。

安装 radosgw

yum install ceph-radosgw -y

创建 rgw 相关的资源池

资源池列表及部分资源池功能介绍如下。

.rgw:region 和 zone 配置信息。

.rgw.root:region 和 zone 配置信息。

.rgw.control:存放 notify 信息。

.rgw.gc:用于资源回收。

.rgw.buckets:存放数据。

.rgw.buckets.index:存放元数据信息。

.rgw.buckets.extra:存放元数据扩展信息。

.log:日志存放。

.intent-log:日志存放。

.usage:存放用户已用容量信息。

.users:存放用户信息。

.users.email:存放用户 E -mail 信息。

.users.swift:存放 swift 类型的账号信息。

.users.uid:存放用户信息。

ceph osd pool create .rgw 8 8 ceph osd pool create .rgw.root 8 8 ceph osd pool create .rgw.control 8 8 ceph osd pool create .rgw.gc 8 8 ceph osd pool create .rgw.buckets 8 8 ceph osd pool create .rgw.buckets.index 8 8 ceph osd pool create .rgw.buckets.extra 8 8 ceph osd pool create .log 8 8 ceph osd pool create .intent-log 8 8 ceph osd pool create .usage 8 8 ceph osd pool create .users 8 8 ceph osd pool create .users.email 8 8 ceph osd pool create .users.swift 8 8 ceph osd pool create .users.uid 8 8

创建过程会遇到这个报错,原因是每个 osd 默认最多只支持 250 个 pg,这里有两种解决办法,一种是删除之前创建的 pool,并新建 pool 时把 pg 设置小一点,另一种则是修改 osd 默认最大 pg 数,这里我用了第二种,修改完配置文件后,重启 mon

Error ERANGE: pg_num 8 size 3 would mean 771 total pgs, which exceeds max 750  (mon_max_pg_per_osd 250 * num_in_osds 3)

编辑配置文件

vim /etc/ceph/ceph.conf [global] mon_max_pg_per_osd = 1000 # 重启 mon systemctl restart ceph-mon@`hostname -s`

可以使用 rados lspools 查看是否创建成功

新建 RADOSGW 用户和 keyring

创建 keyring

ceph-authtool --create-keyring /etc/ceph/ceph.client.radosgw.keyring chown ceph:ceph /etc/ceph/ceph.client.radosgw.keyring

生成 ceph-radosgw 服务对应的用户和 key

ceph-authtool /etc/ceph/ceph.client.radosgw.keyring -n client.rgw.node1 --gen-key ceph-authtool /etc/ceph/ceph.client.radosgw.keyring -n client.rgw.node2 --gen-key ceph-authtool /etc/ceph/ceph.client.radosgw.keyring -n client.rgw.node3 --gen-key

添加用户访问权限

ceph-authtool -n client.rgw.node1 --cap osd  allow rwx  --cap mon  allow rwx  /etc/ceph/ceph.client.radosgw.keyring ceph-authtool -n client.rgw.node2 --cap osd  allow rwx  --cap mon  allow rwx  /etc/ceph/ceph.client.radosgw.keyring ceph-authtool -n client.rgw.node3 --cap osd  allow rwx  --cap mon  allow rwx  /etc/ceph/ceph.client.radosgw.keyring

将 keyring 导入集群中

ceph -k /etc/ceph/ceph.client.admin.keyring auth add client.rgw.node1 -i /etc/ceph/ceph.client.radosgw.keyring ceph -k /etc/ceph/ceph.client.admin.keyring auth add client.rgw.node2 -i /etc/ceph/ceph.client.radosgw.keyring ceph -k /etc/ceph/ceph.client.admin.keyring auth add client.rgw.node3 -i /etc/ceph/ceph.client.radosgw.keyring

编辑配置文件

cat   /etc/ceph/ceph.conf   EOF [client.rgw.node1] host=node1 keyring=/etc/ceph/ceph.client.radosgw.keyring log file=/var/log/radosgw/client.radosgw.gateway.log rgw_frontends = civetweb port=8080 [client.rgw.node2] host=node2 keyring=/etc/ceph/ceph.client.radosgw.keyring log file=/var/log/radosgw/client.radosgw.gateway.log rgw_frontends = civetweb port=8080 [client.rgw.node3] host=node3 keyring=/etc/ceph/ceph.client.radosgw.keyring log file=/var/log/radosgw/client.radosgw.gateway.log rgw_frontends = civetweb port=8080 EOF

创建日志目录

mkdir /var/log/radosgw chown ceph:ceph /var/log/radosgw

拷贝 keyring、ceph.confceph.conf 到 node2、node3

scp /etc/ceph/ceph.client.radosgw.keyring node2:/etc/ceph/ceph.client.radosgw.keyring scp /etc/ceph/ceph.client.radosgw.keyring node3:/etc/ceph/ceph.client.radosgw.keyring scp /etc/ceph/ceph.conf node2:/etc/ceph/ceph.conf scp /etc/ceph/ceph.conf node3:/etc/ceph/ceph.conf

在 node2、node3 部署 RGW

修改 keyring 属主

chown ceph:ceph /etc/ceph/ceph.client.radosgw.keyring

创建日志目录并授权

mkdir /var/log/radosgw chown ceph:ceph /var/log/radosgw

启动 rgw 服务

systemctl start ceph-radosgw@rgw.`hostname -s`   systemctl enable ceph-radosgw@rgw.`hostname -s`

查看 ceph 状态,发现有个小问题

如何手动部署 Ceph octopus 集群

使用 ceph health  detail 查看详情,根据提示 enable 即可

如何手动部署 Ceph octopus 集群

使用 curl 访问服务

如何手动部署 Ceph octopus 集群

感谢你能够认真阅读完这篇文章,希望丸趣 TV 小编分享的“如何手动部署 Ceph octopus 集群”这篇文章对大家有帮助,同时也希望大家多多支持丸趣 TV,关注丸趣 TV 行业资讯频道,更多相关知识等着你来学习!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-16发表,共计9971字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)