rados常用命令

rados是一个用于与Ceph对象存储集群(rados)交互的实用程序,是Ceph分布式存储系统的一部分。

基本命令

[root@node-1 ceph-deploy]# rados -h
usage: rados [options] [commands]
POOL COMMANDS
   lspools                          list pools
   cppool <pool-name> <dest-pool>   copy content of a pool
   purge <pool-name> --yes-i-really-really-mean-it
                                    remove all objects from pool <pool-name> without removing it
   df                               show per-pool and total usage
   ls                               list objects in pool


POOL SNAP COMMANDS
   lssnap                           list snaps
   mksnap <snap-name>               create snap <snap-name>
   rmsnap <snap-name>               remove snap <snap-name>

OBJECT COMMANDS
   get <obj-name> <outfile>         fetch object
   put <obj-name> <infile> [--offset offset]
                                    write object with start offset (default:0)
   append <obj-name> <infile>       append object
   truncate <obj-name> length       truncate object
   create <obj-name>                create object
   rm <obj-name> ...[--force-full]  [force no matter full or not]remove object(s)
   cp <obj-name> [target-obj]       copy object
   listxattr <obj-name>
   getxattr <obj-name> attr
   setxattr <obj-name> attr val
   rmxattr <obj-name> attr
   stat <obj-name>                  stat the named object
   stat2 <obj-name>                 stat2 the named object (with high precision time)
   touch <obj-name> [timestamp]     change the named object modification time
   mapext <obj-name>
   rollback <obj-name> <snap-name>  roll back object to snap <snap-name>

   listsnaps <obj-name>             list the snapshots of this object
   bench <seconds> write|seq|rand [-t concurrent_operations] [--no-cleanup] [--run-name run_name] [--no-hints] [--reuse-bench]
                                    default is 16 concurrent IOs and 4 MB ops
                                    default is to clean up after write benchmark
                                    default run-name is 'benchmark_last_metadata'
   cleanup [--run-name run_name] [--prefix prefix]
                                    clean up a previous benchmark operation
                                    default run-name is 'benchmark_last_metadata'
   load-gen [options]               generate load on the cluster
   listomapkeys <obj-name>          list the keys in the object map
   listomapvals <obj-name>          list the keys and vals in the object map 
   getomapval <obj-name> <key> [file] show the value for the specified key
                                    in the object's object map
   setomapval <obj-name> <key> <val>
   rmomapkey <obj-name> <key>
   clearomap <obj-name> [obj-name2 obj-name3...] clear all the omap keys for the specified objects
   getomapheader <obj-name> [file]
   setomapheader <obj-name> <val>
   watch <obj-name>                 add watcher on this object
   notify <obj-name> <message>      notify watcher of this object with message
   listwatchers <obj-name>          list the watchers of this object
   set-alloc-hint <obj-name> <expected-object-size> <expected-write-size>
                                    set allocation hint for an object
   set-redirect <object A> --target-pool <caspool> <target object A> [--with-reference]
                                    set redirect target
   set-chunk <object A> <offset> <length> --target-pool <caspool> <target object A> <taget-offset> [--with-reference]
                                    convert an object to chunked object
   tier-promote <obj-name>	     promote the object to the base tier
   unset-manifest <obj-name>	     unset redirect or chunked object

IMPORT AND EXPORT
   export [filename]
       Serialize pool contents to a file or standard out.
   import [--dry-run] [--no-overwrite] < filename | - >
       Load pool contents from a file or standard in

ADVISORY LOCKS
   lock list <obj-name>
       List all advisory locks on an object
   lock get <obj-name> <lock-name>
       Try to acquire a lock
   lock break <obj-name> <lock-name> <locker-name>
       Try to break a lock acquired by another client
   lock info <obj-name> <lock-name>
       Show lock information
   options:
       --lock-tag                   Lock tag, all locks operation should use
                                    the same tag
       --lock-cookie                Locker cookie
       --lock-description           Description of lock
       --lock-duration              Lock duration (in seconds)
       --lock-type                  Lock type (shared, exclusive)

SCRUB AND REPAIR:
   list-inconsistent-pg <pool>      list inconsistent PGs in given pool
   list-inconsistent-obj <pgid>     list inconsistent objects in given PG
   list-inconsistent-snapset <pgid> list inconsistent snapsets in the given PG

