前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ceph相关命令汇总

ceph相关命令汇总

作者头像
summerking
发布2022-09-16 12:13:18
9560
发布2022-09-16 12:13:18
举报
文章被收录于专栏:summerking的专栏

# pool

# 创建池

  • 创建副本池
代码语言:javascript
复制
root@Kylin:/sys# ceph osd pool create rbd_pool 1024 1024
pool 'rbd_pool' created
root@Kylin:/sys# ceph osd pool set rbd_pool  size 3
set pool 9 size to 3
root@Kylin:/sys#

  • 创建纠删池
代码语言:javascript
复制
root@Kylin:/sys# ceph osd erasure-code-profile set test_file k=2 m=1 plugin=jerasure ruleset-failure-domain=host technique=reed_sol_van
root@Kylin:/sys# ceph osd pool create bp_ec_pool 1024 1024 erasure test_file 
pool 'bp_ec_pool' created
root@Kylin:/sys# ceph osd erasure-code-profile get test_file
directory=/usr/lib/ceph/erasure-code
k=2
m=1
plugin=jerasure
ruleset-failure-domain=host
technique=reed_sol_van
root@Kylin:/sys# ceph osd erasure-code-profile rm test_file

# 修改池

代码语言:javascript
复制
root@Kylin:/sys# ceph osd pool get testrbd size
size: 2
root@Kylin:/sys# ceph osd pool set testrbd size 3
set pool 5 size to 3
root@Kylin:/sys# ceph osd pool get testrbd size
size: 3

# 查看池

代码语言:javascript
复制
root@Kylin:/sys# ceph osd dump | grep pool
pool 1 'summer60sys000' replicated size 2 min_size 1 crush_ruleset 1 object_hash rjenkins pg_num 256 pgp_num 256 last_change 490 flags hashpspool crash_replay_interval 45 stripe_width 0
pool 3 'summer38-fec-691852341313819928811' erasure size 4 min_size 3 crush_ruleset 2 object_hash rjenkins pg_num 1024 pgp_num 1024 last_change 500 flags hashpspool stripe_width 12288
pool 5 'testrbd' replicated size 3 min_size 1 crush_ruleset 0 object_hash rjenkins pg_num 1024 pgp_num 1024 last_change 509 flags hashpspool stripe_width 0
root@Kylin:/sys# rados lspools
summer60sys000
summer38-fec-691852341313819928811
testrbd
root@Kylin:/sys# rados df
pool name                 KB      objects       clones     degraded      unfound           rd        rd KB           wr        wr KB
summer38-fec-691852341313819928811  63550735361     15515418            0            0           0       646239     18030316     16363738  63882405016
summer60sys000        61302         1535            0            0           0       298021      2242450       296434      2252475
testrbd                    0            0            0            0           0            0            0            0            0
  total used     86041904154     15516953
  total avail   267288605958
  total space   372084556416
root@Kylin:/sys# ceph osd pool ls
summer60sys000
summer38-fec-691852341313819928811
testrbd
root@Kylin:/sys# ceph osd lspools
1 summer60sys000,3 summer38-fec-691852341313819928811,5 testrbd,

# 压缩池

代码语言:javascript
复制
root@Kylin:/sys# ceph osd pool set testrbd compress true
set pool 5 compress to true
root@Kylin:/sys# ceph osd pool get testrbd compress
compress: true
root@Kylin:/sys#

# 加密池

代码语言:javascript
复制
root@Kylin:/sys# ceph osd pool set testrbd crypt true
set pool 5 crypt to true
root@Kylin:/sys# ceph osd pool get testrbd crypt 
crypt: true
root@Kylin:/sys#

# 配额池

代码语言:javascript
复制
root@Kylin:/sys# ceph osd pool set-quota rbd_pool max_bytes 2097152000
set-quota max_bytes = 2097152000 for pool rbd_pool
root@Kylin:/sys# ceph osd pool get-quota rbd_pool 
quotas for pool 'rbd_pool':
  max objects: N/A
  max bytes  : 2000MB

# 删除池

代码语言:javascript
复制
root@Kylin:/sys# ceph osd pool delete test2rbd test2rbd  --yes-i-really-really-mean-it
pool 'test2rbd' removed

# 块设备

# 创建快设备

代码语言:javascript
复制
root@Kylin:/sys# rbd create --size 10240 testrbd/creatrbd
root@Kylin:/sys# rbd -p testrbd ls
creatrbd
root@Kylin:/sys# rbd ls testrbd
creatrbd

# 扩容块设备

代码语言:javascript
复制
root@Kylin:/sys# rbd info testrbd/creatrbd
rbd image 'creatrbd':
        size 10240 MB in 2560 objects
        order 22 (4096 kB objects)
        block_name_prefix: rbd_data.28d5f6b8b4567
        format: 2
        timestamp: 2021-05-13 09:27:32
        features: layering
        flags: 
root@Kylin:/sys# rbd resize --size 20480 testrbd/creatrbd
Resizing image: 100% complete...done.
root@Kylin:/sys# rbd info testrbd/creatrbd
rbd image 'creatrbd':
        size 20480 MB in 5120 objects
        order 22 (4096 kB objects)
        block_name_prefix: rbd_data.28d5f6b8b4567
        format: 2
        timestamp: 2021-05-13 09:27:32
        features: layering
        flags: 

# 移动块设备

  • 例子:将池testrbd中的块creatrbd移动到池test2rbd
