使用 ceph 自建 NAS
文档说明:只记录关键地方; 发布时间: 2022-10-22
环境: ubuntu + podman + cephadm
目标:自建 NAS
意义: 因数据量大,云盘总费用,到了承受不起的地步,果断买硬件自建 存储系统
技术选项: RAID 5 + LVM + 廉价硬盘, NAS 搭建工具 cephadm
ceph 简述
ceph 支持 对象存储(Object Storage) ; 块存储(Block Storage) ; 文件存储(File Storage)
对象存储(Object Storage) 类似案例: 阿里云 OSS 、AWS S3
块存储(Block Storage) 类似案例: 云盘 、 iSCSI
文件存储(File Storage) 类似案例: NFS 、NAS 、cephfs 、 samba
cephfs 和 RGW 可以转换为 NFS 详见:CEPHFS & RGW EXPORTS OVER NFS
使用cephadm 实现 ceph 初始化
#!/bin/env bash set -eux __DIR__=$(cd "$(dirname "$0")";pwd) cd ${__DIR__} if [ ! "$BASH_VERSION" ] ; then echo "Please do not use sh to run this script ($0), just execute it directly" 1>&2 exit 1 fi apt install cephadm # enp0s3 网卡名称 ip=$(ip -4 address show | grep enp0s3 | grep 'inet' | awk '{print $2}' | awk -F '/' '{print $1}' | sed -n '1p') cat <<EOF > initial-ceph.conf [global] osd crush chooseleaf type = 0 EOF # 使用配置文件初始化 # ./cephadm bootstrap --config initial-ceph.conf # 不使用配置文件初始化 cephadm bootstrap \ --no-cleanup-on-failure \ --cluster-network 192.168.3.0/24 \ --mon-ip 192.168.3.205 \ --dashboard-password-noupdate \ --initial-dashboard-user admin \ --initial-dashboard-password ceph \ --allow-fqdn-hostname \ --single-host-defaults \
删除容器版ceph
#!/bin/env bash set -eux __DIR__=$(cd "$(dirname "$0")";pwd) cd ${__DIR__} if [ ! "$BASH_VERSION" ] ; then echo "Please do not use sh to run this script ($0), just execute it directly" 1>&2 exit 1 fi ./cephadm rm-cluster --force --zap-osds --fsid `awk -F "=" '/fsid/ {print $2}' /etc/ceph/ceph.conf`
常用命令
ceph mgr module disable dashboard ceph mgr module enable dashboard ceph dashboard get-grafana-api-url ceph dashboard get-grafana-frontend-api-url ceph mgr services ceph orch ls ceph orch ps ceph mgr module ls ceph orch host ls ceph orch device ls ceph osd tree
linux nfs 挂载例子
# 挂载 sudo mount -t nfs -o vers=4,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 192.168.3.205:/ceph/ /home/jingjingxyk/swoole-cli/pool/ # 卸载 sudo umount /home/jingjingxyk/swoole-cli/pool/
参考文档
磁盘 LVM 操作 (增减硬盘时需要)
一张图让你学会LVM
图原始地址: https://www.linuxprobe.com/one-picture-to-learn-lvm.html
分类:
Cloud Native
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术