ceph-deploy比較適合生產環境,不是用cephadm搭建。相對麻煩一些,但是並不難,細節把握好就行,只是命令多一些而已。 實驗環境 伺服器主機 public網段IP(對外服務) cluster網段IP(集群通信) 角色 deploy 192.168.2.120 用於部署集群、管理集群 cep ...
ceph-deploy比較適合生產環境,不是用cephadm搭建。相對麻煩一些,但是並不難,細節把握好就行,只是命令多一些而已。
實驗環境
伺服器主機 | public網段IP(對外服務) | cluster網段IP(集群通信) | 角色 |
---|---|---|---|
deploy | 192.168.2.120 | 用於部署集群、管理集群 | |
ceph-node1 | 192.168.2.121 | 192.168.6.135 | ceph-mon、ceph-mgr、ceph-osd |
ceph-node2 | 192.168.2.122 | 192.168.6.136 | ceph-mon、ceph-mgr、ceph-osd |
ceph-node3 | 192.168.2.123 | 192.168.6.137 | ceph-mon、ceph-osd |
ceph-osd節點:一般建議裸金屬部署。
10c\12c, 32G、64G更好。
ceph-mgr兩個節點就可以做高可用了,當然可以用更多節點。
ceph-mon必須3個節點以上。
ceph-mon性能可以低一點,比如跑虛擬機上。
4c8g也夠用,4C16G更好。
準備工作
關閉防火牆、關閉selinux
systemctl disable firewalld
systemctl stop firewalld
setenforce 0
sed -i '7s/enforcing/disabled/' /etc/selinux/config
設置每台服務的hostname
hostnamectl set-hostname ceph-node1
hostnamectl set-hostname ceph-node2
hostnamectl set-hostname ceph-node3
hostnamectl set-hostname ceph-deploy
設置host相互解析
192.168.2.120 ceph-deploy
192.168.2.121 ceph-node1
192.168.2.122 ceph-node2
192.168.2.123 ceph-node3
每台伺服器添加好epel源
[epel]
name=Extra Packages for Enterprise Linux 7 -
baseurl=http://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch/
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - - Debug
baseurl=http://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch/debug
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
[epel-source]
name=Extra Packages for Enterprise Linux 7 - - Source
baseurl=http://mirrors.tuna.tsinghua.edu.cn/epel/7/SRPMS
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
每台伺服器添加ceph的源
[Ceph]
name=Ceph packages for $basearch
baseurl=http://mirrors.tuna.tsinghua.edu.cn/ceph/rpm-mimic/el7/$basearch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/ceph/keys/release.asc
[Ceph-noarch]
name=Ceph noarch packages
baseurl=http://mirrors.tuna.tsinghua.edu.cn/ceph/rpm-mimic/el7/noarch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/ceph/keys/release.asc
[ceph-source]
name=Ceph source packages
baseurl=http://mirrors.tuna.tsinghua.edu.cn/ceph/rpm-mimic/el7/SRPMS
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/ceph/keys/release.asc
每天伺服器添加ceph用戶
groupadd ceph -g 3333
useradd -u 3333 -g 3333 ceph
echo "cephadmin888" | passwd --stdin ceph
每台服務配置sudoer配置文件,允許ceph用戶執行所有sudo命令
echo "ceph ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
ceph-deploy節點生產ssh密鑰
# 切換到ceph用戶,切記一定要切換再做..不然免密就是免密你當前的用戶,因為後續要用ceph用戶來部署。
su - ceph
# 生成ssh密鑰
ssh-keygen
複製ssh密鑰到ceph-node1、ceph-node2、ceph-node3節點
sudo ssh-copy-id [email protected]
sudo ssh-copy-id [email protected]
sudo ssh-copy-id [email protected]
開始部署集群
在ceph-deploy節點創建目錄
su - ceph
[ceph@ceph-deploy ~]$ mkdir ceph-cluster-deploy
[ceph@ceph-deploy ~]$ cd ceph-cluster-deploy/
[ceph@ceph-deploy ceph-cluster-deploy]$
安裝ceph-deploy包
[ceph@ceph-deploy ceph-cluster-deploy]$ sudo yum install ceph-deploy python-setuptools python2-subprocess3
安裝成功後可以查看ceph-deploy命令是否能夠使用
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph-deploy
usage: ceph-deploy [-h] [-v | -q] [--version] [--username USERNAME]
[--overwrite-conf] [--ceph-conf CEPH_CONF]
COMMAND ...
查看ceph-deploy的版本
ceph-deploy 2.0.1預設安裝mimic的ceph版本(也就是13.2.10),如果需要安裝其他版本ceph,可以使用--release來指定
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph-deploy --version
2.0.1
執行ceph-deploy install命令初始化osd節點
在ceph-deploy節點通過執行install命令,為ceph集群中的osd節點安裝ceph相關包
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph-deploy install --help
usage: ceph-deploy install [-h] [--stable [CODENAME] | --release [CODENAME] |
--testing | --dev [BRANCH_OR_TAG]]
[--dev-commit [COMMIT]] [--mon] [--mgr] [--mds]
[--rgw] [--osd] [--tests] [--cli] [--all]
[--adjust-repos | --no-adjust-repos | --repo]
[--local-mirror [LOCAL_MIRROR]]
[--repo-url [REPO_URL]] [--gpg-url [GPG_URL]]
[--nogpgcheck]
HOST [HOST ...]
Install Ceph packages on remote hosts.
positional arguments:
HOST hosts to install on
... 等選項,此處忽略
# 這裡有2個比較重要的選項,分別是:
--no-adjust-repos install packages without modifying source repos # 不要去修改ceph的repo源,因為我們前面已經將源改成清華的源了,等下它給你改回來就慢的要死
--nogpgcheck install packages without gpgcheck # 跳過gpg校驗
執行命令:
# p.s:ceph-node{1..3} 中的{1..3}這個是linux中的一個迴圈運算,比如用在for迴圈中
# 實際上生產命令:ceph-deploy install --no-adjust-repos --nogpgcheck ceph-node1 ceph-node2 ceph-node3
# 執行該命令進行安裝
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph-deploy install --no-adjust-repos --nogpgcheck ceph-node{1..3}
執行過程就忽略了,執行成功後有類似提示,如下:
[ceph-node3][DEBUG ] 完畢!
[ceph-node3][INFO ] Running command: sudo ceph --version
[ceph-node3][DEBUG ] ceph version 13.2.10 (564bdc4ae87418a232fc901524470e1a0f76d641) mimic (stable)
執行ceph-deploy new命令執行ceph集群初始化
# 查看ceph-deploy new子命令的幫助信息
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph-deploy new --help
usage: ceph-deploy new [-h] [--no-ssh-copykey] [--fsid FSID]
[--cluster-network CLUSTER_NETWORK]
[--public-network PUBLIC_NETWORK]
MON [MON ...]
Start deploying a new cluster, and write a CLUSTER.conf and keyring for it.
positional arguments:
MON initial monitor hostname, fqdn, or hostname:fqdn pair
optional arguments:
-h, --help show this help message and exit
--no-ssh-copykey do not attempt to copy SSH keys
--fsid FSID provide an alternate FSID for ceph.conf generation
--cluster-network CLUSTER_NETWORK
specify the (internal) cluster network
--public-network PUBLIC_NETWORK
specify the public network for a cluster
執行命令:
# 由於我是將mon也放到osd節點上,所以這裡就是ceph-node1、ceph-node2、ceph-node3了
# 生產環境,建議將mon單獨伺服器節點。
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph-deploy new --cluster-network 192.168.6.0/24 --public-network 192.168.2.0/24 ceph-node1 ceph-node2 ceph-node3
[ceph_deploy.conf][DEBUG ] found configuration file at: /home/ceph/.cephdeploy.conf
[ceph_deploy.cli][INFO ] Invoked (2.0.1): /bin/ceph-deploy new --cluster-network 192.168.6.0/24 --public-network 192.168.2.0/24 ceph-node1 ceph-node2
[ceph_deploy.cli][INFO ] ceph-deploy options:
[ceph_deploy.cli][INFO ] username : None
[ceph_deploy.cli][INFO ] func : <function new at 0x7fa768c08de8>
[ceph_deploy.cli][INFO ] verbose : False
[ceph_deploy.cli][INFO ] overwrite_conf : False
[ceph_deploy.cli][INFO ] quiet : False
[ceph_deploy.cli][INFO ] cd_conf : <ceph_deploy.conf.cephdeploy.Conf instance at 0x7fa76837f8c0>
[ceph_deploy.cli][INFO ] cluster : ceph
[ceph_deploy.cli][INFO ] ssh_copykey : True
[ceph_deploy.cli][INFO ] mon : ['ceph-node1', 'ceph-node2']
[ceph_deploy.cli][INFO ] public_network : 192.168.2.0/24
[ceph_deploy.cli][INFO ] ceph_conf : None
[ceph_deploy.cli][INFO ] cluster_network : 192.168.6.0/24
[ceph_deploy.cli][INFO ] default_release : False
[ceph_deploy.cli][INFO ] fsid : None
[ceph_deploy.new][DEBUG ] Creating new cluster named ceph
[ceph_deploy.new][INFO ] making sure passwordless SSH succeeds
[ceph-node1][DEBUG ] connected to host: ceph-deploy
[ceph-node1][INFO ] Running command: ssh -CT -o BatchMode=yes ceph-node1
[ceph-node1][DEBUG ] connection detected need for sudo
[ceph-node1][DEBUG ] connected to host: ceph-node1
[ceph-node1][DEBUG ] detect platform information from remote host
[ceph-node1][DEBUG ] detect machine type
[ceph-node1][DEBUG ] find the location of an executable
[ceph-node1][INFO ] Running command: sudo /usr/sbin/ip link show
[ceph-node1][INFO ] Running command: sudo /usr/sbin/ip addr show
[ceph-node1][DEBUG ] IP addresses found: [u'192.168.2.121', u'192.168.6.135']
[ceph_deploy.new][DEBUG ] Resolving host ceph-node1
[ceph_deploy.new][DEBUG ] Monitor ceph-node1 at 192.168.2.121
[ceph_deploy.new][INFO ] making sure passwordless SSH succeeds
[ceph-node2][DEBUG ] connected to host: ceph-deploy
[ceph-node2][INFO ] Running command: ssh -CT -o BatchMode=yes ceph-node2
[ceph_deploy.new][WARNIN] could not connect via SSH
[ceph_deploy.new][INFO ] will connect again with password prompt
The authenticity of host 'ceph-node2 (192.168.2.122)' can't be established.
ECDSA key fingerprint is SHA256:bFB9FzJjKEKMP2W5kW+orMbo9mD+tr8fLOPRsYaXhj8.
ECDSA key fingerprint is MD5:b7:e5:bd:6a:56:10:42:3d:34:3a:54:ac:79:a2:3c:5b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ceph-node2' (ECDSA) to the list of known hosts.
[ceph-node2][DEBUG ] connected to host: ceph-node2
[ceph-node2][DEBUG ] detect platform information from remote host
[ceph-node2][DEBUG ] detect machine type
[ceph_deploy.new][INFO ] adding public keys to authorized_keys
[ceph-node2][DEBUG ] append contents to file
[ceph-node2][DEBUG ] connection detected need for sudo
[ceph-node2][DEBUG ] connected to host: ceph-node2
[ceph-node2][DEBUG ] detect platform information from remote host
[ceph-node2][DEBUG ] detect machine type
[ceph-node2][DEBUG ] find the location of an executable
[ceph-node2][INFO ] Running command: sudo /usr/sbin/ip link show
[ceph-node2][INFO ] Running command: sudo /usr/sbin/ip addr show
[ceph-node2][DEBUG ] IP addresses found: [u'192.168.6.136', u'192.168.2.122']
[ceph_deploy.new][DEBUG ] Resolving host ceph-node2
[ceph_deploy.new][DEBUG ] Monitor ceph-node2 at 192.168.2.122
[ceph_deploy.new][DEBUG ] Monitor initial members are ['ceph-node1', 'ceph-node2']
[ceph_deploy.new][DEBUG ] Monitor addrs are [u'192.168.2.121', u'192.168.2.122']
[ceph_deploy.new][DEBUG ] Creating a random mon key...
[ceph_deploy.new][DEBUG ] Writing monitor keyring to ceph.mon.keyring...
[ceph_deploy.new][DEBUG ] Writing initial config to ceph.conf...
# 查看當前目錄,可以發現生產了一些文件
[ceph@ceph-deploy ceph-cluster-deploy]$ ll
總用量 16
-rw-rw-r-- 1 ceph ceph 292 12月 22 12:10 ceph.conf # conf是ceph集群的配置文件
-rw-rw-r-- 1 ceph ceph 5083 12月 22 12:10 ceph-deploy-ceph.log # 日誌
-rw------- 1 ceph ceph 73 12月 22 12:10 ceph.mon.keyring # 這個是ceph集群的密鑰
# 查看ceph.conf
[ceph@ceph-deploy ceph-cluster-deploy]$ cat ceph.conf
[global]
fsid = f1da3a2e-b8df-46ba-9c6b-0030da25c73e
public_network = 192.168.2.0/24
cluster_network = 192.168.6.0/24
mon_initial_members = ceph-node1, ceph-node2
mon_host = 192.168.2.121,192.168.2.122
auth_cluster_required = cephx
auth_service_required = cephx
auth_client_required = cephx
配置mon節點
安裝ceph-mon包
如果是獨立的mon節點,記得檢查各個mon節點中是否安裝了ceph-mon包
yum install -y ceph-mon
初始化mon節點
切換回ceph-deploy節點
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph-deploy mon create-initial
執行完成後回發現又多了一些配置文件,這些文件都是非常重要的,類似k8s中的kubeconfig,不要隨意泄露。
[ceph@ceph-deploy ceph-cluster-deploy]$ ll
總用量 476
-rw------- 1 ceph ceph 113 12月 22 13:11 ceph.bootstrap-mds.keyring
-rw------- 1 ceph ceph 113 12月 22 13:11 ceph.bootstrap-mgr.keyring
-rw------- 1 ceph ceph 113 12月 22 13:11 ceph.bootstrap-osd.keyring
-rw------- 1 ceph ceph 113 12月 22 13:11 ceph.bootstrap-rgw.keyring
-rw------- 1 ceph ceph 151 12月 22 13:11 ceph.client.admin.keyring
-rw-rw-r-- 1 ceph ceph 292 12月 22 12:11 ceph.conf
-rw-rw-r-- 1 ceph ceph 207826 12月 22 13:17 ceph-deploy-ceph.log
-rw------- 1 ceph ceph 73 12月 22 12:11 ceph.mon.keyring
而且對應的mon節點上的伺服器,運行的mon服務
[email protected]
從此處鏈接:
/etc/systemd/system/ceph-mon.target.wants/ceph-mon@<mon節點主機名>.service
並且也有對應的進程
[root@ceph-node3 ~]# ps axu | grep non
ceph 2614 0.5 2.1 470596 39944 ? Ssl 13:17 0:00 /usr/bin/ceph-mon -f --cluster ceph --id ceph-node3 --setuser ceph --setgroup ceph
推送管理密鑰到節點
推送密鑰到各個osd節點、或者你需要使用ceph集群管理的節點。不推送你就得每次自己指定密鑰,比較麻煩。。。
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph-deploy admin ceph-node{1..3}
# 推送給自己,因為我這裡是用同一個伺服器來部署和管理ceph集群
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph-deploy admin ceph-deploy
設置密鑰的facl許可權
在各個node節點上設置文件facl,因為推送過去的密碼預設屬主和屬組都是root用戶,但是我們前面是創建ceph用戶用於管理ceph集群
# 可以在root用戶下設置,也可以用sudo
# ceph-node1
[root@ceph-node1 ~]# setfacl -m u:ceph:rw /etc/ceph/ceph.client.admin.keyring
[root@ceph-node1 ~]# getfacl /etc/ceph/ceph.client.admin.keyring
getfacl: Removing leading '/' from absolute path names
# file: etc/ceph/ceph.client.admin.keyring
# owner: root
# group: root
user::rw-
user:ceph:rw-
group::---
mask::rw-
other::---
# ceph-node2 和 ceph-node3 類似
# 因為我打算在deploy節點同時管理ceph,也就是admin和deploy是同一個節點,所以這裡也要給ddeploy節點設置facl
[root@ceph-deploy ~]# setfacl -m u:ceph:rw /etc/ceph/ceph.client.admin.keyring
配置mgr節點
只有ceph luminios和以上的版本才有mgr節點,老版本並沒有,所以老版本不需要部署。
但是我們部署的是安裝mimic的ceph版本(也就是13.2.10),所以需要部署。
安裝ceph-mgr包
如果是獨立的mgr節點伺服器,記得檢查是否安裝了ceph-mgr包
yum install -y ceph-mgr
ceph-mgr命令選項:
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph-deploy mgr --help
usage: ceph-deploy mgr [-h] {create} ...
Ceph MGR daemon management
positional arguments:
{create}
create Deploy Ceph MGR on remote host(s)
optional arguments:
-h, --help show this help message and exit
添加mgr節點
執行命令,初始化mgr節點
# 由於我是osd、mon、mgr混用伺服器,所以這裡就用ceph-node1、ceph-node2了。
ceph-deploy mgr create ceph-node1 ceph-node2
檢查ceph集群狀態
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph -s
cluster:
id: f1da3a2e-b8df-46ba-9c6b-0030da25c73e
health: HEALTH_WARN
OSD count 0 < osd_pool_default_size 3
services:
mon: 3 daemons, quorum ceph-node1,ceph-node2,ceph-node3
mgr: ceph-node1(active), standbys: ceph-node2
osd: 0 osds: 0 up, 0 in
data:
pools: 0 pools, 0 pgs
objects: 0 objects, 0 B
usage: 0 B used, 0 B / 0 B avail
pgs:
添加osd
添加osd到集群中
# 擦除osd節點上要被添加的磁碟的空間
ceph-deploy disk zap ceph-node1 /dev/sd{b,c,d}
ceph-deploy disk zap ceph-node2 /dev/sd{b,c,d}
ceph-deploy disk zap ceph-node3 /dev/sd{b,c,d}
# 添加ceph-node1上的磁碟為osd
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph-deploy osd create ceph-node1 --data /dev/sdb
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph-deploy osd create ceph-node1 --data /dev/sdc
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph-deploy osd create ceph-node1 --data /dev/sdd
# 添加ceph-node2上的磁碟為osd
ceph-deploy osd create ceph-node2 --data /dev/sdb
ceph-deploy osd create ceph-node2 --data /dev/sdc
ceph-deploy osd create ceph-node2 --data /dev/sdd
# 添加ceph-node3上的磁碟為osd
ceph-deploy osd create ceph-node3 --data /dev/sdb
ceph-deploy osd create ceph-node3 --data /dev/sdc
ceph-deploy osd create ceph-node3 --data /dev/sdd
# 添加完成後,會在對應的osd節點上添加osd服務(但是只是runtime臨時生效,必須將其改為永久生效)
如:/run/systemd/system/ceph-osd.target.wants/[email protected] # 7是osd的id,從0開始。
檢查osd狀態
# 通過ceph-deploy可以檢查
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph-deploy osd list ceph-node{1,2,3}
# 通過ceph osd stat命令檢查
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph osd stat
9 osds: 9 up, 9 in; epoch: e37
# 使用 ceph osd status 查看
- `id`: OSD的唯一標識符。
- `host`: OSD所在的主機名
- `used`: OSD已使用的存儲容量。
- `avail`: OSD可用的存儲容量。
- `wr ops`: OSD每秒寫入操作的數量。
- `wr data`: OSD每秒寫入數據的數量。
- `rd ops`: OSD每秒讀取操作的數量。
- `rd data`: OSD每秒讀取數據的數量。
- `state`: OSD的狀態,"exists"表示OSD存在,"up"表示OSD正常運行。
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph osd status
+----+------------+-------+-------+--------+---------+--------+---------+-----------+
| id | host | used | avail | wr ops | wr data | rd ops | rd data | state |
+----+------------+-------+-------+--------+---------+--------+---------+-----------+
| 0 | ceph-node1 | 1028M | 4087M | 0 | 0 | 0 | 0 | exists,up |
| 1 | ceph-node1 | 1028M | 4087M | 0 | 0 | 0 | 0 | exists,up |
| 2 | ceph-node1 | 1028M | 4087M | 0 | 0 | 0 | 0 | exists,up |
| 3 | ceph-node2 | 1028M | 4087M | 0 | 0 | 0 | 0 | exists,up |
| 4 | ceph-node2 | 1028M | 4087M | 0 | 0 | 0 | 0 | exists,up |
| 5 | ceph-node2 | 1028M | 4087M | 0 | 0 | 0 | 0 | exists,up |
| 6 | ceph-node3 | 1028M | 4087M | 0 | 0 | 0 | 0 | exists,up |
| 7 | ceph-node3 | 1028M | 4087M | 0 | 0 | 0 | 0 | exists,up |
| 8 | ceph-node3 | 1028M | 4087M | 0 | 0 | 0 | 0 | exists,up |
+----+------------+-------+-------+--------+---------+--------+---------+-----------+
# ceph osd tree 也可以
[root@ceph-node1 ~]# ceph osd tree
ID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF
-1 0.04408 root default
-3 0.01469 host ceph-node1
0 hdd 0.00490 osd.0 up 1.00000 1.00000
1 hdd 0.00490 osd.1 up 1.00000 1.00000
2 hdd 0.00490 osd.2 up 1.00000 1.00000
-5 0.01469 host ceph-node2
3 hdd 0.00490 osd.3 up 1.00000 1.00000
4 hdd 0.00490 osd.4 up 1.00000 1.00000
5 hdd 0.00490 osd.5 up 1.00000 1.00000
-7 0.01469 host ceph-node3
6 hdd 0.00490 osd.6 up 1.00000 1.00000
7 hdd 0.00490 osd.7 up 1.00000 1.00000
8 hdd 0.00490 osd.8 up 1.00000 1.00000
# 這個是用來查看osd的disk free,類似linux的df
- `ID`: OSD的唯一標識符。
- `CLASS`: OSD的存儲類別。
- `WEIGHT`: OSD的權重。
- `REWEIGHT`: OSD的重新加權比例。
- `SIZE`: OSD的總存儲容量。
- `RAW USE`: OSD當前使用的原始存儲容量。
- `DATA`: OSD數據存儲使用量。
- `OMAP`: OSD的OMAP(Object Map)數據存儲使用量。
- `META`: OSD元數據存儲使用量。
- `AVAIL`: OSD可用的存儲容量。
- `%USE`: OSD使用率百分比。
- `VAR`: OSD使用率方差。
- `PGS`: OSD分佈的PG(Placement Group)數量。
- `STATUS`: OSD的狀態,"up"表示OSD正常運行。
[root@ceph-node1 ~]# ceph osd df
ID CLASS WEIGHT REWEIGHT SIZE USE DATA OMAP META AVAIL %USE VAR PGS
0 hdd 0.00490 1.00000 5.0 GiB 1.0 GiB 4.7 MiB 0 B 1 GiB 4.0 GiB 20.11 1.00 0
1 hdd 0.00490 1.00000 5.0 GiB 1.0 GiB 4.7 MiB 0 B 1 GiB 4.0 GiB 20.11 1.00 0
2 hdd 0.00490 1.00000 5.0 GiB 1.0 GiB 4.7 MiB 0 B 1 GiB 4.0 GiB 20.11 1.00 0
3 hdd 0.00490 1.00000 5.0 GiB 1.0 GiB 4.7 MiB 0 B 1 GiB 4.0 GiB 20.11 1.00 0
4 hdd 0.00490 1.00000 5.0 GiB 1.0 GiB 4.7 MiB 0 B 1 GiB 4.0 GiB 20.11 1.00 0
5 hdd 0.00490 1.00000 5.0 GiB 1.0 GiB 4.7 MiB 0 B 1 GiB 4.0 GiB 20.11 1.00 0
6 hdd 0.00490 1.00000 5.0 GiB 1.0 GiB 4.7 MiB 0 B 1 GiB 4.0 GiB 20.11 1.00 0
7 hdd 0.00490 1.00000 5.0 GiB 1.0 GiB 4.7 MiB 0 B 1 GiB 4.0 GiB 20.11 1.00 0
8 hdd 0.00490 1.00000 5.0 GiB 1.0 GiB 4.7 MiB 0 B 1 GiB 4.0 GiB 20.11 1.00 0
TOTAL 45 GiB 9.0 GiB 42 MiB 0 B 9 GiB 36 GiB 20.11
MIN/MAX VAR: 1.00/1.00 STDDEV: 0
將ceph-osd服務設置開機啟動
根據osd所在節點,添加對應的服務為開機啟動
# ceph-node1
systemctl enable ceph-osd@{0,1,2}
# ceph-node2
systemctl enable ceph-osd@{3,4,5}
# ceph-node3
systemctl enable ceph-osd@{6,7,8}
管理相關
從rados中移除osd
移除的時候,最好一個個移除,不然有可能性能跟不上,因為ceph自己去找其他osd的備份來作為主,一旦一次性刪除太多就可能出現性能問題。
# 停用osd
ceph osd out <osd-id>
# 停止osd服務
systemctl stop ceph-osd@<osd-id>
# 移除osd
ceph osd ourge <osd-id> --yes-i-really-mean-it
# 檢查ceph.conf集群配置文件中,是福哦還有對應osd的配置,如有則手動刪除、
###### Luminous 之前的版本,移除步驟如下 :
ceph osd crush remove <name>
ceph auth del osd <osd-id>
ceph osd rm <osd-id>
手動測試數據上傳、下載
# 通過rados創建pool
rados mkpool <pool-name> [123[ 4]] create pool <pool-name>'
[with auid 123[and using crush rule 4]]
# 通過ceph 命令創建pool
ceph osd pool create <poolname> <int[0-]> {<int[0-]>} {replicated|erasure} {<erasure_code_profile>} create pool
{<rule>} {<int>}
ceph osd pool create <pool名> <pg值> <pg備份值>
# 上傳文件到指定的pool
[ceph@ceph-deploy ceph-cluster-deploy]$ rados put myfile /etc/fstab -p swq-test
# 列出指定pool中的文件
[ceph@ceph-deploy ceph-cluster-deploy]$ rados ls -p swq-test
myfile
# 下載文件
[ceph@ceph-deploy ceph-cluster-deploy]$ rados get myfile -p swq-test /tmp/my.txt
[ceph@ceph-deploy ceph-cluster-deploy]$ cat /tmp/my.txt
#
# /etc/fstab
# Created by anaconda on Thu Dec 21 23:51:13 2023
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=4b1bb372-7f34-48f6-8852-036ee6dfd125 /boot
# 查看文件的映射關係
[ceph@ceph-deploy ceph-cluster-deploy]$ ceph osd map swq-test myfile
osdmap e43 pool 'swq-test' (2) object 'myfile' -> pg 2.423e92f7 (2.17) -> up ([5,6,2], p5) acting ([5,6,2], p5)
# 在哪個pg中?
# pg為2的423e92f7中。
# -> pg 2.423e92f7 (2.17)
# 在哪個osd中?
# 這裡是在5,6,2這3個osd中,主osd為:5
# acting是目前活動的osd
# -> up ([5,6,2], p5) acting ([5,6,2], p5)
本文來自博客園,作者:蕝戀,轉載請註明原文鏈接:https://www.cnblogs.com/juelian/p/17921681.html