您好,登錄后才能下訂單哦!
1 核心組件介紹
Object
Ceph最底層的存儲(chǔ)單元是Object對(duì)象,每個(gè)Object包含元數(shù)據(jù)和原始數(shù)據(jù)。
OSD
OSD全稱Object Storage Device,也就是負(fù)責(zé)響應(yīng)客戶端請(qǐng)求返回具體數(shù)據(jù)的進(jìn)程。一個(gè)Ceph集群一般都有很多個(gè)OSD。
PG
PG全稱Placement Grouops,是一個(gè)邏輯的概念,一個(gè)PG包含多個(gè)OSD。引入PG這一層其實(shí)是為了更好的分配數(shù)據(jù)和定位數(shù)據(jù)。
Monitor
一個(gè)Ceph集群需要多個(gè)Monitor組成的小集群,它們通過(guò)Paxos同步數(shù)據(jù),用來(lái)保存OSD的元數(shù)據(jù)。
RADOS
RADOS全稱Reliable Autonomic Distributed Object Store,是Ceph集群的精華,用戶實(shí)現(xiàn)數(shù)據(jù)分配、Failover等集群操作。
Libradio
Librados是Rados提供庫(kù),因?yàn)镽ADOS是協(xié)議很難直接訪問(wèn),因此上層的RBD、RGW和CephFS都是通過(guò)librados訪問(wèn)的,目前提供PHP、Ruby、Java、Python、C和C++支持。
CRUSH
CRUSH是Ceph使用的數(shù)據(jù)分布算法,類(lèi)似一致性哈希,讓數(shù)據(jù)分配到預(yù)期的地方。
RBD
RBD全稱RADOS block device,是Ceph對(duì)外提供的塊設(shè)備服務(wù)。
RGW
RGW全稱RADOS gateway,是Ceph對(duì)外提供的對(duì)象存儲(chǔ)服務(wù),接口與S3和Swift兼容。
MDS
MDS全稱Ceph Metadata Server,是CephFS服務(wù)依賴的元數(shù)據(jù)服務(wù)。
CephFS
CephFS全稱Ceph File System,是Ceph對(duì)外提供的文件系統(tǒng)服務(wù)。
2 安裝準(zhǔn)備
操作系統(tǒng):CentOS Linux release 7.4.1708 (Core)
內(nèi)核版本:3.10.0-693.el7.x86_64
服務(wù)器使用規(guī)劃
Node | Host Name | Ceph Deploy | Ceph Admin | Mon | OSD | MDS | MGR | RGW |
192.168.2.241 | node1 | √ | √ | √ | √ | √ | ||
192.168.2.242 | node2 | √ | √ | √ | √ | |||
192.168.2.243 | node3 | √ | √ | |||||
192.168.2.244 | node4 | √ | ||||||
192.168.2.245 | node5 | √ |
存儲(chǔ)準(zhǔn)備
node4、node5兩個(gè)osd節(jié)點(diǎn)單獨(dú)掛載一個(gè)5G大小的存儲(chǔ)盤(pán)
目錄規(guī)劃
/install ? ? ? ? ? #用來(lái)存放安裝文件
創(chuàng)建以上目錄(node1)
mkdir?/install
依次修改主機(jī)名,xx請(qǐng)?zhí)鎿Q1-5
hostnamectl?set-hostname?nodexx
配置免密訪問(wèn)(管理節(jié)點(diǎn))
ssh-keygen ssh-copy-id?node1 ssh-copy-id?node2 ssh-copy-id?node3 ssh-copy-id?node4 ssh-copy-id?node5
修改主機(jī)hosts配置(管理節(jié)點(diǎn))
vi?/etc/hosts 192.168.2.241?node1 192.168.2.242?node2 192.168.2.243?node3 192.168.2.244?node4 192.168.2.245?node5
同步hosts配置到其他節(jié)點(diǎn)
scp?/etc/hosts?node2:/etc/ scp?/etc/hosts?node3:/etc/ scp?/etc/hosts?node4:/etc/ scp?/etc/hosts?node5:/etc/
關(guān)閉防火墻(所有節(jié)點(diǎn))
setenforce?0 systemctl?stop?firewalld?&&?systemctl?disable?firewalld
時(shí)間同步(所有節(jié)點(diǎn))
yum?install?ntp?ntpdate?-y ntpdate?cn.pool.ntp.org systemctl?enable?ntpd systemctl?start?ntpd
內(nèi)核優(yōu)化(node1)
vi?/etc/sysctl.conf net.ipv4.tcp_fin_timeout?=?2 net.ipv4.tcp_tw_reuse?=?1? net.ipv4.tcp_tw_recycle?=?1? net.ipv4.tcp_syncookies?=?1? net.ipv4.tcp_keepalive_time?=?600? net.ipv4.tcp_keepalive_probes?=?5? net.ipv4.tcp_keepalive_intvl?=?15 net.ipv4.ip_local_port_range?=?1024?65000 net.ipv4.tcp_max_syn_backlog?=?262144 net.ipv4.tcp_max_tw_buckets?=5000 net.ipv4.tcp_syn_retries?=?1 net.ipv4.tcp_synack_retries?=?1 net.core.somaxconn?=?16384 net.core.netdev_max_backlog?=?16384 net.ipv4.tcp_max_orphans?=?16384
同步到其他節(jié)點(diǎn)
scp?/etc/sysctl.conf?node2:/etc scp?/etc/sysctl.conf?node3:/etc scp?/etc/sysctl.conf?node4:/etc scp?/etc/sysctl.conf?node5:/etc vi?/etc/security/limits.conf soft?nofile?1024000 hard?nofile?1024000 root?soft?nofile?1024000 root?hard?nofile?1024000
同步到其他節(jié)點(diǎn)
scp?/etc/security/limits.conf?node2:/etc/security scp?/etc/security/limits.conf?node3:/etc/security scp?/etc/security/limits.conf?node4:/etc/security scp?/etc/security/limits.conf?node5:/etc/security
生效配置(所有節(jié)點(diǎn))
sysctl?-p
修改環(huán)境配置(所有節(jié)點(diǎn))
echo?"ulimit?-HSn?102400"?>>?/etc/profile
添加yum源
cat?<<?EOM?>?/etc/yum.repos.d/ceph.repo [Ceph-SRPMS] name=Ceph?SRPMS?packages baseurl=https://mirrors.aliyun.com/ceph/rpm-mimic/el7/SRPMS/ enabled=1 gpgcheck=0 type=rpm-md [Ceph-aarch74] name=Ceph?aarch74?packages baseurl=https://mirrors.aliyun.com/ceph/rpm-mimic/el7/aarch74/ enabled=1 gpgcheck=0 type=rpm-md [Ceph-noarch] name=Ceph?noarch?packages baseurl=https://mirrors.aliyun.com/ceph/rpm-mimic/el7/noarch/ enabled=1 gpgcheck=0 type=rpm-md [Ceph-x86_64] name=Ceph?x86_64?packages baseurl=https://mirrors.aliyun.com/ceph/rpm-mimic/el7/x86_64/ enabled=1 gpgcheck=0 type=rpm-md EOM
同步到其他節(jié)點(diǎn)
scp?/etc/yum.repos.d/ceph.repo?node2:/etc/yum.repos.d scp?/etc/yum.repos.d/ceph.repo?node3:/etc/yum.repos.d scp?/etc/yum.repos.d/ceph.repo?node4:/etc/yum.repos.d scp?/etc/yum.repos.d/ceph.repo?node5:/etc/yum.repos.d
清理緩存(所有節(jié)點(diǎn))
yum?makecache
3 集群部署
安裝依賴(所有節(jié)點(diǎn))
yum?install?-y?https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
安裝ceph(所有節(jié)點(diǎn))
yum?-y?install?epel-release?ceph?ceph-radosgw?ceph-common?deltarpm
安裝ceph-deploy(node1執(zhí)行)
yum?install?-y?ceph-deploy
創(chuàng)建一個(gè)名稱為mycluster的集群,如果沒(méi)有指定--clster,默認(rèn)名稱為ceph,集群節(jié)點(diǎn)(mon)包括node{1,2,3}(node1執(zhí)行)
cd?/install ceph-deploy?--cluster?mycluster?new?node{1,2,3}
修改ceph配置文件,增加網(wǎng)段(生產(chǎn)環(huán)境以實(shí)際為準(zhǔn),建議public和cluster使用不同的段)
vi?ceph.conf public?network?=?192.168.2.0/24 cluster?network?=?192.168.2.0/24 mon_allow_pool_delete?=?true osd?pool?default?size?=?2 osd?pool?default?min?size?=?1 osd?pool?default?pg?num?=?64 osd?pool?default?pgp?num?=?64
創(chuàng)建和初始化監(jiān)控節(jié)點(diǎn)并收集所有的秘鑰(node1執(zhí)行)
ceph-deploy?mon?create-initial
將配置文件和管理秘鑰復(fù)制到管理節(jié)點(diǎn)和ceph節(jié)點(diǎn)(node1執(zhí)行)
ceph-deploy?admin?node{1,2,3,4,5}
部署mgr(node1執(zhí)行)
ceph-deploy?mgr?create?node{1,2}
部署osd(node1執(zhí)行)
ceph-deploy?osd?create?--data?/dev/sdb?node4 ceph-deploy?osd?create?--data?/dev/sdb?node5
4 啟用Dashboard
先查看dashboard狀態(tài)
ceph?mgr?services
啟用dashboard
ceph?mgr?module?enable?dashboard
生成自簽名證書(shū)
ceph?dashboard?create-self-signed-cert cd?/install openssl?req?\ -new?-nodes?\ -x509?\ -subj?"/O=IT/CN=ceph-mgr-dashboard"?\ -days?3650?\ -keyout?dashboard.key?\ -out?dashboard.crt?\ -extensions?v3_ca
啟用證書(shū)
ceph?config-key?set?mgr?mgr/dashboard/crt?-i?dashboard.crt ceph?config-key?set?mgr?mgr/dashboard/key?-i?dashboard.key
不用證書(shū)功能的時(shí)候,可以選擇禁用證書(shū)
ceph?config?set?mgr?mgr/dashboard/ssl?false
注:更換證書(shū)后,需要重啟dashboard
ceph?mgr?module?disable?dashboard ceph?mgr?module?enable?dashboard
配置服務(wù)地址、端口(生產(chǎn)環(huán)境中,mgr的訪問(wèn)地址建議使用域名或者負(fù)載IP)
ceph?config?set?mgr?mgr/dashboard/server_addr?192.168.2.241 ceph?config?set?mgr?mgr/dashboard/server_port?8443
創(chuàng)建用戶
ceph?dashboard?set-login-credentials?admin?admin
重啟mgr
systemctl?restart?ceph-mgr@node1
瀏覽器訪問(wèn)
https://192.168.2.241:8443
5 塊存儲(chǔ)
任意ceph集群主機(jī)執(zhí)行
創(chuàng)建存儲(chǔ)池,命名為ec,pg和pgs分配為64(這里只是測(cè)試,生產(chǎn)環(huán)境請(qǐng)按公式計(jì)算pg和pgs)
ceph?osd?pool?create?ec?64?64
rbd方式啟用該存儲(chǔ)池
ceph?osd?pool?application?enable?ec?rbd
創(chuàng)建用戶client.ec,用于客戶端掛載訪問(wèn)
ceph?auth?get-or-create?client.ec?\ mon?'allow?r'??\ osd?'allow?rwx?pool=ec'?\ -o?/etc/ceph/ceph.client.ec.keyring
遠(yuǎn)端客戶端掛載
檢查客戶端內(nèi)核版本,內(nèi)核版本建議在2.6.34以上版本
uname?-r
檢查當(dāng)前內(nèi)核版本是否支持rbd
modprobe?rbd?&&?lsmod|grep?rbd
在hosts配置添加ceph集群主機(jī)映射
vi?/etc/hosts 192.168.2.241?node1 192.168.2.242?node2 192.168.2.243?node3 192.168.2.244?node4 192.168.2.245?node5
考慮到國(guó)外下載慢的問(wèn)題,配置國(guó)內(nèi)鏡像源
cat?<<?EOM?>?/etc/yum.repos.d/ceph.repo [Ceph-SRPMS] name=Ceph?SRPMS?packages baseurl=https://mirrors.aliyun.com/ceph/rpm-mimic/el7/SRPMS/ enabled=1 gpgcheck=0 type=rpm-md [Ceph-aarch74] name=Ceph?aarch74?packages baseurl=https://mirrors.aliyun.com/ceph/rpm-mimic/el7/aarch74/ enabled=1 gpgcheck=0 type=rpm-md [Ceph-noarch] name=Ceph?noarch?packages baseurl=https://mirrors.aliyun.com/ceph/rpm-mimic/el7/noarch/ enabled=1 gpgcheck=0 type=rpm-md [Ceph-x86_64] name=Ceph?x86_64?packages baseurl=https://mirrors.aliyun.com/ceph/rpm-mimic/el7/x86_64/ enabled=1 gpgcheck=0 type=rpm-md EOM
清理緩存
yum?makecache
安裝依賴
yum?install?-y?https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
安裝ceph客戶端
yum?-y?install?ceph-common
將服務(wù)端生成的用戶秘鑰(client.ec)拷貝到客戶端服務(wù)器
scp?-r?/etc/ceph/ceph.client.ec.keyring?node5:/etc/ceph
驗(yàn)證用戶權(quán)限,由于沒(méi)有使用admin賬號(hào),所以每次都需要指定訪問(wèn)用戶
ceph?-s?--name?client.ec
在存儲(chǔ)池ec上創(chuàng)建塊設(shè)備(磁盤(pán)),命名為ec,分配最大存儲(chǔ)空間10G
rbd?create?ec/ec?--size?10G?--image-format?2?--image-feature?layering?--name?client.ec
查看創(chuàng)建的塊設(shè)備
rbd?info?ec/ec?--name?client.ec 或 rbd?info?-p?ec?ec?--name?client.ec
將塊設(shè)備映射到本地磁盤(pán)
rbd?map?ec/ec?--name?client.ec
格式化磁盤(pán),可以選擇格式化成ext4或xfs
mkfs.ext4?/dev/rbd0
創(chuàng)建掛載目錄
mkdir?/ecdata
將盤(pán)符掛載到該目錄
mount?/dev/rbd0?/ecdata
查看掛載狀態(tài)
df?-h rbd?showmapped
擴(kuò)容
rbd?resize?--size?xxG?pool-name/image-name
擴(kuò)容存儲(chǔ)空間后,在客戶端不會(huì)立即生效,需要在客戶端執(zhí)行如下操作
#針對(duì)ext文件系統(tǒng),rbd0為映射的本地設(shè)備名 blockdev?--getsize64?/dev/rbd0 resize2fs?/dev/rbd0 #針對(duì)xfs文件系統(tǒng),還需要執(zhí)行如下命令,mnt為掛載點(diǎn) xfs_growfs?/mnt
創(chuàng)建快照
rbd?snap?create?ec/ec@ec-snap
回滾快照(出現(xiàn)回滾失敗時(shí),需要先解除掛載和本地映射)
rbd?snap?rollback?ec/ec@ec-snap
克隆快照
rbd?snap?protect?ec/ec@ec-snap rbd?snap?clone?ec/ec@ec-snap?new-ec-pool
6 文件存儲(chǔ)
服務(wù)端
部署mds(node1執(zhí)行),啟用文件存儲(chǔ)時(shí)創(chuàng)建
ceph-deploy?mds?create?node2
創(chuàng)建存儲(chǔ)池
ceph?osd?pool?create?cephfs_data?64 ceph?osd?pool?create?cephfs_metadata?64
創(chuàng)建文件系統(tǒng)
ceph?fs?new?cephfs?cephfs_metadata?cephfs_data
查看MDS服務(wù)器狀態(tài)
ceph?mds?stat
創(chuàng)建用戶
ceph?auth?get-or-create?client.cephfs?\ mon?'allow?r'?\ mds?'allow?r,allow?rw?path=/'?\ osd?'allow?rw?pool=cephfs_data'?\ -o?/etc/ceph/ceph.client.cephfs.keyring
同步key到其他節(jié)點(diǎn)
scp?/etc/ceph/ceph.client.cephfs.keyring?node2:/etc/ceph scp?/etc/ceph/ceph.client.cephfs.keyring?node3:/etc/ceph
查看用戶key
ceph?auth?get-key?client.cephfs
客戶端
掛載ceph文件系統(tǒng)(啟用cephx認(rèn)證后,必須指定授權(quán)用戶),其中192.168.2.241為mon地址
mount?-t?ceph?node1:6789:/?/data?-o?name=cephfs,secret=AQAHs9RdRVLkOBAAYl1JZqYupcHnORttIo+Udg==
或
echo?"AQAHs9RdRVLkOBAAYl1JZqYupcHnORttIo+Udg=="?>?/etc/ceph/cephfskey mount?-t?ceph?node1:6789:/?/data?-o?name=cephfs,secretfile=/etc/ceph/cephfskey
寫(xiě)入數(shù)據(jù)測(cè)試(1G)
dd?if=/dev/zero?of=/data/file2?bs=1M?count=1024
開(kāi)機(jī)自動(dòng)掛載
echo?"node1:6789:/?/data/?ceph?name=cephfs,secret=AQAHs9RdRVLkOBAAYl1JZqYupcHnORttIo+Udg==,_netdev,noatime?0?0"?>>?/etc/fstab
或
echo?"node1:6789:/?/data/?ceph?name=cephfs,secretfile=/etc/ceph/cephfskey,_netdev,noatime?0?0"?>>?/etc/fstab
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。