当前位置:网站首页>ceph运维常用指令
ceph运维常用指令
2022-06-26 09:51:00 【波哥】
一、集群
1、启动一个ceph 进程
启动mon进程
service ceph start mon.node1
启动msd进程
service ceph start mds.node1
启动osd进程
service ceph start osd.0
2、查看机器的监控状态
[[email protected] ~]# ceph health
HEALTH_OK
3、查看ceph的实时运行状态
[[email protected] ~]# ceph -w
4、检查信息状态信息
[[email protected] ~]# ceph -s
5、查看ceph存储空间
[[email protected] ~]# ceph df
6、删除一个节点的所有的ceph数据包
[[email protected] ~]# ceph-deploy purge node1
[[email protected] ~]# ceph-deploy purgedata node1
7、为ceph创建一个admin用户并为admin用户创建一个密钥,把密钥保存到/etc/ceph目录下:
ceph auth get-or-create client.admin mds 'allow' osd 'allow *' mon 'allow *' > /etc/ceph/ceph.client.admin.keyring
或
ceph auth get-or-create client.admin mds 'allow' osd 'allow *' mon 'allow *' -o /etc/ceph/ceph.client.admin.keyring
8、为osd.0创建一个用户并创建一个key
ceph auth get-or-create osd.0 mon 'allow rwx' osd 'allow *' -o /var/lib/ceph/osd/ceph-0/keyring
9、为mds.node1创建一个用户并创建一个key
ceph auth get-or-create mds.node1 mon 'allow rwx' osd 'allow *' mds 'allow *' -o /var/lib/ceph/mds/ceph-node1/keyring
10、查看ceph集群中的认证用户及相关的key
ceph auth list
11、删除集群中的一个认证用户
ceph auth del osd.0
12、查看集群的详细配置
[[email protected] ~]# ceph daemon mon.node1 config show | less
13、查看集群健康状态细节
[[email protected] ~]# ceph health detail
14、查看ceph log日志所在的目录
[[email protected] ~]# ceph-conf --name mon.node1 --show-config-value log_file
二、mon
1、查看mon的状态信息
[[email protected] ~]# ceph mon stat
2、查看mon的选举状态
[[email protected] ~]# ceph quorum_status
3、查看mon的映射信息
[[email protected] ~]# ceph mon dump
4、删除一个mon节点
[[email protected] ~]# ceph mon remove node1
5、获得一个正在运行的mon map,为二进制mon.bin
[[email protected] ~]# ceph mon getmap -o mon.bin
6、查看上面获得的map
[[email protected] ~]# monmaptool --print mon.bin
[[email protected] ~]#
7、把上面的mon map注入新加入的节点
ceph-mon -i node4 --inject-monmap mon.bin
8、查看mon的amin socket
[email protected] ~]# ceph-conf --name mon.node1 --show-config-value admin_socket
9、查看mon的详细状态
[[email protected] ~]# ceph daemon mon.node1 mon_status
10、删除一个mon节点
[[email protected] ~]# ceph mon remove os-node1
三、msd
1、查看msd状态
[[email protected] ~]# ceph mds stat
2、查看msd的映射信息
[[email protected] ~]# ceph mds dump
3、删除一个mds节点
[[email protected] ~]# ceph mds rm 0 mds.node1
四、osd
1、查看ceph osd运行状态
[[email protected] ~]# ceph osd stat
2、查看osd映射信息
[[email protected] ~]# ceph osd dump
3、查看osd的目录树
[[email protected] ~]# ceph osd tree
4、down掉一个osd硬盘
[[email protected] ~]# ceph osd down 0 #down掉osd.0节点
5、在集群中删除一个osd硬盘
[[email protected] ~]# ceph osd rm 0
removed osd.0
6、在集群中删除一个osd 硬盘 crush map
[[email protected] ~]# ceph osd crush rm osd.0
7、在集群中删除一个osd的host节点
[[email protected] ~]# ceph osd crush rm node1
removed item id -2 name 'node1' from crush map
查看最大osd的个数
[[email protected] ~]# ceph osd getmaxosd
max_osd = 4 in epoch 514 #默认最大是4个osd节点
8、设置最大的osd的个数(当扩大osd节点的时候必须扩大这个值)
[[email protected] ~]# ceph osd setmaxosd 10
9、设置osd crush的权重为1.0
ceph osd crush set {id} {weight} [{loc1} [{loc2} ...]]
例如:
[[email protected] ~]# ceph osd crush set 3 3.0 host=node4
set item id 3 name 'osd.3' weight 3 at location {host=node4} to crush map
[[email protected] ~]# ceph osd tree
或者用下面的方式
[[email protected] ~]# ceph osd crush reweight osd.3 1.0
reweighted item id 3 name 'osd.3' to 1 in crush map
[[email protected] ~]# ceph osd tree
10、设置osd的权重
[[email protected] ~]# ceph osd reweight 3 0.5
11、把一个osd节点逐出集群
[[email protected] ~]# ceph osd out osd.3
12、把逐出的osd加入集群
[[email protected] ~]# ceph osd in osd.3
13、暂停osd (暂停后整个集群不再接收数据)
[[email protected] ~]# ceph osd pause
set pauserd,pausewr
14、再次开启osd (开启后再次接收数据)
[[email protected] ~]# ceph osd unpause
unset pauserd,pausewr
15、查看一个集群osd.2参数的配置
ceph --admin-daemon /var/run/ceph/ceph-osd.2.asok config show | less
16、如果osd坏了,进程还在的话
ceph tell osd.1740 bench #往osd.1740写数据,进程就会kill 自己了17、调整osd的恢复优先级
ceph daemon /var/run/ceph/ceph-osd.$id.asok config set osd_max_backfills 10五、PG组
1、1、查看pg组的映射信息
[[email protected] ~]# ceph pg dump
dumped all in format plain
version 1164
stamp 2014-06-30 00:48:29.754714
last_osdmap_epoch 88
last_pg_scan 73
full_ratio 0.95
nearfull_ratio 0.85
pg_stat objects mip degr unf bytes log disklog state state_stamp v reported up up_primary acting acting_primary last_scrub scrub_stamp last_deep_scrudeep_scrub_stamp
0.3f 39 0 0 0 163577856 128 128 active+clean 2014-06-30 00:30:59.193479 52'128 88:242 [0,2] 0 [0,2] 0 44'25 2014-06-29 22:25:25.282347 0'0 2014-06-26 19:52:08.521434
下面部分省略
2、查看一个PG的map
[[email protected] ~]# ceph pg map 0.3f
osdmap e88 pg 0.3f (0.3f) -> up [0,2] acting [0,2] #其中的[0,2]代表存储在osd.0、osd.2节点,osd.0代表主副本的存储位置
3、查看PG状态
[[email protected] ~]# ceph pg stat
v1164: 448 pgs: 448 active+clean; 10003 MB data, 23617 MB used, 37792 MB / 61410 MB avail
4、查询一个pg的详细信息
[[email protected] ~]# ceph pg 0.26 query
5、查看pg中stuck的状态
[[email protected] ~]# ceph pg dump_stuck unclean
ok
[[email protected] ~]# ceph pg dump_stuck inactive
ok
[[email protected] ~]# ceph pg dump_stuck stale
ok
6、显示一个集群中的所有的pg统计
ceph pg dump --format plain
7、恢复一个丢失的pg
ceph pg {pg-id} mark_unfound_lost revert
8、显示非正常状态的pg
ceph pg dump_stuck inactive|unclean|stale
六、pool
1、查看ceph集群中的pool数量
[[email protected] ~]# ceph osd lspools
0 data,1 metadata,2 rbd,
2、在ceph集群中创建一个pool
ceph osd pool create jiayuan 100 #这里的100指的是PG组
3、为一个ceph pool配置配额
ceph osd pool set-quota data max_objects 10000
4、在集群中删除一个pool
ceph osd pool delete testpool testpool --yes-i-really-really-mean-it #集群名字需要重复两次
5、显示集群中pool的详细信息
[[email protected] ~]# rados df
[[email protected] ~]#
6、给一个pool创建一个快照
[[email protected] ~]# ceph osd pool mksnap data date-snap
created pool data snap date-snap
7、删除pool的快照
[[email protected] ~]# ceph osd pool rmsnap data data-snap
removed pool data snap date-snap
8、查看data池的pg数量
[[email protected] ~]# ceph osd pool get data pg_num
pg_num: 64
9、设置data池的最大存储空间为100T(默认是1T)
[[email protected] ~]# ceph osd pool set data target_max_bytes 100000000000000
set pool 0 target_max_bytes to 100000000000000
10、设置data池的副本数是3
[[email protected] ~]# ceph osd pool set data size 3
set pool 0 size to 3
11、设置data池能接受写操作的最小副本为2
[[email protected] ~]# ceph osd pool set data min_size 2
set pool 0 min_size to 2
12、查看集群中所有pool的副本尺寸
[[email protected] mycephfs]# ceph osd dump | grep 'replicated size'
pool 2 'rbd' replicated size 2 min_size 1 crush_ruleset 0 object_hash rjenkins pg_num 64 pgp_num 64 last_change 1 owner 0 flags hashpspool stripe_width 0
13、设置一个pool的pg数量
[[email protected] ~]# ceph osd pool set data pg_num 100
set pool 0 pg_num to 100
14、设置一个pool的pgp数量
[[email protected] ~]# ceph osd pool set data pgp_num 100
set pool 0 pgp_num to 100
七、rados和rbd指令
1、rados命令使用方法
(1)、查看ceph集群中有多少个pool (只是查看pool)
[[email protected] ~]# rados lspools
(2)、查看ceph集群中有多少个pool,并且每个pool容量及利用情况
[[email protected] ~]# rados df
(3)、创建一个pool
[[email protected] ~]#rados mkpool test
(4)、查看ceph pool中的ceph object (这里的object是以块形式存储的)
[[email protected] ~]# rados ls -p volumes | less
rbd_data.348f21ba7021.0000000000000866
rbd_data.32562ae8944a.0000000000000c79
(5)、创建一个对象object
[[email protected] ~]# rados create test-object -p test
[[email protected] ~]# rados -p test ls
test-object
(6)、删除一个对象
[[email protected] ~]# rados rm test-object-1 -p test
2、rbd命令的用法
(1)、查看ceph中一个pool里的所有镜像
[[email protected] ~]# rbd ls volumes
(2)、查看ceph pool中一个镜像的信息
[[email protected] ~]# rbd info -p images --image test
(3)、在test池中创建一个命名为test2的10000M的镜像
[[email protected] ~]# rbd create -p test --size 10000 test2
(4)、删除一个镜像
[[email protected] ~]# rbd rm -p test test2
(5)、调整一个镜像的尺寸
[[email protected] ~]# rbd resize -p test --size 20000 test3
Resizing image: 100% complete...done.
(6)、给一个镜像创建一个快照
[[email protected] ~]# rbd snap create test/[email protected] #池/镜像@快照
[[email protected] ~]# rbd snap ls -p test test3
[[email protected] ~]#
[[email protected] ~]# rbd info test/[email protected]
(7)、查看一个镜像文件的快照
[[email protected] ~]# rbd snap ls -p volumes test
(8)、删除一个镜像文件的一个快照快照
快照所在的池/ 快照所在的镜像文件 @ 快照
[[email protected] ~]# rbd snap rm volumes/[email protected]
2014-08-18 19:23:42.099301 7fd0245ef760 -1 librbd: removing snapshot from header failed: (16) Device or resource busy
上面不能删除显示的报错信息是此快照备写保护了,下面命令是删除写保护后再进行删除。
[[email protected] ~]# rbd snap unprotect volumes/[email protected]
[[email protected] ~]# rbd snap rm volumes/[email protected]
(9)删除一个镜像文件的所有快照
[[email protected] ~]# rbd snap purge -p volumes test3
Removing all snapshots: 100% complete...done.
(10)、把ceph pool中的一个镜像导出
导出镜像
[[email protected] ~]# rbd export -p images --image test
2014-05-24 17:16:15.197695 7ffb47a9a700 0 -- :/1020493 >> 10.49.101.9:6789/0 pipe(0x1368400 sd=3 :0 s=1 pgs=0 cs=0 l=1 c=0x1368660).fault
Exporting image: 100% complete...done.
导出云硬盘
[[email protected] ~]# rbd export -p volumes --image volume-470fee37-b950-4eef-a595-d7def334a5d6 /var/lib/glance/ceph-pool/volumes/test-10.40.212.24
2014-05-24 17:28:18.940402 7f14ad39f700 0 -- :/1032237 >> 10.49.101.9:6789/0 pipe(0x260a400 sd=3 :0 s=1 pgs=0 cs=0 l=1 c=0x260a660).fault
Exporting image: 100% complete...done.
(11)、把一个镜像导入ceph中 (但是直接导入是不能用的,因为没有经过openstack,openstack是看不到的)
[[email protected] ~]# rbd import /root/aaa.img -p images --image 74cb427c-cee9-47d0-b467-af217a67e60a
Importing image: 100% complete...done.
边栏推荐
- June training (the 26th day) - collective search
- 挖财商学院证券开户安全嘛?
- 磁带库简单记录1
- [software project management] sorting out knowledge points for final review
- 利用foreach循环二维数组
- The fourteenth MySQL operation - e-mall project
- Global and Chinese market for change and configuration management software 2022-2028: Research Report on technology, participants, trends, market size and share
- Blog post index summary --c #
- How QT uses quazip to compress and decompress files
- MySQL Chapter 5 Summary
猜你喜欢

MySQL第十三次作业-事务管理

DBSCAN

MySQL job 11 - application de la vue

Vscode environment setup: synchronous configuration

Hcia-dhcp experiment

What is in the method area - class file, class file constant pool, runtime constant pool

MySQL第十四次作业--电子商城项目

MySQL第十一作業-視圖的應用

Which PHP open source works deserve attention

Small example of SSM project, detailed tutorial of SSM integration
随机推荐
Call API interface to generate QR code of wechat applet with different colors
Using reflection to export entity data to excel
Procedure Call Standard
How QT uses quazip to compress and decompress files
About multi table query of MySQL
Small example of SSM project, detailed tutorial of SSM integration
Redis (IV) redis association table caching
Progressive Web 应用程序PWA是应用程序开发的未来
基础-MySQL
[software project management] sorting out knowledge points for final review
MySQL第八次作业
CentOS installs redis multi master multi slave cluster
[binary search] 4 Find the median of two positive arrays
Installer MySQL sous Linux [détails]
Flutter与原生通信(上)
RDB持久化验证测试
Search engine advanced search method records
35 qlineedit control synthesis example
Notes - simple but adequate series_ KVM quick start
Global and Chinese market for change and configuration management software 2022-2028: Research Report on technology, participants, trends, market size and share