代码语言:javascript
复制
root@Kylin:/sys# rados lspools
summer60sys000
summer38-fec-691852341313819928811
testrbd
test2rbd

代码语言:javascript
复制
root@Kylin:/sys# rbd ls testrbd
creatrbd
root@Kylin:/sys# rbd ls test2rbd
root@Kylin:/sys# 
root@Kylin:/sys# rbd snap ls testrbd/creatrbd
SNAPID NAME             SIZE 
     2 snapcreatrbd 20480 MB 

代码语言:javascript
复制
root@Kylin:/sys# rbd clone testrbd/creatrbd@snapcreatrbd test2rbd/creatrbd
2021-05-13 09:37:22.310112 ffff93209280 -1 librbd: parent snapshot must be protected
rbd: clone error: (22) Invalid argument
root@Kylin:/sys# rbd snap protect testrbd/creatrbd@snapcreatrbd
root@Kylin:/sys# rbd clone testrbd/creatrbd@snapcreatrbd test2rbd/creatrbd
root@Kylin:/sys# rbd ls testrbd
creatrbd
root@Kylin:/sys# rbd ls test2rbd
creatrbd
root@Kylin:/sys# 

# 查看块设备

代码语言:javascript
复制
root@Kylin:/sys# rbd info testrbd/creatrbd
rbd image 'creatrbd':
        size 20480 MB in 5120 objects
        order 22 (4096 kB objects)
        block_name_prefix: rbd_data.28d5f6b8b4567
        format: 2
        timestamp: 2021-05-13 09:27:32
        features: layering
        flags: 

# 使用块设备

# map映射
# 映射rbd到本地客户端
代码语言:javascript
复制
root@Kylin:/sys# rbd map --image testrbd/creatrbd
/dev/cephrbd0
root@Kylin:/sys# rbd showmapped
id pool    image    snap device        
0  testrbd creatrbd -    /dev/cephrbd0 
root@Kylin:/sys# 

# 直接lsblk查看
代码语言:javascript
复制
root@Kylin:/sys# lsblk | grep cephrbd0
cephrbd0 252:0    0    20G  0 disk 

# 格式化该设备
代码语言:javascript
复制
root@Kylin:/sys# mkfs.xfs /dev/cephrbd0 
meta-data=/dev/cephrbd0          isize=512    agcount=17, agsize=326656 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=4096   blocks=5242880, imaxpct=25
         =                       sunit=1024   swidth=1024 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=8 blks, lazy-count=1
realtime =无                    extsz=4096   blocks=0, rtextents=0

# 挂载该设备
代码语言:javascript
复制
root@Kylin:/sys# mkdir /rbdtest
root@Kylin:/sys# mount /dev/cephrbd0 /rbdtest/
root@Kylin:/sys# df -h | grep rbd
/dev/cephrbd0    20G   33M   20G    1% /rbdtest
root@Kylin:/sys# 

# 卸载并取消块设备映射
代码语言:javascript
复制
root@Kylin:/sys# umount -l /rbdtest/
root@Kylin:/sys# rbd unmap /dev/rbd/testrbd/creatrbd
root@Kylin:/sys# rbd showmapped
root@Kylin:/sys# 

# iscsi映射
# 新建tgt
代码语言:javascript
复制
root@Kylin:/sys# tgtadm --lld iscsi --mode target --op new --tid 2 --targetname iqn.2021-05.com.919:192.168.88.105.sn.84736ec1e9db9037c6b1a32
root@Kylin:/sys# tgtadm -L iscsi -m target -o show | grep 'Target 2'
Target 2: iqn.2021-05.com.919:192.168.88.105.sn.84736ec1e9db9037c6b1a32

# 绑定rbd
代码语言:javascript
复制
root@Kylin:/sys# tgtadm -L iscsi -m logicalunit -o new -t 2 -l 1 -b testrbd/creatrbd --bstype rbd

# 授权所有
代码语言:javascript
复制
root@Kylin:/sys# tgtadm -L iscsi -m target -o bind -t 2 -I ALL

# 查看tgt
代码语言:javascript
复制
root@Kylin:/sys# tgtadm -L iscsi -m target -o show
...
Target 2: iqn.2021-05.com.919:192.168.88.105.sn.84736ec1e9db9037c6b1a32
    System information:
        Driver: iscsi
        State: ready
    I_T nexus information:
    LUN information:
        LUN: 0
            Type: controller
            SCSI ID: IET     00020000
            SCSI SN: beaf20
            Size: 0 MB, Block size: 1
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            SWP: No
            Thin-provisioning: No
            Backing store type: null
            Backing store path: None
            Backing store flags: 
        LUN: 1
            Type: disk
            SCSI ID: IET     00020001
            SCSI SN: beaf21
            Size: 21475 MB, Block size: 512
            Online: Yes
            Removable media: No
            Prevent removal: No
            Readonly: No
            SWP: No
            Thin-provisioning: No
            Backing store type: rbd
            Backing store path: testrbd/creatrbd
            Backing store flags: 
    Account information:
    ACL information:
        ALL

# 发现tgt
代码语言:javascript
复制
root in iscloud163-200 in ~ via 🐍 v2.7.5 
➜ iscsiadm -m discovery -t st -p 192.168.88.105:3260
192.168.88.105:3260,1 iqn.2021-05.com.015:192.168.88.sn.163cbb414ff35ad401c995bb
192.168.88.105:3260,1 iqn.2021-05.com.919:192.168.88.105.sn.84736ec1e9db9037c6b1a32
root in iscloud163-200 in ~ via 🐍 v2.7.5 
➜

