转载:https://www.cnblogs.com/kuku0223/p/8257813.html
常用操作:
生成一新用户:
在两个集群当中都创建相同的管理用户
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin user create --uid=admin --display-name=admin --access_key=admin --secret=123456 </pre>
这里为了测试方便使用了简单密码
此时admin还仅仅是普通的权限,需要通过cap添加user的capabilities,例如:
|
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin caps add --uid=admin --caps="users=read, write"
radosgw-admin caps add --uid=admin --caps="usage=read, write" </pre>
|
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">$ radosgw-admin user create --display-name="johnny rotten" --uid=johnny
{ "user_id": "johnny",
"rados_uid": 0,
"display_name": "johnny rotten",
"email": "",
"suspended": 0,
"subusers": [],
"keys": [
{ "user": "johnny",
"access_key": "TCICW53D9BQ2VGC46I44",
"secret_key": "tfm9aHMI8X76L3UdgE+ZQaJag1vJQmE6HDb5Lbrz"}],
"swift_keys": []}</pre>
删除一用户:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">$ radosgw-admin user rm --uid=johnny</pre>
删除一个用户和与他相关的桶及内容:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">$ radosgw-admin user rm --uid=johnny --purge-data</pre>
删除一个桶:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">$ radosgw-admin bucket unlink --bucket=foo</pre>
显示一个桶从 2012 年 4 月 1 日起的日志:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">$ radosgw-admin log show --bucket=foo --date=2012-04-01</pre>
显示某用户 2012 年 3 月 1 日(不含)到 4 月 1 日期间的使用情况:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">$ radosgw-admin usage show --uid=johnny
--start-date=2012-03-01 --end-date=2012-04-01</pre>
只显示所有用户的使用情况汇总:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">$ radosgw-admin usage show --show-log-entries=false</pre>
裁剪掉某用户 2012 年 4 月 1 日之前的使用信息:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">$ radosgw-admin usage trim --uid=johnny --end-date=2012-04-01</pre>
选项
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin-c" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">-c</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;"> ceph.conf</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">, </tt><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--conf</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=ceph.conf</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
用指定的 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">ceph.conf</tt> 配置文件而非默认的 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">/etc/ceph/ceph.conf</tt> 来确定启动时所需的监视器地址。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin-m" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">-m</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;"> monaddress[:port]</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
连接到指定监视器,而非通过 ceph.conf 查询。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--uid" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--uid</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=uid</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
radosgw 用户的 ID 。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--subuser" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--subuser</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=<name></tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
子用户名字。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--email" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--email</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=email</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
用户的电子邮件地址。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--display-name" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--display-name</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=name</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
配置用户的显示名称(昵称)
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--access-key" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--access-key</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=<key></tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
S3 访问密钥。
</dd>
</dl>
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--gen-access-key" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--gen-access-key</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
生成随机访问密钥(给 S3 )。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--secret" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--secret</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=secret</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
指定密钥的密文。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--gen-secret" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--gen-secret</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
生成随机密钥。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--key-type" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--key-type</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=<type></tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
密钥类型,可用的有: swift 、 S3 。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--temp-url-key" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--temp-url-key</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">[-2]=<key></tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
临时 URL 密钥。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--system" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--system</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
给用户设置系统标识。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--bucket" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--bucket</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=bucket</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
指定桶名
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--object" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--object</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=object</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
指定对象名
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--date" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--date</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=yyyy-mm-dd</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
某些命令所需的日期
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--start-date" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--start-date</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=yyyy-mm-dd</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
某些命令所需的起始日期
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--end-date" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--end-date</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=yyyy-mm-dd</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
某些命令所需的终结日期
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--shard-id" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--shard-id</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=<shard-id></tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
执行 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">mdlog list</tt> 时为可选项。对 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">mdlog trim</tt> 、 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">replica mdlog get/delete</tt> 、 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">replica datalog get/delete</tt> 来说是必须的。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--auth-uid" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--auth-uid</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=auid</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
librados 认证所需的 auid 。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--purge-data" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--purge-data</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
删除用户前先删除用户数据。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--purge-keys" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--purge-keys</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
若加了此选项,删除子用户时将一起删除其所有密钥。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--purge-objects" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--purge-objects</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
删除桶前先删除其内所有对象。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--metadata-key" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--metadata-key</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=<key></tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
用 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">metadata get</tt> 检索元数据时用的密钥。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--rgw-region" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--rgw-region</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=<region></tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
radosgw 所在的 region 。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--rgw-zone" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--rgw-zone</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=<zone></tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
radosgw 所在的区域。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--fix" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--fix</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
除了检查桶索引,还修复它。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--check-objects" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--check-objects</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
检查桶:根据对象的实际状态重建桶索引。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--format" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--format</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=<format></tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
为某些操作指定输出格式: xml 、 json 。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--sync-stats" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--sync-stats</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
<tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">user stats</tt> 的选项,收集用户的桶索引状态、并同步到用户状态。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--show-log-entries" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--show-log-entries</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=<flag></tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
执行 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">log show</tt> 时,显示或不显示日志条目。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--show-log-sum" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--show-log-sum</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=<flag></tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
执行 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">log show</tt> 时,显示或不显示日志汇总。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--skip-zero-entries" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--skip-zero-entries</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
让 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">log show</tt> 只显示数字字段非零的日志。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--infile" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--infile</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
设置时指定要读取的文件。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--state" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--state</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=<state string></tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
给 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">opstate set</tt> 命令指定状态。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--replica-log-type" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--replica-log-type</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
复制日志类型( metadata 、 data 、 bucket ),操作复制日志时需要。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--categories" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--categories</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=<list></tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
逗号分隔的一系列类目,显示使用情况时需要。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--caps" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--caps</tt><tt class="descclassname" style="font-family: "Courier New", Courier, monospace;">=<caps></tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
能力列表,如 “usage=read, write; user=read” 。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--yes-i-really-mean-it" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--yes-i-really-mean-it</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
某些特定操作需要。
配额选项
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--bucket" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--bucket</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
为配额命令指定桶。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--max-objects" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--max-objects</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
指定最大对象数(负数为禁用)。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--max-size" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--max-size</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
指定最大尺寸(单位为字节,负数为禁用)。
<dl class="option" style="margin: 0px; padding: 0px; list-style-type: none; list-style-image: none;">
<dt id="cmdoption-radosgw-admin--quota-scope" style="margin: 0px; padding: 6px 0px; list-style-type: none; list-style-image: none; font-weight: bold; clear: both;"><tt class="descname" style="font-family: "Courier New", Courier, monospace;">--quota-scope</tt></dt>
<dd style="margin: 0px; padding: 0px 0px 0px 2em; list-style-type: none; list-style-image: none;">
配额有效范围(桶、用户)。
操作管理实例:
用户管理
新建一个用户
执行下面的命令新建一个用户 (S3 接口):
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin user create --uid={username} --display-name="{display-name}" [--email={email}]</pre>
实例如下:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin user create --uid=johndoe --display-name="John Doe" --email=john@example.com</pre>
新建一个子用户
为了给用户新建一个子用户 (Swift 接口) ,你必须为该子用户指定用户的 ID(<tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">--uid={username}</tt>),子用户的 ID 以及访问级别:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin subuser create --uid={uid} --subuser={uid} --access=[ read | write | readwrite | full ]</pre>
实例如下:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin subuser create --uid=johndoe --subuser=johndoe:swift --access=full</pre>
Note:<tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">full</tt> 并不表示 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">readwrite</tt>, 因为它还包括访问权限策略.
获取用户信息
要获取一个用户的信息,你必须使用 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">user info</tt> 子命令并且制定一个用户 ID(<tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">--uid={username}</tt>) .
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin user info --uid=johndoe</pre>
修改用户信息
要修改一个用户的信息,你必须指定用户的 ID (<tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">--uid={username}</tt>),还有 你想要修改的属性值。典型的修改项主要是 access 和secret 密钥,邮件地址,显 示名称和访问级别。举例如下:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin user modify --uid=johndoe --display-name="John E. Doe"</pre>
要修改子用户的信息, 使用 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">subuser modify</tt> 子命令并且执行子用户的 ID. 举例如下:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin subuser modify --uid=johndoe:swift --access=full</pre>
用户 启用/停用
当你创建了一个用户,用户默认情况下是处于启用状态的。然而,你可以暂停用户权 限并在以后随时重新启用它们。暂停一个用户,使用 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">user suspend</tt> 子命令 然后哦指定用户的 ID:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin user suspend --uid=johndoe</pre>
要重新启用已经被停用的用户,使用 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">user enable</tt> 子命令并指明用户的 ID.
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin user enable --uid=johndoe</pre>
Note:停用一个用户后,它的子用户也会一起被停用.
删除用户
删除用户时,这个用户以及他的子用户都会被删除。当然,如果你愿意,可以只删除子用户。要删除用户(及其子用户),可使用 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">user rm</tt> 子命令并指明用户 ID :
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin user rm --uid=johndoe</pre>
只想删除子用户时,可使用 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">subuser rm</tt> 子命令并指明子用户 ID 。
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin subuser rm --subuser=johndoe:swift</pre>
其它可选操作:
- Purge Data: 加 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">--purge-data</tt> 选项可清除与此 UID 相关的所有数据。
- Purge Keys: 加 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">--purge-keys</tt> 选项可清除与此 UID 相关的所有密钥。
删除子用户
在你删除子用户的同时,也失去了 Swift 接口的访问方式,但是这个用户在系统 中还存在。要删除子用户,可使用 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">subuser rm</tt> 子命令并指明子用户 ID :
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin subuser rm --subuser=johndoe:swift</pre>
其它可选操作:
- Purge Keys: 加 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">--purge-keys</tt> 选项可清除与此 UID 相关的所有密钥。
新建一个密钥
要为用户新建一个密钥,你需要使用 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">key create</tt> 子命令。对于用户来说,需要指明用户的 ID 以及新建的密钥类型为 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">s3</tt> 。要为子用户新建一个密钥,则需要指明子用户的 ID以及密钥类型为 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">swift</tt> 。实例如下:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin key create --subuser=johndoe:swift --key-type=swift --gen-secret</pre>
新建/删除 ACCESS 密钥
用户和子用户要能使用 S3 和Swift 接口,必须有 access 密钥。在你新 建用户或者子用户的时候,如果没有指明 access 和 secret 密钥,这两 个密钥会自动生成。你可能需要新建 access 和/或 secret 密钥,不管是 手动指定还是自动生成的方式。你也可能需要删除一个 access 和 secret 。可用的选项有:
- <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">--secret=<key></tt> 指明一个 secret 密钥 (e.即手动生成).
- <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">--gen-access-key</tt> 生成一个随机的 access 密钥 (新建 S3 用户的默认选项).
- <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">--gen-secret</tt> 生成一个随机的 secret 密钥.
- <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">--key-type=<type></tt> 指定密钥类型. 这个选项的值可以是: swift, s3
要新建密钥,需要指明用户 ID.
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin key create --uid=johndoe --key-type=s3 --gen-access-key --gen-secret</pre>
你也可以使用指定 access 和 secret 密钥的方式.
要删除一个 access 密钥, 也需要指定用户 ID.
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin key rm --uid=johndoe</pre>
添加/删除 管理权限
Ceph 存储集群提供了一个管理API,它允许用户通过 REST API 执行管理功能。默认情况下,用户没有访问 这个 API 的权限。要启用用户的管理功能,需要为用 户提供管理权限。
执行下面的命令为一个用户添加管理权限:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin caps add --uid={uid} --caps={caps}</pre>
你可以给一个用户添加对用户、bucket、元数据和用量(存储使用信息)等数据的 读、写或者所有权限。举例如下:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">--caps="[users|buckets|metadata|usage|zone]=[*|read|write|read, write]" </pre>
实例如下:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin caps add --uid=johndoe --caps="users=*"</pre>
要删除某用户的管理权限,可用下面的命令:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin caps rm --uid=johndoe --caps={caps}</pre>
配额管理
设置用户配额
在你启用用户的配额前 ,你需要先设置配额参数。 例如:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin quota set --quota-scope=user --uid=<uid> [--max-objects=<num objects>] [--max-size=<max size>]</pre>
实例如下:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin quota set --quota-scope=user --uid=johndoe --max-objects=1024 --max-size=1024</pre>
最大对象数和最大存储用量的值是负数则表示不启用指定的 配额参数。
启用/禁用用户配额
在你设置了用户配额之后,你可以启用这个配额。实例如下:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin quota enable --quota-scope=user --uid=<uid></pre>
你也可以禁用已经启用了配额的用户的配额。 举例如下:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin quota-disable --quota-scope=user --uid=<uid></pre>
设置 BUCKET 配额
Bucket 配额作用于用户的某一个 bucket,通过 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">uid</tt> 指定用户。这些配额设置是独立于用户之外的。:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin quota set --uid=<uid> --quota-scope=bucket [--max-objects=<num objects>] [--max-size=<max size>]</pre>
最大对象数和最大存储用量的值是负数则表示不启用指定的 配额参数。
启用/禁用 BUCKET 配额
在你设置了 bucket 配额之后,你可以启用这个配额。实例如下:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin quota enable --quota-scope=bucket --uid=<uid></pre>
你也可以禁用已经启用了配额的 bucket 的配额。 举例如下:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin quota-disable --quota-scope=bucket --uid=<uid></pre>
获取配额信息
你可以通过用户信息 API 来获取每一个用户的配额 设置。通过 CLI 接口读取用户的配额设置信息,请执行下面的命令:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin user info --uid=<uid></pre>
更新配额统计信息
配额的统计数据的同步是异步的。你也可以通过手动获 取最新的配额统计数据为所有用户和所有 bucket 更新配额统计数据:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin user stats --uid=<uid> --sync-stats</pre>
获取用户用量统计信息
执行下面的命令获取当前用户已经消耗了配额的多少:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin user stats --uid=<uid></pre>
Note:你应该在执行 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">radosgw-admin user stats</tt> 的时候带上 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">--sync-stats</tt> 参数来获取最新的数据.
读取/设置全局配额
你可以在 region map中读取和设置配额。执行下面的命 令来获取 region map:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin regionmap get > regionmap.json</pre>
要为整个 region 设置配额,只需要简单的修改 region map 中的配额设置。然后使用 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">region set</tt> 来更新 region map即可:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin region set < regionmap.json</pre>
Note:在更新 region map 后,你必须重启网关.
用量管理
Ceph 对象网关会为每一个用户记录用量数据。你也可以通过指定日期范围来跟踪用户的用量数据。
可用选项如下:
- Start Date: 选项 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">--start-date</tt> 允许你指定一个起始日期来过滤用量数据 (format: <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">yyyy-mm-dd[HH:MM:SS]</tt>).
- End Date: 选项 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">--end-date</tt> 允许你指定一个截止日期来过滤用量数据 (format: <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">yyyy-mm-dd[HH:MM:SS]</tt>).
- Log Entries: 选项 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">--show-log-entries</tt> 允许你 指明显示用量数据的时候是否要包含日志条目。 (选项值: <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">true</tt> | <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">false</tt>).
Note:你可以指定时间为分钟和秒,但是数据存储是以一个小时的间隔存储的.
展示用量信息
显示用量统计数据,使用 <tt class="docutils literal" style="font-family: "Courier New", Courier, monospace;">usage show</tt> 子命令。显示某一个特定 用户的用量数据,你必须指定该用户的 ID。你也可以指定开始日期、结 束日期以及是否显示日志条目。:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin usage show --uid=johndoe --start-date=2012-03-01 --end-date=2012-04-01</pre>
通过去掉用户的 ID,你也可以获取所有用户的汇总的用量信息
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin usage show --show-log-entries=false</pre>
删除用量信息
对于大量使用的集群而言,用量日志可能会占用大量存储空间。你可以为所有用户或者一个特定的用户删除部分用量日志。你也可以为删除操作指定日期范围。:
<pre style="margin: 0px; white-space: pre-wrap; overflow-wrap: break-word; padding: 0px; list-style-type: none; list-style-image: none; font-family: "Courier New", Courier, monospace;">radosgw-admin usage trim --start-date=2010-01-01 --end-date=2010-12-31
radosgw-admin usage trim --uid=johndoe
radosgw-admin usage trim --uid=johndoe --end-date=2013-12-31</pre>
网友评论