CACHE POOLS: (for testing/development only)
   cache-flush <obj-name>           flush cache pool object (blocking)
   cache-try-flush <obj-name>       flush cache pool object (non-blocking)
   cache-evict <obj-name>           evict cache pool object
   cache-flush-evict-all            flush+evict all objects
   cache-try-flush-evict-all        try-flush+evict all objects

GLOBAL OPTIONS:
   --object_locator object_locator
        set object_locator for operation
   -p pool
   --pool=pool
        select given pool by name
   --target-pool=pool
        select target pool by name
   --pgid PG id
        select given PG id
   -f [--format plain|json|json-pretty]
   --format=[--format plain|json|json-pretty]
   -b op_size
        set the block size for put/get ops and for write benchmarking
   -O object_size
        set the object size for put/get ops and for write benchmarking
   --max-objects
        set the max number of objects for write benchmarking
   -s name
   --snap name
        select given snap name for (read) IO
   --create
        create the pool or directory that was specified
   -N namespace
   --namespace=namespace
        specify the namespace to use for the object
   --all
        Use with ls to list objects in all namespaces
        Put in CEPH_ARGS environment variable to make this the default
   --default
        Use with ls to list objects in default namespace
        Takes precedence over --all in case --all is in environment
   --target-locator
        Use with cp to specify the locator of the new object
   --target-nspace
        Use with cp to specify the namespace of the new object
   --striper
        Use radostriper interface rather than pure rados
        Available for stat, get, put, truncate, rm, ls and 
        all xattr related operations

BENCH OPTIONS:
   -t N
   --concurrent-ios=N
        Set number of concurrent I/O operations
   --show-time
        prefix output with date/time
   --no-verify
        do not verify contents of read objects
   --write-object
        write contents to the objects
   --write-omap
        write contents to the omap
   --write-xattr
        write contents to the extended attributes

LOAD GEN OPTIONS:
   --num-objects                    total number of objects
   --min-object-size                min object size
   --max-object-size                max object size
   --min-op-len                     min io size of operations
   --max-op-len                     max io size of operations
   --max-ops                        max number of operations
   --max-backlog                    max backlog size
   --read-percent                   percent of operations that are read
   --target-throughput              target throughput (in bytes)
   --run-length                     total time (in seconds)
   --offset-align                   at what boundary to align random op offsetsCACHE POOLS OPTIONS:
   --with-clones                    include clones when doing flush or evict
OMAP OPTIONS:
    --omap-key-file file            read the omap key from a file

POOL COMMANDS

列出所有 pools

rados lspools

复制 pool 内容

rados cppool {pool-name} {destination-pool-name}

清空 pool

rados purge {pool-name} --yes-i-really-really-mean-it

显示每个 pool 的使用资源

可通过添加参数 -p {pool-name} 来指定 pool,不加显示所有 pool。

rados df -p {pool-name}

列出 pool 的对象

必须指定 pool 或者 pg,可选输出文件。

rados -p {pool-name} ls --output {file}
rados --pgid {pg-id} ls --output {file}

OBJECT COMMANDS

获取对象

输出对象到指定文件。

rados get {obj-name} {outfile}

写入对象

可以指定偏移量,默认是0。

rados put {obj-name} {infile} [--offset offset] -p {pool-name}

附加对象

rados -p {pool-name} append {obj-name} {infile}

删除定长对象

rados -p {pool-name} truncate {obj-name} length

创建对象

rados -p {pool-name} create {obj-name}

删除对象

可以加上 --force-full 强制删除。

rados -p {pool-name} rm {obj-name}...[--force-full]  

复制对象

rados -p {pool-name} cp {obj-name} {target-obj}

对象属性

设置属性
rados -p {pool-name} setxattr <obj-name> attr val

查看属性
rados -p {pool-name} listxattr <obj-name>

获取指定属性
rados -p {pool-name} getxattr <obj-name> attr

删除指定属性
rados -p {pool-name} rmxattr <obj-name> attr

对象信息

rados -p {pool-name} stat {obj-name}

更高精度时间
rados -p {pool-name} stat2 {obj-name}

更改对象修改时间

rados -p {pool-name} touch {obj-name} [timestamp]

显示对象偏移量

rados -p {pool-name} mapext {obj-name}

对象回滚

rados -p {pool-name} roolback {obj-name} {snap-name}

列出对象snap

rados -p {pool-name} listsnaps {obj-name}

bench