1 2 3 4 5 6

# 删除块设备

  • 块信息
代码语言:javascript
复制
root@Kylin:/sys# rbd ls test2rbd
creatrbd
root@Kylin:/sys# rbd info test2rbd/creatrbd
rbd image 'creatrbd':
        size 20480 MB in 5120 objects
        order 22 (4096 kB objects)
        block_name_prefix: rbd_data.28d936b8b4567
        format: 2
        timestamp: 2021-05-13 09:38:02
        features: layering
        flags: 
        parent: testrbd/creatrbd@snapcreatrbd
        overlap: 20480 MB

  • 步骤
  1. 重命名
代码语言:javascript
复制
root@Kylin:/sys# rbd rename test2rbd/creatrbd test2rbd/creatrbd-del
  1. 查看快照
代码语言:javascript
复制
root@Kylin:/sys# rbd snap ls test2rbd/creatrbd
2021-05-13 09:54:49.068213 ffff83e99280 -1 librbd::ImageCtx: error finding header: (2) No such file or directory
rbd: error opening image creatrbd: (2) No such file or directory
  1. 查看block_name_prefix
代码语言:javascript
复制
root@Kylin:/sys# rbd -p test2rbd info creatrbd-del | /bin/grep  block_name_prefix | /usr/bin/awk  -F. '{print $2}'
28d936b8b4567
  1. 删除对象名称
代码语言:javascript
复制
root@Kylin:/sys# rados -p test2rbd rm rbd_id.creatrbd-del
root@Kylin:/sys# rados -p test2rbd rm rbd_header.28d936b8b4567
  1. 从对象名称的对象图中删除键
代码语言:javascript
复制
root@Kylin:/sys# rados -p test2rbd rmomapkey rbd_directory id_28d936b8b4567
root@Kylin:/sys# rados -p test2rbd rmomapkey rbd_directory name_creatrbd-del
  • 删除到回收站
  • rbd -h 没有trash命令?
代码语言:javascript
复制
root@Kylin:/sys# rbd ls testrbd
creatrbd
root@Kylin:/sys# rbd trash move creatrbd -p testrbd
rbd: error parsing command 'trash'; -h or --help for usage

# 快照

# 创建快照
代码语言:javascript
复制
root@Kylin:/sys# rbd ls testrbd
creatrbd
newcreatrbd
root@Kylin:/sys# rbd snap create --snap creatrbdsnap testrbd/creatrbd
root@Kylin:/sys# rbd snap create --snap creatrbdsnap2 testrbd/creatrbd
root@Kylin:/sys# rbd snap create --snap creatrbdsnap3 testrbd/creatrbd
root@Kylin:/sys# 

# 查看快照
代码语言:javascript
复制
root@Kylin:/sys# rbd snap ls testrbd/creatrbd
SNAPID NAME              SIZE 
     4 creatrbdsnap  20480 MB 
     5 creatrbdsnap2 20480 MB 
     6 creatrbdsnap3 20480 MB 

# 保护快照
代码语言:javascript
复制
root@Kylin:/sys# rbd snap protect testrbd/creatrbd@snapcreatrbd

# 克隆快照
代码语言:javascript
复制
root@Kylin:/sys# rbd ls testrbd
creatrbd
root@Kylin:/sys# rbd snap ls testrbd/creatrbd
SNAPID NAME             SIZE 
     2 snapcreatrbd 20480 MB 
root@Kylin:/sys# rbd clone testrbd/creatrbd@snapcreatrbd testrbd/newcreatrbd
root@Kylin:/sys# rbd ls testrbd
creatrbd
newcreatrbd
root@Kylin:/sys# 

# 拍平克隆映像
代码语言:javascript
复制
root@Kylin:/sys# rbd flatten testrbd/newcreatrbd
Image flatten: 100% complete...done.

# 取消快照保护
代码语言:javascript
复制
root@Kylin:/sys# rbd snap unprotect testrbd/creatrbd@snapcreatrbd

# 回滚快照
代码语言:javascript
复制
root@Kylin:/sys# rbd snap ls testrbd/creatrbd
SNAPID NAME             SIZE 
     2 snapcreatrbd 20480 MB 
root@Kylin:/sys# rbd snap rollback testrbd/creatrbd@snapcreatrbd
Rolling back to snapshot: 100% complete...done.

# 删除快照
代码语言:javascript
复制
root@Kylin:/sys# rbd snap rm testrbd/creatrbd@snapcreatrbd

# 清除所有快照
代码语言:javascript
复制
root@Kylin:/sys# rbd snap ls testrbd/creatrbd
SNAPID NAME              SIZE 
     4 creatrbdsnap  20480 MB 
     5 creatrbdsnap2 20480 MB 
     6 creatrbdsnap3 20480 MB 
root@Kylin:/sys# rbd snap purge testrbd/creatrbd
Removing all snapshots: 100% complete...done.
root@Kylin:/sys# rbd snap ls testrbd/creatrbd

# 对象

# 用户

