前言
为什么要集成ceph???
ceph官网:https://docs.ceph.com/en/latest/
关于ceph:https://blog.csdn.net/mingongge/article/details/100788388
参考连接:https://blog.csdn.net/jmilk/article/details/89503498
OpenStack 使用 Ceph 作为后端存储可以带来以下好处:
- 不需要购买昂贵的商业存储设备,降低 OpenStack 的部署成本
- Ceph 同时提供了块存储、文件系统和对象存储,能够完全满足 OpenStack 的存储类型需求
- RBD COW 特性支持快速的并发启动多个 OpenStack 实例
- 为 OpenStack 实例默认的提供持久化卷
- 为 OpenStack 卷提供快照、备份以及复制功能
- 为 Swift 和 S3 对象存储接口提供了兼容的 API 支持
在生产环境中,我们经常能够看见将 Nova、Cinder、Glance 与 Ceph RBD 进行对接。除此之外,还可以将 Swift、Manila 分别对接到 Ceph RGW 与 CephFS。Ceph 作为统一存储解决方案,有效降低了 OpenStack 云环境的复杂性与运维成本。
准备工作
1、新建一个虚拟机作为ceph的admin节点,配置如下
(1)双网卡
ens33:192.168.12.219
ens37:192.168.12.220
(2)4核处理器,4G内存,双硬盘60G x2
2、基础配置参考https://blog.csdn.net/qq_42666043/article/details/107668439前12步,其中第8步修改hosts文件,将openstack集群和ceph 集群都添加进去
vim /etc/hosts
#openstack集群
192.168.12.137 controller
192.168.12.133 compute
192.168.12.174 compute2
#ceph集群
192.168.12.219 ceph-admin
3、三个节点和ceph-admin节点配置时间同步
4、三个节点操作
yum install deltarpm -y
安装ceph软件
1、admin节点配置yum源,安装epel源,在ceph-admin,controller,compute上操作
cd /etc/yum.repos.d/
yum install -y yum-utils && sudo yum-config-manager --add-repo https://dl.fedoraproject.org/pub/epel/7/x86_64/ && sudo yum install --nogpgcheck -y epel-release && sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 && sudo rm /etc/yum.repos.d/dl.fedoraproject.org*
2、配置ceph的yum源,在ceph-admin,controller,compute上操作
vim /etc/yum.repos.d/ceph.repo
写入如下配置
[Ceph]
name=Ceph packages for $basearch
baseurl=http://mirrors.aliyun.com/ceph/rpm-jewel/el7/x86_64/
enabled=1
gpgcheck=0
type=rpm-md
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
priority=1
[Ceph-noarch]
name=Ceph noarch packages
baseurl=http://mirrors.aliyun.com/ceph/rpm-jewel/el7/noarch/
enabled=1
gpgcheck=0
type=rpm-md
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
priority=1
[ceph-source]
name=Ceph source packages
baseurl=http://mirrors.aliyun.com/ceph/rpm-jewel/el7/SRPMS/
enabled=1
gpgcheck=0
type=rpm-md
gpgkey=https://mirrors.aliyun.com/ceph/keys/release.asc
priority=1
清除缓存
yum makecache
3、在ceph-admin 上安装ceph-deploy管理工具 并且创建ceph工作目录
mkdir -p /etc/ceph && cd /etc/ceph/
yum -y install ceph-deploy
4、在ceph-admin上使用ceph-deploy给所有节点安装ceph
ceph-deploy install ceph-admin controller compute compute2
5、在ceph-admin节点进入ceph目录创建一个ceph集群
ceph-deploy new ceph-admin controller compute compute2
命令执行之后在ceph目录会生成相关的配置文件ceph.conf,ceph.mon.keyring
cat ceph.conf
[global]
fsid = 1cbc8bc2-c0a9-4442-b32f-49bd6d5179d2
mon_initial_members = ceph-admin, controller, compute, compute2
mon_host = 192.168.12.224,192.168.12.137,192.168.12.133,192.168.12.174
auth_cluster_required = cephx
auth_service_required = cephx
auth_client_required = cephx
6、在ceph-admin节点上使用ceph-deploy创建mon
ceph-deploy mon create ceph-admin controller compute compute2
7、在ceph-admin节点收集密钥
ceph-deploy gatherkeys ceph-admin
这时在/etc/ceph下可看到如下文件
ceph.bootstrap-mds.keyring ceph.bootstrap-rgw.keyring ceph-deploy-ceph.log
ceph.bootstrap-mgr.keyring ceph.client.admin.keyring ceph.mon.keyring
ceph.bootstrap-osd.keyring ceph.conf rbdmap
8、在ceph-admin节点上使用ceph-deploy创建osd
ceph-deploy osd create ceph-admin:sdb controller:sdb compute:sdb compute2:sdb
9、在ceph-admin 节点分发配置文件
ceph-deploy admin ceph-admin controller compute compute2
10、给kerying添加权限 (每一个节点都要执行)
chmod +rx /etc/ceph/*
- 可能出现的错误一
ceph -s 查看集群健康状态,如果发现报错
ceph -s
cluster 1cbc8bc2-c0a9-4442-b32f-49bd6d5179d2
health HEALTH_WARN
clock skew detected on mon.compute2
16 pgs degraded
43 pgs stuck unclean
16 pgs undersized
1/4 in osds are down
Monitor clock skew detected
monmap e1: 4 mons at {ceph-admin=192.168.12.224:6789/0,compute=192.168.12.133:6789/0,compute2=192.168.12.174:6789/0,controller=192.168.12.137:6789/0}
election epoch 6, quorum 0,1,2,3 compute,controller,compute2,ceph-admin
osdmap e22: 4 osds: 3 up, 4 in; 43 remapped pgs
flags sortbitwise,require_jewel_osds
pgmap v45: 64 pgs, 1 pools, 0 bytes data, 0 objects
430 MB used, 299 GB / 299 GB avail
25 active+