rados bench -p <pool_name> <seconds> write|seq|rand
<pool_name>:池名称
<seconds>:测试所持续的秒数
<write|seq|rand>:操作模式,write:写,seq:顺序读;rand:随机读
-b:块大小,即一次写入的数据量大小,默认为4MB
-t:线程数量,默认为16
--no-cleanup 表示测试完成后不删除测试用数据。在做读测试之前,需要使用该参数来运行一遍写测试来产生测试数据,在全部测试结束后可以运行 rados -p <pool_name> cleanup 来清理所有测试数据。默认是会被清空
例子:rados bench 3000 -b 4M -t 16 write --no-cleanup -p storage-cold

清除先前设置
rados -p {pool-name} cleanup [--run-name run_name] [--prefix prefix]

load-gen

与 rados bench 相比,rados load-gen 的特点是可以产生混合类型的测试负载,而 rados bench 只能产生一种类型的负载

rados -p <pool-name> load-gen [options]
	--num-objects:初始生成测试用的对象数,默认 200
	--min-object-size:测试对象的最小大小,默认 1KB,单位byte 
	--max-object-size:测试对象的最大大小,默认 5GB,单位byte
	--min-ops:一次提交的最小IO数,相当于iodepth
	--max-ops:一次提交的最大IO数,相当于iodepth
	--min-op-len:压测IO的最小大小,默认 1KB,单位byte
	--max-op-len:压测IO的最大大小,默认 1KB,单位byte
	--max-backlog:一次提交IO的吞吐量上限,默认10MB/s,单位B/s
	--percent:读写混合中读的比例,默认80,范围[0, 100]
	--target-throughput:一次提交IO的历史累计吞吐量上限,默认 5MB/s,单位B/s,
	--run-length:运行的时间,默认60s,单位秒

POOL SNAP COMMANDS

列出快照

rados lssnap -p {pool-name}

创建快照

rados mksnap {snap-name} -p {pool-name}

删除快照

rados rmsnap {snap-name} -p {pool-name}

IMPORT AND EXPORT

导出

rados -p {pool-name} export {file-name}

导入

rados -p {pool-name} import [--dry-run] [--no-overwrite] < filename | - >

HELP

[root@localhost build]# ./bin/rados -h
usage: rados [options] [commands]
POOL COMMANDS
   lspools                          list pools
   cppool <pool-name> <dest-pool>   copy content of a pool
   purge <pool-name> --yes-i-really-really-mean-it
                                    remove all objects from pool <pool-name> without removing it
   df                               show per-pool and total usage
   ls                               list objects in pool


POOL SNAP COMMANDS
   lssnap                           list snaps
   mksnap <snap-name>               create snap <snap-name>
   rmsnap <snap-name>               remove snap <snap-name>

OBJECT COMMANDS
   get <obj-name> <outfile>         fetch object
   put <obj-name> <infile> [--offset offset]
                                    write object with start offset (default:0)
   append <obj-name> <infile>       append object
   truncate <obj-name> length       truncate object
   create <obj-name>                create object
   rm <obj-name> ...[--force-full]  [force no matter full or not]remove object(s)
   cp <obj-name> [target-obj]       copy object
   listxattr <obj-name>
   getxattr <obj-name> attr
   setxattr <obj-name> attr val
   rmxattr <obj-name> attr
   stat <obj-name>                  stat the named object
   stat2 <obj-name>                 stat2 the named object (with high precision time)
   touch <obj-name> [timestamp]     change the named object modification time
   mapext <obj-name>
   rollback <obj-name> <snap-name>  roll back object to snap <snap-name>

   listsnaps <obj-name>             list the snapshots of this object
   bench <seconds> write|seq|rand [-t concurrent_operations] [--no-cleanup] [--run-name run_name] [--no-hints] [--reuse-bench]
                                    default is 16 concurrent IOs and 4 MB ops
                                    default is to clean up after write benchmark
                                    default run-name is 'benchmark_last_metadata'
   cleanup [--run-name run_name] [--prefix prefix]
                                    clean up a previous benchmark operation
                                    default run-name is 'benchmark_last_metadata'
   load-gen [options]               generate load on the cluster
   listomapkeys <obj-name>          list the keys in the object map
   listomapvals <obj-name>          list the keys and vals in the object map 
   getomapval <obj-name> <key> [file] show the value for the specified key
                                    in the object's object map
   setomapval <obj-name> <key> <val>
   rmomapkey <obj-name> <key>
   clearomap <obj-name> [obj-name2 obj-name3...] clear all the omap keys for the specified objects
   getomapheader <obj-name> [file]
   setomapheader <obj-name> <val>
   watch <obj-name>                 add watcher on this object
   notify <obj-name> <message>      notify watcher of this object with message
   listwatchers <obj-name>          list the watchers of this object
   set-alloc-hint <obj-name> <expected-object-size> <expected-write-size>
                                    set allocation hint for an object
   set-redirect <object A> --target-pool <caspool> <target object A> [--with-reference]
                                    set redirect target
   set-chunk <object A> <offset> <length> --target-pool <caspool> <target object A> <taget-offset> [--with-reference]
                                    convert an object to chunked object
   tier-promote <obj-name>	     promote the object to the base tier
   unset-manifest <obj-name>	     unset redirect or chunked object