# 创建用户
代码语言:javascript
复制
root@Kylin:/sys# radosgw-admin user create --uid="summerKing" --display-name="summerKing" --access-key=q88888888
{
    "user_id": "summerKing",
    "display_name": "summerKing",
    "email": "",
    "suspended": 0,
    "max_buckets": 1000,
    "auid": 0,
    "subusers": [],
    "keys": [
        {
            "user": "summerKing",
            "access_key": "q88888888",
            "secret_key": "jTn1W0yrqWEKvVMzOUepDC0SikKfUXtJxZhIcJRX"
        }
    ],
    "swift_keys": [],
    "caps": [],
    "op_mask": "read, write, delete",
    "default_placement": "",
    "placement_tags": [],
    "bucket_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": -1,
        "max_size_kb": -1,
        "max_objects": -1
    },
    "user_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": -1,
        "max_size_kb": -1,
        "max_objects": -1
    },
    "temp_url_keys": [],
    "mfa_ids": []
}

root@Kylin:/sys# 

# 查看所有用户user
代码语言:javascript
复制
root@Kylin:/sys# radosgw-admin metadata list user
[

    "summerKing"

]

# 查看用户详情
代码语言:javascript
复制
root@Kylin:/sys# radosgw-admin user info --uid=summerKing
{
    "user_id": "summerKing",
    "display_name": "summerKing",
    "email": "",
    "suspended": 0,
    "max_buckets": 1000,
    "auid": 0,
    "subusers": [],
    "keys": [
        {
            "user": "summerKing",
            "access_key": "q88888888",
            "secret_key": "jTn1W0yrqWEKvVMzOUepDC0SikKfUXtJxZhIcJRX"
        }
    ],
    "swift_keys": [],
    "caps": [],
    "op_mask": "read, write, delete",
    "default_placement": "",
    "placement_tags": [],
    "bucket_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": -1,
        "max_size_kb": -1,
        "max_objects": -1
    },
    "user_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": -1,
        "max_size_kb": -1,
        "max_objects": -1
    },
    "temp_url_keys": [],
    "mfa_ids": []
}

# 修改用户信息
代码语言:javascript
复制
root@Kylin:/sys# radosgw-admin user modify --uid=summerKing --display-name="xswgogogo" --email=1111111@qq.com
{
    "user_id": "summerKing",
    "display_name": "xswgogogo",
    "email": "1111111@qq.com",
    "suspended": 0,
    "max_buckets": 1000,
    "auid": 0,
    "subusers": [],
    "keys": [
        {
            "user": "summerKing",
            "access_key": "q88888888",
            "secret_key": "jTn1W0yrqWEKvVMzOUepDC0SikKfUXtJxZhIcJRX"
        }
    ],
    "swift_keys": [],
    "caps": [],
    "op_mask": "read, write, delete",
    "default_placement": "",
    "placement_tags": [],
    "bucket_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": -1,
        "max_size_kb": -1,
        "max_objects": -1
    },
    "user_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": -1,
        "max_size_kb": -1,
        "max_objects": -1
    },
    "temp_url_keys": [],
    "mfa_ids": []
}

# 删除用户
代码语言:javascript
复制
root@Kylin:/sys# radosgw-admin user rm --uid=summerKing

1

# 设置用户配额
代码语言:javascript
复制
root@Kylin:/sys# radosgw-admin quota set --quota-scope=user --uid=xsw --max-objects=10240 --max-size=10240
root@Kylin:/sys# radosgw-admin user info --uid=xsw 
{
    "user_id": "xsw",
    "display_name": "xswlalala",
    "email": "",
    "suspended": 0,
    "max_buckets": 1000,
    "auid": 0,
    "subusers": [],
    "keys": [
        {
            "user": "xsw",
            "access_key": "q88888888",
            "secret_key": "Q7ToQSqlSiECUq63SIia4evfkAkJG5TGxqr2Wacy"
        }
    ],
    "swift_keys": [],
    "caps": [],
    "op_mask": "read, write, delete",
    "default_placement": "",
    "placement_tags": [],
    "bucket_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": -1,
        "max_size_kb": -1,
        "max_objects": -1
    },
    "user_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": 10240,
        "max_size_kb": 10,
        "max_objects": 10240
    },
    "temp_url_keys": [],
    "mfa_ids": []
}

# 启用用户配额
代码语言:javascript
复制
root@Kylin:/sys# radosgw-admin quota enable --quota-scope=user --uid=xsw
root@Kylin:/sys# radosgw-admin user info --uid=xsw 
{
    "user_id": "xsw",
    "display_name": "xswlalala",
    "email": "",
    "suspended": 0,
    "max_buckets": 1000,
    "auid": 0,
    "subusers": [],
    "keys": [
        {
            "user": "xsw",
            "access_key": "q88888888",
            "secret_key": "Q7ToQSqlSiECUq63SIia4evfkAkJG5TGxqr2Wacy"
        }
    ],
    "swift_keys": [],
    "caps": [],
    "op_mask": "read, write, delete",
    "default_placement": "",
    "placement_tags": [],
    "bucket_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": -1,
        "max_size_kb": -1,
        "max_objects": -1
    },
    "user_quota": {
        "enabled": true,
        "check_on_raw": false,
        "max_size": 10240,
        "max_size_kb": 10,
        "max_objects": 10240
    },
    "temp_url_keys": [],
    "mfa_ids": []
}

# bucket

# 查看系统用所有bucket
代码语言:javascript
复制
root@Kylin:/sys# radosgw-admin metadata list bucket
[

    "bkt"

]

1 2 3 4 5 6

