Ceph storage cluster中涉及到大量的命令,在ceph运维的过程中会经常用到。这里对其做一个简单的梳理。ceph命令主要分为一下几大类:

  • auth命令集
  • system命令集
  • monitor命令集
  • osd命令集
  • pg命令集
  • mds命令集

auth命令集

1.  auth add <entity> {<caps> [<caps>...]}   
2.  auth caps <entity> <caps> [<caps>...]    
3.  auth del <entity>                       
4.  auth export {<entity>}                  
5.  auth get <entity>                       
6.  auth get-key <entity>                    
7.  auth get-or-create <entity> {<caps> [<caps>...]}                                                                 
8.  auth get-or-create-key <entity> {<caps> [<caps>...]}                             
9.  auth import                              
10. auth list                                
11. auth print-key <entity>                  
12. auth print_key <entity>                  

(1) 添加用户身份认证信息

向cephx认证系统中添加用户信息,可以通过文件传入key,或者随机产生。

auth add <entity> {<caps> [<caps>...]}

例如:

sudo ceph auth add osd.0 osd 'allow *' mon 'allow profile osd' -i /var/lib/ceph/osd/ceph-0/keyring

(2) 修改用户权限信息

在使用时,一般需要先用ceph auth get <entity>ceph auth export <entity>来获取到对应实体的权限,然后再进行修改。

auth caps <entity> <caps> [<caps>...]

例如:

sudo ceph auth caps osd.0 'allow rwx' mon 'allow profile osd'

(3) 从cephx系统中删除用户及权限信息

auth del <entity>     

(4) 导出用户的详细信息(包括用户ID)

从cephx系统中导出用户详细信息,也包括用户ID。可以通过添加-o选项来导出到文件

auth export {<entity>} 

例如:

sudo ceph auth export client.admin

运行结果如下:

ceph_auth_export

2. system命令集

3. monitor命令集

4. osd命令集

1) 查看当前所有pool

# ceph osd pool ls

5. pg命令集

6. mds命令集

7. RGW命令集

1) 查看一个pool中的对象数据

# rados -p default.rgw.users.uid ls

2) 创建swift用户

# radosgw-admin user create --subuser="registry:swift" --uid="registry" --display-name="registry swift" --key-type=swift --access=full

# radosgw-admin user rm --uid=registry --subuser=registry:swift

# radosgw-admin subuser rm --subuser=registry:swift

# curl -X GET http://10.17.155.100:7480/auth -H "X-Auth-User: registry:swift" -H "X-Auth-Key: 3ruohjBaORwic87NoRGFBzO8SC1IcAkck5AnMN1q" -ikL

3) rados上传文件

# rados put openresty-1.11.2.3.tar.gz ./openresty-1.11.2.3.tar.gz -p nh.rgw.buckets.data

4) 列出所有bucket

# radosgw-admin bucket list

# radosgw-admin bucket stats --bucket=chaoge_73_test
{
    "bucket": "chaoge_73_test",
    "pool": "default.rgw.buckets.data",
    "index_pool": "default.rgw.buckets.index",
    "id": "5c470d18-0d9e-4a34-8a6c-7a6d64784c3e.38311.41",
    "marker": "5c470d18-0d9e-4a34-8a6c-7a6d64784c3e.38311.41",
    "owner": "FFF65F671D9E48F696C5E57931A1DE85",
    "ver": "0#1",
    "master_ver": "0#0",
    "mtime": "2018-05-03 17:47:31.329045",
    "max_marker": "0#",
    "usage": {},
    "bucket_quota": {
        "enabled": false,
        "max_size_kb": -1,
        "max_objects": -1
    }
}

# radosgw-admin user info --uid=FFF65F671D9E48F696C5E57931A1DE85
{
    "user_id": "FFF65F671D9E48F696C5E57931A1DE85",
    "display_name": "user name",
    "email": "",
    "suspended": 0,
    "max_buckets": 1000,
    "auid": 0,
    "subusers": [],
    "keys": [
        {
            "user": "FFF65F671D9E48F696C5E57931A1DE85",
            "access_key": "A5DXX3XCFX7OF4ZM1UY5",
            "secret_key": "r1eeS2Sq5fuQF8JbOxjlauNDkPV7apZ6sArhFlUq"
        }
    ],
    "swift_keys": [],
    "caps": [],
    "op_mask": "read, write, delete",
    "default_placement": "",
    "placement_tags": [],
    "bucket_quota": {
        "enabled": false,
        "max_size_kb": -1,
        "max_objects": -1
    },
    "user_quota": {
        "enabled": false,
        "max_size_kb": -1,
        "max_objects": -1
    },
    "temp_url_keys": []
}

5) 查看rgw配置信息

# ceph daemon client.radosgw.ceph001-node1 config show
{
    "name": "client.radosgw.ceph001-node1",
    "cluster": "ceph",
    "debug_none": "0\/5",
    "debug_lockdep": "0\/0",
    "debug_context": "0\/0",
    "debug_crush": "0\/0",
    "debug_mds": "0\/0",
    "debug_mds_balancer": "0\/0",
    "debug_mds_locker": "0\/0",
    "debug_mds_log": "0\/0",
	....
}