环境要求
-
操作系统:openEuler 22.03 LTS(三台云主机)
-
节点角色:
-
storage01
:mon/mgr/osd节点 -
storage02
:osd节点 -
storage03
:osd节点
-
-
磁盘规划:每节点至少2块磁盘(系统盘+数据盘
/dev/sdb
)
初始配置(所有节点执行)
# 设置主机名(按节点分别执行)
hostnamectl set-hostname storage01 # 第一节点
hostnamectl set-hostname storage02 # 第二节点
hostnamectl set-hostname storage03 # 第三节点
# 关闭防火墙和SELinux(所有节点)
systemctl stop firewalld && systemctl disable firewalld
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
# 配置时间同步(重要!)
yum install -y chrony
systemctl enable chronyd --now
chronyc sources
软件仓库配置(storage01节点)
-
部署本地仓库服务
# 解压Ceph软件包到共享目录
tar -zxf ceph-14.2.22.tar.gz -C /opt/
# 安装并配置HTTP服务(替代FTP)
yum install -y nginx
cat > /etc/nginx/conf.d/repo.conf << EOF
server {
listen 80;
server_name localhost;
root /opt;
autoindex on;
}
EOF
# 启动服务
systemctl enable nginx --now
其他节点配置(storage02/storage03)
# 配置仓库文件
cat > /etc/yum.repos.d/ceph.repo << EOF
[ceph]
name=Ceph Packages
baseurl=http://storage01/ceph-14.2.22
enabled=1
gpgcheck=0
[baseos]
name=openEuler-22.03-LTS-BaseOS
baseurl=https://repo.openeuler.org/openEuler-22.03-LTS/OS/\$basearch/
enabled=1
gpgcheck=0
EOF
# 更新缓存
dnf clean all && dnf makecache
集群初始化配置
-
主机名解析(所有节点)
# 在storage01操作
cat >> /etc/hosts << EOF
192.168.100.11 storage01
192.168.100.12 storage02
192.168.100.13 storage03
EOF
# 同步到其他节点
scp /etc/hosts root@storage02:/etc/
scp /etc/hosts root@storage03:/etc/
-
SSH免密登录
# 生成密钥(storage01执行)
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
# 分发公钥
ssh-copy-id storage01
ssh-copy-id storage02
ssh-copy-id storage03
Ceph集群部署
-
安装依赖组件
# 所有节点安装基础工具
dnf install -y python3 python3-pip tar
# 安装Ceph部署工具(storage01执行)
pip3 install ceph-deploy
-
初始化集群
mkdir /etc/ceph && cd /etc/ceph
ceph-deploy new storage01 # 生成初始配置
# 编辑配置文件添加兼容性参数
cat >> ceph.conf << EOF
osd_pool_default_size = 3
osd_pool_default_min_size = 1
mon_allow_pool_delete = true
EOF
# 安装Ceph组件(全节点)
ceph-deploy install --no-adjust-repos storage01 storage02 storage03
-
部署监控服务
# 初始化mon节点
ceph-deploy mon create-initial
# 禁用不安全认证
ceph config set mon auth_allow_insecure_global_id_reclaim false
-
部署存储节点
# 创建OSD(注意:openEuler磁盘路径可能不同)
ceph-deploy osd create --data /dev/sdb storage01
ceph-deploy osd create --data /dev/sdb storage02
ceph-deploy osd create --data /dev/sdb storage03
# 部署管理服务
ceph-deploy mgr create storage01 storage02 storage03
存储池创建与验证
# 创建存储池
ceph osd pool create vms 32
ceph osd pool create images 32
ceph osd pool create volumes 32
# 设置PGP数量(必须等于PG数)
ceph osd pool set vms pgp_num 32
ceph osd pool set images pgp_num 32
ceph osd pool set volumes pgp_num 32
# 验证集群状态
ceph -s
关键验证输出
# ceph -s 健康状态
cluster:
id: 4a3b9c8d-6e1f-4c7a-bd82-5a0f6e2c1b7a
health: HEALTH_OK
# osd tree结构
ID CLASS WEIGHT TYPE NAME STATUS
0 hdd 0.01949 osd.0 up
1 hdd 0.01949 osd.1 up
2 hdd 0.01949 osd.2 up
部署后优化建议
-
CRUSH Map调优:根据实际硬件拓扑调整数据分布策略
-
性能优化:根据SSD/HDD混合部署场景配置缓存分层
-
监控集成:部署Prometheus+Grafana实现可视化监控