# 查看bucket的配额
代码语言:javascript
复制
root@Kylin:/sys# radosgw-admin bucket stats --bucket=bkt
{
    "bucket": "bkt",
    "tenant": "",
    "pool": "summer60sys000",
    "index_pool": "summer60sys000",
    "id": "default.170839.1",
    "marker": "default.170839.1",
    "owner": "test",
    "seconds_upload": false,
    "multi_version": false,
    "append_write": false,
    "ver": "0#1,1#1,2#1,3#1",
    "master_ver": "0#0,1#0,2#0,3#0",
    "mtime": "2021-05-13 11:39:43.000000",
    "max_marker": "0#,1#,2#,3#",
    "usage": {},
    "bucket_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": -1,
        "max_size_kb": -1,
        "max_objects": -1
    }
}

# 查看用户已消耗的配额
代码语言:javascript
复制
root@Kylin:/sys# radosgw-admin user stats --uid=test
{
    "stats": {
        "total_entries": 0,
        "total_bytes": 0,
        "total_bytes_rounded": 0
    },
    "last_stats_sync": "0.000000",
    "last_stats_update": "2021-05-13 03:39:43.033283Z"
}

# 设置桶配额
代码语言:javascript
复制
root@Kylin:/sys# radosgw-admin quota set --uid=test --quota-scope=bucket --max-objects=20480 --max-size=20480
root@Kylin:/sys# radosgw-admin user info --uid=test
{
    "user_id": "test",
    "display_name": "test",
    "email": "asdasd@qq.com",
    "suspended": 0,
    "max_buckets": 1000,
    "auid": 0,
    "subusers": [],
    "keys": [
        {
            "user": "test",
            "access_key": "q1234567",
            "secret_key": "q1234567"
        }
    ],
    "swift_keys": [],
    "caps": [],
    "op_mask": "read, write, delete",
    "default_placement": "",
    "placement_tags": [],
    "bucket_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": 20480,
        "max_size_kb": 20,
        "max_objects": 20480
    },
    "user_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": -1,
        "max_size_kb": -1,
        "max_objects": -1
    },
    "temp_url_keys": [],
    "mfa_ids": []
}

# 启动桶配额
代码语言:javascript
复制
root@Kylin:/sys# radosgw-admin quota enable --quota-scope=bucket --uid=test
root@Kylin:/sys# radosgw-admin user info --uid=test
{
    "user_id": "test",
    "display_name": "test",
    "email": "asdasd@qq.com",
    "suspended": 0,
    "max_buckets": 1000,
    "auid": 0,
    "subusers": [],
    "keys": [
        {
            "user": "test",
            "access_key": "q1234567",
            "secret_key": "q1234567"
        }
    ],
    "swift_keys": [],
    "caps": [],
    "op_mask": "read, write, delete",
    "default_placement": "",
    "placement_tags": [],
    "bucket_quota": {
        "enabled": true,
        "check_on_raw": false,
        "max_size": 20480,
        "max_size_kb": 20,
        "max_objects": 20480
    },
    "user_quota": {
        "enabled": false,
        "check_on_raw": false,
        "max_size": -1,
        "max_size_kb": -1,
        "max_objects": -1
    },
    "temp_url_keys": [],
    "mfa_ids": []
}

