| |
| |
| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="utf-8"> |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| |
| <meta name="description" content="Hadoop Ozone Documentation"> |
| |
| <title>Documentation for Apache Hadoop Ozone</title> |
| |
| |
| <link href="../../css/bootstrap.min.css" rel="stylesheet"> |
| |
| |
| <link href="../../css/ozonedoc.css" rel="stylesheet"> |
| |
| </head> |
| |
| |
| <body> |
| |
| |
| <nav class="navbar navbar-inverse navbar-fixed-top"> |
| <div class="container-fluid"> |
| <div class="navbar-header"> |
| <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#sidebar" aria-expanded="false" aria-controls="navbar"> |
| <span class="sr-only">Toggle navigation</span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| </button> |
| <a href="#" class="navbar-left" style="height: 50px; padding: 5px 5px 5px 0;"> |
| <img src="../../ozone-logo-small.png" width="40"/> |
| </a> |
| <a class="navbar-brand hidden-xs" href="#"> |
| Apache Hadoop Ozone/HDDS documentation |
| </a> |
| <a class="navbar-brand visible-xs-inline" href="#">Hadoop Ozone</a> |
| </div> |
| <div id="navbar" class="navbar-collapse collapse"> |
| <ul class="nav navbar-nav navbar-right"> |
| <li><a href="https://github.com/apache/hadoop-ozone">Source</a></li> |
| <li><a href="https://hadoop.apache.org">Apache Hadoop</a></li> |
| <li><a href="https://apache.org">ASF</a></li> |
| </ul> |
| </div> |
| </div> |
| </nav> |
| |
| |
| <div class="container-fluid"> |
| <div class="row"> |
| |
| <div class="col-sm-2 col-md-2 sidebar" id="sidebar"> |
| <ul class="nav nav-sidebar"> |
| |
| |
| |
| <li class=""> |
| |
| <a href="../../zh/"> |
| |
| |
| |
| <span>概述</span> |
| </a> |
| </li> |
| |
| |
| |
| <li class=""> |
| |
| <a href="../../zh/start.html"> |
| |
| |
| |
| <span>快速入门</span> |
| </a> |
| </li> |
| |
| |
| |
| <li class=""> |
| |
| <a href="../../zh/shell.html"> |
| |
| |
| |
| <span>命令行接口</span> |
| </a> |
| </li> |
| |
| |
| |
| <li class=""> |
| |
| <a href="../../zh/interface.html"> |
| |
| |
| |
| <span>编程接口</span> |
| </a> |
| </li> |
| |
| |
| |
| <li class=""> |
| |
| <a href="../../zh/gdpr.html"> |
| |
| |
| |
| <span>GDPR</span> |
| </a> |
| </li> |
| |
| |
| |
| <li class=""> |
| |
| <a href="../../zh/concept.html"> |
| |
| |
| |
| <span>概念</span> |
| </a> |
| </li> |
| |
| |
| <li class="visible-xs"><a href="#">References</a> |
| <ul class="nav"> |
| <li><a href="https://github.com/apache/hadoop"><span class="glyphicon glyphicon-new-window" aria-hidden="true"></span> Source</a></li> |
| <li><a href="https://hadoop.apache.org"><span class="glyphicon glyphicon-new-window" aria-hidden="true"></span> Apache Hadoop</a></li> |
| <li><a href="https://apache.org"><span class="glyphicon glyphicon-new-window" aria-hidden="true"></span> ASF</a></li> |
| </ul></li> |
| </ul> |
| |
| </div> |
| |
| <div class="col-sm-10 col-sm-offset-2 col-md-10 col-md-offset-2 main"> |
| |
| |
| |
| <div class="col-md-9"> |
| <nav aria-label="breadcrumb"> |
| <ol class="breadcrumb"> |
| <li class="breadcrumb-item"><a href="../../">Home</a></li> |
| <li class="breadcrumb-item" aria-current="page"><a href="../../zh/interface.html">编程接口</a></li> |
| <li class="breadcrumb-item active" aria-current="page">S3 协议接口</li> |
| </ol> |
| </nav> |
| |
| |
| |
| <div class="pull-right"> |
| |
| |
| <a href="../../interface/s3.html"><span class="label label-success">English</span></a> |
| |
| |
| |
| |
| </div> |
| |
| |
| <div class="col-md-9"> |
| <h1>S3 协议接口</h1> |
| |
| |
| |
| <!--- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <p>Ozone 提供了兼容 S3 的 REST 接口,你可以使用任何兼容 S3 的工具来操作 Ozone 的对象存储数据。</p> |
| |
| <h2 id="起步">起步</h2> |
| |
| <p>S3 网关是提供兼容 S3 的 API 的独立组件,它应当和普通的 Ozone 组件分别启动。</p> |
| |
| <p>你可以使用发行包启动一个基于 docker 的集群,其中会包括 S3 网关。</p> |
| |
| <p>进入 <code>compose/ozones3</code> 目录,启动服务:</p> |
| <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">docker-compose up -d</code></pre></div> |
| <p>你可以通过 <code>http://localhost:9878</code> 访问 S3 网关。</p> |
| |
| <h2 id="url-规范">URL 规范</h2> |
| |
| <p>Ozone S3 网关既支持虚拟主机风格的 URL 作为桶地址(形如:<a href="http://bucketname.host:9878),也支持多级路径风格的">http://bucketname.host:9878),也支持多级路径风格的</a> URL 作为桶地址(形如 <a href="http://host:9878/bucketname)。">http://host:9878/bucketname)。</a></p> |
| |
| <p>默认使用多级路径风格,如果要使用虚拟主机风格的 URL,在 <code>ozone-site.xml</code> 中设置你的主域名:</p> |
| <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#f92672"><property></span> |
| <span style="color:#f92672"><name></span>ozone.s3g.domain.name<span style="color:#f92672"></name></span> |
| <span style="color:#f92672"><value></span>s3g.internal<span style="color:#f92672"></value></span> |
| <span style="color:#f92672"></property></span></code></pre></div> |
| <h2 id="桶浏览器">桶浏览器</h2> |
| |
| <p>在桶的 URL 中加上 <code>?browser=true</code>,就可以在浏览器中浏览桶。</p> |
| |
| <p>比如,<code>testbucket</code> 桶中的内容可以在浏览器中用 <a href="http://localhost:9878/testbucket?browser=true">http://localhost:9878/testbucket?browser=true</a> 来查看。</p> |
| |
| <h2 id="已实现的-rest-端点">已实现的 REST 端点</h2> |
| |
| <p>S3 网关服务的操作:</p> |
| |
| <table> |
| <thead> |
| <tr> |
| <th>端点</th> |
| <th>状态</th> |
| </tr> |
| </thead> |
| |
| <tbody> |
| <tr> |
| <td>GET 服务</td> |
| <td>已实现</td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <p>桶操作:</p> |
| |
| <table> |
| <thead> |
| <tr> |
| <th>端点</th> |
| <th>状态</th> |
| <th>备注</th> |
| </tr> |
| </thead> |
| |
| <tbody> |
| <tr> |
| <td>GET 桶(列举对象)第二版</td> |
| <td>已实现</td> |
| <td></td> |
| </tr> |
| |
| <tr> |
| <td>HEAD 桶</td> |
| <td>已实现</td> |
| <td></td> |
| </tr> |
| |
| <tr> |
| <td>DELETE 桶</td> |
| <td>已实现</td> |
| <td></td> |
| </tr> |
| |
| <tr> |
| <td>PUT 桶 (创建桶)</td> |
| <td>已实现</td> |
| <td></td> |
| </tr> |
| |
| <tr> |
| <td>Delete 多个对象 (POST)</td> |
| <td>已实现</td> |
| <td></td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <p>对象操作:</p> |
| |
| <table> |
| <thead> |
| <tr> |
| <th>端点</th> |
| <th>状态</th> |
| <th>备注</th> |
| </tr> |
| </thead> |
| |
| <tbody> |
| <tr> |
| <td>PUT 对象</td> |
| <td>已实现</td> |
| <td></td> |
| </tr> |
| |
| <tr> |
| <td>GET 对象</td> |
| <td>已实现</td> |
| <td></td> |
| </tr> |
| |
| <tr> |
| <td>分块上传</td> |
| <td>已实现</td> |
| <td>但不包括当前分块上传的进度</td> |
| </tr> |
| |
| <tr> |
| <td>DELETE 对象</td> |
| <td>已实现</td> |
| <td></td> |
| </tr> |
| |
| <tr> |
| <td>HEAD 对象</td> |
| <td>已实现</td> |
| <td></td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <h2 id="安全">安全</h2> |
| |
| <p>如果不启用安全机制,你可以*使用*<strong>任何</strong> AWS_ACCESS_KEY_ID 和 AWS_SECRET_ACCESS_KEY 来访问 Ozone 的 S3 服务。</p> |
| |
| <p>在启用了安全机制的情况下,你可以通过 <code>ozone s3 gesecret</code> 命令获取 key 和 secret(需要进行 Kerberos 认证)。</p> |
| <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">/etc/security/keytabs/testuser.keytab testuser/scm@EXAMPLE.COM |
| ozone s3 getsecret |
| awsAccessKey<span style="color:#f92672">=</span>testuser/scm@EXAMPLE.COM |
| awsSecret<span style="color:#f92672">=</span>c261b6ecabf7d37d5f9ded654b1c724adac9bd9f13e247a235e567e8296d2999</code></pre></div> |
| <p>现在你可以使用 key 和 secret 来访问 S3 endpoint:</p> |
| <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">export AWS_ACCESS_KEY_ID<span style="color:#f92672">=</span>testuser/scm@EXAMPLE.COM |
| export AWS_SECRET_ACCESS_KEY<span style="color:#f92672">=</span>c261b6ecabf7d37d5f9ded654b1c724adac9bd9f13e247a235e567e8296d2999 |
| aws s3api --endpoint http://localhost:9878 create-bucket --bucket bucket1</code></pre></div> |
| <h2 id="s3-桶和-ozone-桶的映射">S3 桶和 Ozone 桶的映射</h2> |
| |
| <p><strong>注意</strong>: Ozone 对 S3 REST 端点中缺失的卷都做了标记,在底层实现上,S3 的桶名被映射到 Ozone 桶的位置(取决于给定的认证信息)。</p> |
| |
| <p>要显示一个 S3 桶存储的位置,使用 <code>ozone s3 path <bucketname></code> 命令。</p> |
| <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">aws s3api --endpoint-url http://localhost:9878 create-bucket --bucket<span style="color:#f92672">=</span>bucket1 |
| |
| ozone s3 path bucket1 |
| Volume name <span style="color:#66d9ef">for</span> S3Bucket is : s3thisisakey |
| Ozone FileSystem Uri is : o3fs://bucket1.s3thisisakey</code></pre></div> |
| <h2 id="客户端">客户端</h2> |
| |
| <h3 id="aws-命令行接口">AWS 命令行接口</h3> |
| |
| <p>通过指定自定义的 –endpoint 选项,<code>aws</code> 命令行接口可以在 Ozone S3 上使用。</p> |
| <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">aws s3api --endpoint http://localhost:9878 create-bucket --bucket buckettest</code></pre></div> |
| <p>或者</p> |
| <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">aws s3 ls --endpoint http://localhost:9878 s3://buckettest</code></pre></div> |
| <h3 id="s3-fuse-驱动-goofys">S3 Fuse 驱动(goofys)</h3> |
| |
| <p>Goofys 是一个 S3 FUSE 驱动,可以将 Ozone 的桶挂载到 POSIX 文件系统。</p> |
| <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">goofys --endpoint http://localhost:9878 bucket1 /mount/bucket1</code></pre></div> |
| |
| |
| </div> |
| |
| </div> |
| </div> |
| </div> |
| </div> |
| |
| |
| |
| |
| <script src="../../js/jquery-3.4.1.min.js"></script> |
| <script src="../../js/ozonedoc.js"></script> |
| <script src="../../js/bootstrap.min.js"></script> |
| |
| |
| </body> |
| |
| </html> |