IMPORT AND EXPORT
   export [filename]
       Serialize pool contents to a file or standard out.
   import [--dry-run] [--no-overwrite] < filename | - >
       Load pool contents from a file or standard in

ADVISORY LOCKS
   lock list <obj-name>
       List all advisory locks on an object
   lock get <obj-name> <lock-name>
       Try to acquire a lock
   lock break <obj-name> <lock-name> <locker-name>
       Try to break a lock acquired by another client
   lock info <obj-name> <lock-name>
       Show lock information
   options:
       --lock-tag                   Lock tag, all locks operation should use
                                    the same tag
       --lock-cookie                Locker cookie
       --lock-description           Description of lock
       --lock-duration              Lock duration (in seconds)
       --lock-type                  Lock type (shared, exclusive)

SCRUB AND REPAIR:
   list-inconsistent-pg <pool>      list inconsistent PGs in given pool
   list-inconsistent-obj <pgid>     list inconsistent objects in given PG
   list-inconsistent-snapset <pgid> list inconsistent snapsets in the given PG

CACHE POOLS: (for testing/development only)
   cache-flush <obj-name>           flush cache pool object (blocking)
   cache-try-flush <obj-name>       flush cache pool object (non-blocking)
   cache-evict <obj-name>           evict cache pool object
   cache-flush-evict-all            flush+evict all objects
   cache-try-flush-evict-all        try-flush+evict all objects

GLOBAL OPTIONS:
   --object_locator object_locator
        set object_locator for operation
   -p pool
   --pool=pool
        select given pool by name
   --target-pool=pool
        select target pool by name
   --pgid PG id
        select given PG id
   -f [--format plain|json|json-pretty]
   --format=[--format plain|json|json-pretty]
   -b op_size
        set the block size for put/get ops and for write benchmarking
   -o object_size
        set the object size for put/get ops and for write benchmarking
   --max-objects
        set the max number of objects for write benchmarking
   -s name
   --snap name
        select given snap name for (read) IO
   --create
        create the pool or directory that was specified
   -N namespace
   --namespace=namespace
        specify the namespace to use for the object
   --all
        Use with ls to list objects in all namespaces
        Put in CEPH_ARGS environment variable to make this the default
   --default
        Use with ls to list objects in default namespace
        Takes precedence over --all in case --all is in environment
   --target-locator
        Use with cp to specify the locator of the new object
   --target-nspace
        Use with cp to specify the namespace of the new object
   --striper
        Use radostriper interface rather than pure rados
        Available for stat, get, put, truncate, rm, ls and 
        all xattr related operations

BENCH OPTIONS:
   -t N
   --concurrent-ios=N
        Set number of concurrent I/O operations
   --show-time
        prefix output with date/time
   --no-verify
        do not verify contents of read objects
   --write-object
        write contents to the objects
   --write-omap
        write contents to the omap
   --write-xattr
        write contents to the extended attributes

LOAD GEN OPTIONS:
   --num-objects                    total number of objects
   --min-object-size                min object size
   --max-object-size                max object size
   --min-op-len                     min io size of operations
   --max-op-len                     max io size of operations
   --max-ops                        max number of operations
   --max-backlog                    max backlog size
   --read-percent                   percent of operations that are read
   --target-throughput              target throughput (in bytes)
   --run-length                     total time (in seconds)
   --offset-align                   at what boundary to align random op offsetsCACHE POOLS OPTIONS:
   --with-clones                    include clones when doing flush or evict
OMAP OPTIONS:
    --omap-key-file file            read the omap key from a file

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值