# s3cmd使用

  • 使用s3cmd连接FT平台的对象服务(s3cmd --configure
# 创建桶
代码语言:javascript
复制
root in iscloud150-11 in ~ via 🐍 v2.7.5 took 1m9s 
➜ s3cmd mb s3://test-bucket
Bucket 's3://test-bucket/' created

1 2 3

# 删除桶
  • 删除空桶
代码语言:javascript
复制
root in iscloud150-11 in ~ via 🐍 v2.7.5 
➜ s3cmd rb s3://test-bucket
Bucket 's3://test-bucket/' removed

1 2 3

# 上传文件至桶
代码语言:javascript
复制
root in iscloud150-11 in ~ via 🐍 v2.7.5 
➜ s3cmd mb s3://test-bucket
Bucket 's3://test-bucket/' created
root in iscloud150-11 in ~ via 🐍 v2.7.5 
➜ s3cmd put s3test.py s3://test-bucket
upload: 's3test.py' -> 's3://test-bucket/s3test.py'  [1 of 1]
 516 of 516   100% in    0s     7.95 KB/s  done

# 下载文件到本地
代码语言:javascript
复制
root in iscloud150-11 in /home 
➜ s3cmd get  s3://test-bucket/s3test.py
download: 's3://test-bucket/s3test.py' -> './s3test.py'  [1 of 1]
 516 of 516   100% in    0s    11.55 KB/s  done

# 删除桶里的文件
代码语言:javascript
复制
root in iscloud150-11 in /home via 🐍 v2.7.5 
➜ s3cmd ls  s3://test-bucket
2021-05-13 05:48          516  s3://test-bucket/s3test.py
root in iscloud150-11 in /home via 🐍 v2.7.5 
➜ s3cmd del  s3://test-bucket/s3test.py
delete: 's3://test-bucket/s3test.py'
root in iscloud150-11 in /home via 🐍 v2.7.5 

# 补充

# 本地权限

  • 修改主用户为:testone
  • 修改主用户组为:test-dir
  • 权限:

用户

其他

读,执行

读,执行

代码语言:javascript
复制
root@Kylin:/tmp/test# ll | grep worm_test/
drwxr-xr-x 1 root root          0 May 14 11:28 worm_test/
root@Kylin:/tmp/test# chgrp test-dir worm_test/
root@Kylin:/tmp/test# chown testone worm_test/
root@Kylin:/tmp/test# chmod 525 worm_test/
root@Kylin:/tmp/test# ll | grep worm_test/
dr-x-w-r-x 1 testone test-dir          0 May 14 11:28 worm_test/
root@Kylin:/tmp/test#

# 访问控制

  • 初始状态testfile文件没有ACL的额外属性
代码语言:javascript
复制
总用量 1024004
drw-r---w- 1 root root 1048576000 May 14 13:49 ./
drwxrwxrwt 9 root root       4096 May 14 14:19 ../
-rw-r--r-- 1 root root 1048576000 May 14 13:49 testfile
dr-xrw-r-x 1 root root          0 May 14 11:28 worm_test/
root@Kylin:/tmp/test# getfacl testfile 
# file: testfile
# owner: root
# group: root
user::rw-
group::r--
other::r--

  • 使testone用户拥有对testfile文件的读写权限
  • 使test-dir组拥有对testfile文件读权限
代码语言:javascript
复制
root@Kylin:/tmp/test# setfacl -m u:testone:rw testfile 
root@Kylin:/tmp/test# setfacl -m g:test-dir:r testfile 
root@Kylin:/tmp/test# getfacl -c testfile 
user::rw-
user:testone:rw-
group::r--
group:test-dir:r--
mask::rw-
other::r--

# 用户(组)配额

# 增加用户组
代码语言:javascript
复制
root@Kylin:/home/hci_sysadmin# groupadd gptest -g 1509

1

# 增加用户
代码语言:javascript
复制
root@Kylin:/home/hci_sysadmin# useradd utest -u 1509 -s /bin//bash  -c "don't remove" -G gptest
root@Kylin:/home/hci_sysadmin# id utest
uid=1509(utest) gid=1510(utest) 组=1510(utest),1509(gptest)
root@Kylin:/home/hci_sysadmin#

# 配置用户配额
代码语言:javascript
复制
root@Kylin:/home/hci_sysadmin# mkdir  -p /tmp/test
root@Kylin:/home/hci_sysadmin# chmod 755 /tmp/test
root@Kylin:/home/hci_sysadmin# mount  -t ceph 88.88.88.101,88.88.88.102,88.88.88.103:'/summer38-fec-691852341313819928811/vr/test-permissions'  '/tmp/test' -o readdir_max_bytes=4194304,readdir_max_entries=8192,rasize=134217728,noatime,wr_inflight_limit=9371,pool_id=3

# 配置用户文件数配额
代码语言:javascript
复制
root@Kylin:/home/hci_sysadmin# setfattr  -n user.file.used.1509 -v 0 /tmp/test
root@Kylin:/home/hci_sysadmin# setfattr  -n user.file.total.1509 -v 100 /tmp/test

# 配置用户容量配额
代码语言:javascript
复制
root@Kylin:/home/hci_sysadmin# setfattr  -n user.vol.used.1509 -v 0 /tmp/test
root@Kylin:/home/hci_sysadmin# setfattr  -n user.vol.total.1509 -v 10485760000 /tmp/test

# 查看用户配额
代码语言:javascript
复制
root@Kylin:/home/hci_sysadmin# getfattr -dm ".*" /tmp/test
getfattr:删去绝对路径名最前面的'/'
# file: tmp/test
ceph.dir.entries="0"
ceph.dir.files="0"
ceph.dir.rbytes="0"
ceph.dir.rctime="0.090"
ceph.dir.rentries="1"
ceph.dir.rfiles="0"
ceph.dir.rsubdirs="1"
ceph.dir.subdirs="0"
user.file.total.1509="100"
user.file.total.64056="888888888"
user.file.used.1509="0"
user.vol.total.1509="10485760000"
user.vol.total.64056="10484711424"
user.vol.used.1509="0"

root@Kylin:/home/hci_sysadmin# umount /tmp/test

# 删除用户配额
# 删除用户文件数配额
代码语言:javascript
复制
root@Kylin:/tmp/test# setfattr  -x user.file.used.1509 -h /tmp/test
root@Kylin:/tmp/test# setfattr  -x user.file.total.1509 -h /tmp/test

# 删除用户容量配额
代码语言:javascript
复制
root@Kylin:/tmp/test# setfattr  -x user.vol.used.1509 -h /tmp/test
root@Kylin:/tmp/test# setfattr  -x user.vol.total.1509 -h /tmp/test

# 查看用户配额
代码语言:javascript
复制
root@Kylin:/tmp/test# getfattr -dm ".*" /tmp/test
getfattr:删去绝对路径名最前面的'/'
# file: tmp/test
ceph.dir.entries="0"
ceph.dir.files="0"
ceph.dir.rbytes="0"
ceph.dir.rctime="0.090"
ceph.dir.rentries="1"
ceph.dir.rfiles="0"
ceph.dir.rsubdirs="1"
ceph.dir.subdirs="0"
user.file.total.64056="888888888"
user.vol.total.64056="10484711424"

# 配额用户组配额
# 配置用户组文件数配额
代码语言:javascript
复制
root@Kylin:/tmp/test# setfattr -n group.file.used.1509 -v 0 /tmp/test
root@Kylin:/tmp/test# setfattr -n group.file.total.1509 -v 200 /tmp/test

# 配置用户组容量配额
代码语言:javascript
复制
root@Kylin:/tmp/test# setfattr -n group.vol.used.1509 -v 0 /tmp/test
root@Kylin:/tmp/test# setfattr -n group.vol.total.1509 -v 20971520000 /tmp/test

# 查看用户组配额
代码语言:javascript
复制
root@Kylin:/tmp/test# getfattr -dm ".*" /tmp/test
getfattr:删去绝对路径名最前面的'/'
# file: tmp/test
group.file.total.1509="200"
group.file.used.1509="0"
group.vol.total.1509="20971520000"
group.vol.used.1509="0"
ceph.dir.entries="0"
ceph.dir.files="0"
ceph.dir.rbytes="0"
ceph.dir.rctime="0.090"
ceph.dir.rentries="1"
ceph.dir.rfiles="0"
ceph.dir.rsubdirs="1"
ceph.dir.subdirs="0"
user.file.total.64056="888888888"
user.vol.total.64056="10484711424"

root@Kylin:/tmp/test#

# 删除用户组文件数配额
代码语言:javascript
复制
root@Kylin:/tmp/test# setfattr -x group.file.used.1509 /tmp/test
root@Kylin:/tmp/test# setfattr -x group.file.total.1509 /tmp/test

# 删除用户组容量配额
代码语言:javascript
复制
root@Kylin:/tmp/test# setfattr -x group.vol.used.1509 /tmp/test
root@Kylin:/tmp/test# setfattr -x group.vol.total.1509 /tmp/test

# 目录容量配额

# 配置目录容量配额
代码语言:javascript
复制
root@Kylin:/tmp/test# setfattr  -n user.quota -v 52428800000 /tmp/test
root@Kylin:/tmp/test# getfattr -dm ".*" /tmp/test
getfattr:删去绝对路径名最前面的'/'
# file: tmp/test
ceph.dir.entries="0"
ceph.dir.files="0"
ceph.dir.rbytes="0"
ceph.dir.rctime="0.090"
ceph.dir.rentries="1"
ceph.dir.rfiles="0"
ceph.dir.rsubdirs="1"
ceph.dir.subdirs="0"
user.file.total.64056="888888888"
user.quota="52428800000"
user.vol.total.64056="10484711424"

# 删除目录容量配额
代码语言:javascript
复制
root@Kylin:/tmp/test# setfattr  -x user.quota  /tmp/test
root@Kylin:/tmp/test# getfattr -dm ".*" /tmp/test
getfattr:删去绝对路径名最前面的'/'
# file: tmp/test
ceph.dir.entries="0"
ceph.dir.files="0"
ceph.dir.rbytes="0"
ceph.dir.rctime="0.090"
ceph.dir.rentries="1"
ceph.dir.rfiles="0"
ceph.dir.rsubdirs="1"
ceph.dir.subdirs="0"
user.file.total.64056="888888888"
user.vol.total.64056="10484711424"

# 目录文件数配额

# 配置目录文件数配额
代码语言:javascript
复制
root@Kylin:/tmp/test# setfattr -n file.quota -v 100 /tmp/test/
root@Kylin:/tmp/test# getfattr -dm ".*" /tmp/test
getfattr:删去绝对路径名最前面的'/'
# file: tmp/test
file.quota="100"
ceph.dir.entries="0"
ceph.dir.files="0"
ceph.dir.rbytes="0"
ceph.dir.rctime="0.090"
ceph.dir.rentries="1"
ceph.dir.rfiles="0"
ceph.dir.rsubdirs="1"
ceph.dir.subdirs="0"
user.file.total.64056="888888888"
user.vol.total.64056="10484711424"

# 虚拟容量配额

# 配置虚拟容量和软配额
代码语言:javascript
复制
root@Kylin:/tmp/test# df -h | grep test
88.88.88.101,88.88.88.102,88.88.88.103:/summer38-fec-691852341313819928811/vr/test-permissions  298T   60T  239T   20% /tmp/test

  • 重新挂载
代码语言:javascript
复制
root@Kylin:/tmp# mount -t ceph -o readdir_max_bytes=4194304,readdir_max_entries=8192,noatime,quota_nearfull_ratio=85,quota_dir,rasize=134217728,pool_id=3,statfs_xattr 88.88.88.101,88.88.88.102,88.88.88.103:'/summer38-fec-691852341313819928811/vr/test-permissions'  '/tmp/test'
root@Kylin:/tmp# setfattr  -n user.total -v 536870912000 /tmp/test
root@Kylin:/tmp# df -h | grep 500
88.88.88.101,88.88.88.102,88.88.88.103:/summer38-fec-691852341313819928811/vr/test-permissions  500G     0  500G    0% /tmp/test

# WORM

# 配置普通worm功能
代码语言:javascript
复制
root@Kylin:/tmp/test# mkdir worm_test
root@Kylin:/tmp/test# ll
总用量 4
drw-r---w- 1 root root    0 May 14 11:28 ./
drwxrwxrwt 9 root root 4096 May 14 11:28 ../
drwxr-xr-x 1 root root    0 May 14 11:28 worm_test/
root@Kylin:/tmp/test# ceph_worm_set -u utest -p q1234567 -d /tmp/test/worm_test/
OK 
root@Kylin:/tmp/test# getfattr -dm ".*" /tmp/test/worm_test/
getfattr:删去绝对路径名最前面的'/'
# file: tmp/test/worm_test/
ceph.dir.entries="0"
ceph.dir.files="0"
ceph.dir.rbytes="0"
ceph.dir.rctime="0.090"
ceph.dir.rentries="1"
ceph.dir.rfiles="0"
ceph.dir.rsubdirs="1"
ceph.dir.subdirs="0"
user.username.utest="d4ySaq8FuJEW1bUalZGT3Q=="

root@Kylin:/tmp/test#

# 配置worm高级功能
  • WORM将在08,09,10(月)01,02,03,04,05,06,07,08,09,10(日)周一,周二00:00:00-11:00:42启用
代码语言:javascript
复制
root@Kylin:/tmp/test# ceph_worm_set -d /tmp/test/worm_test/ -u utest -p q1234567 -m 08,09,10 -a 01,02,03,04,05,06,07,08,09,10 -w 1,2 -t 00:00:00-11:00:42 -e 1
OK 
root@Kylin:/tmp/test# getfattr -dm ".*" /tmp/test/worm_test/
getfattr:删去绝对路径名最前面的'/'
# file: tmp/test/worm_test/
ceph.dir.entries="0"
ceph.dir.files="0"
ceph.dir.rbytes="0"
ceph.dir.rctime="0.090"
ceph.dir.rentries="1"
ceph.dir.rfiles="0"
ceph.dir.rsubdirs="1"
ceph.dir.subdirs="0"
user.day="01,02,03,04,05,06,07,08,09,10"
user.enable="1"
user.month="08,09,10"
user.time="00:00:00-11:00:42"
user.username.utest="d4ySaq8FuJEW1bUalZGT3Q=="
user.week="1,2"

root@Kylin:/tmp/test#

WORM将在08,09,10(月)01,02,03,04,05,06,07,08,09,10(日)周一,周二00:00:00-11:30:39禁用

代码语言:javascript
复制
root@Kylin:/tmp/test# ceph_worm_set -d /tmp/test/worm_test/ -u utest -p q1234567 -m 08,09,10 -a 01,02,03,04,05,06,07,08,09,10 -w 1,2 -t 00:00:00-11:00:42 -e 0
OK 
root@Kylin:/tmp/test# getfattr -dm ".*" /tmp/test/worm_test/
getfattr:删去绝对路径名最前面的'/'
# file: tmp/test/worm_test/
ceph.dir.entries="0"
ceph.dir.files="0"
ceph.dir.rbytes="0"
ceph.dir.rctime="0.090"
ceph.dir.rentries="1"
ceph.dir.rfiles="0"
ceph.dir.rsubdirs="1"
ceph.dir.subdirs="0"
user.day="01,02,03,04,05,06,07,08,09,10"
user.enable="0"
user.month="08,09,10"
user.time="00:00:00-11:00:42"
user.username.utest="d4ySaq8FuJEW1bUalZGT3Q=="
user.week="1,2"

# 删除worm功能
代码语言:javascript
复制
root@Kylin:/tmp/test# ceph_worm_set -D /tmp/test/worm_test/ -u utest -p q1234567 
OK 
root@Kylin:/tmp/test# getfattr -dm ".*" /tmp/test/worm_test/
getfattr:删去绝对路径名最前面的'/'
# file: tmp/test/worm_test/
ceph.dir.entries="0"
ceph.dir.files="0"
ceph.dir.rbytes="0"
ceph.dir.rctime="0.090"
ceph.dir.rentries="1"
ceph.dir.rfiles="0"
ceph.dir.rsubdirs="1"
ceph.dir.subdirs="0"
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-01-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • # pool
    • # 创建池
      • # 修改池
        • # 查看池
          • # 压缩池
            • # 加密池
              • # 配额池
                • # 删除池
                • # 块设备
                  • # 创建快设备
                    • # 扩容块设备
                      • # 移动块设备
                        • # 查看块设备
                          • # 使用块设备
                            • # map映射
                            • # iscsi映射
                          • # 删除块设备
                            • # 快照
                              • # 创建快照
                              • # 查看快照
                              • # 保护快照
                              • # 克隆快照
                              • # 拍平克隆映像
                              • # 取消快照保护
                              • # 回滚快照
                              • # 删除快照
                              • # 清除所有快照
                          • # 对象
                            • # 用户
                              • # 创建用户
                              • # 查看所有用户user
                              • # 查看用户详情
                              • # 修改用户信息
                              • # 删除用户
                              • # 设置用户配额
                              • # 启用用户配额
                            • # bucket
                              • # 查看系统用所有bucket
                              • # 查看bucket的配额
                              • # 查看用户已消耗的配额
                              • # 设置桶配额
                              • # 启动桶配额
                            • # s3cmd使用
                              • # 创建桶
                              • # 删除桶
                              • # 上传文件至桶
                              • # 下载文件到本地
                              • # 删除桶里的文件
                          • # 补充
                            • # 本地权限
                              • # 访问控制
                                • # 用户(组)配额
                                  • # 增加用户组
                                  • # 增加用户
                                  • # 配置用户配额
                                  • # 删除用户配额
                                  • # 配额用户组配额
                                • # 目录容量配额
                                  • # 配置目录容量配额
                                  • # 删除目录容量配额
                                • # 目录文件数配额
                                  • # 配置目录文件数配额
                                • # 虚拟容量配额
                                  • # 配置虚拟容量和软配额
                                • # WORM
                                  • # 配置普通worm功能
                                  • # 配置worm高级功能
                                  • # 删除worm功能
                              相关产品与服务
                              访问管理
                              访问管理(Cloud Access Management,CAM)可以帮助您安全、便捷地管理对腾讯云服务和资源的访问。您可以使用CAM创建子用户、用户组和角色,并通过策略控制其访问范围。CAM支持用户和角色SSO能力,您可以根据具体管理场景针对性设置企业内用户和腾讯云的互通能力。
                              领券
                              问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档