hadoop-aliyun
模組提供支援,可將 Aliyun 與 Aliyun 物件儲存服務 (Aliyun OSS) 整合。產生的 JAR 檔案 hadoop-aliyun.jar
也宣告對此支援所需的所有外部人工製品的傳遞依賴關係,讓下游應用程式可以輕鬆使用此支援。
若要使其成為 Apache Hadoop 的預設類別路徑,只需確保 hadoop-env.sh 中的 HADOOP_OPTIONAL_TOOLS 在清單中包含「hadoop-aliyun」。
FileSystem
介面,提供階層式檔案系統檢視。Aliyun OSS 是「物件儲存體」的一個範例。為了達成可擴充性,特別是高可用性,Aliyun OSS 放寬了傳統「POSIX」檔案系統所承諾的某些限制。
具體而言
delete()
和 rename()
是透過遞迴檔案逐檔案操作來實作的。它們會花費的時間至少與檔案數量成正比,在此期間可能會看到部分更新。delete()
和 rename()
無法保證原子性。如果中斷這些操作,檔案系統將會停留在中間狀態。仰賴此功能的 Hadoop 功能可能會出現意外行為。例如,YARN 的 AggregatedLogDeletionService 將不會移除適當的記錄檔。
您的 Aliyun 認證資料不僅會用於支付服務,它們還會提供資料的讀取和寫入存取權。擁有該帳戶的任何人都可以讀取您的資料集,而且他們也可以刪除這些資料集。
請勿透過以下方式無意間分享這些認證資料:1. 將包含機密的任何組態檔簽入 SCM。2. 將它們記錄到主控台,因為它們最終一定會被看到。3. 在 URL 中使用認證資料來定義檔案系統 URI,例如 oss://accessKeyId:accessKeySecret@directory/file
。它們最終會出現在記錄和錯誤訊息中。4. 在錯誤報告中包含機密資料。
如果您執行上述任何一項操作,請立即變更您的認證資料!
具體來說:在阿里雲 E-MapReduce 上,oss://
也受支援,但實作方式不同。如果您使用阿里雲 E-MapReduce,請遵循下列說明,並注意所有與阿里雲 OSS 整合到 E-MapReduce 中相關的問題,都只能由阿里雲自行解決:請向他們提出您的問題。
<property> <name>fs.oss.accessKeyId</name> <description>Aliyun access key ID</description> </property> <property> <name>fs.oss.accessKeySecret</name> <description>Aliyun access key secret</description> </property> <property> <name>fs.oss.credentials.provider</name> <description> Class name of a credentials provider that implements com.aliyun.oss.common.auth.CredentialsProvider. Omit if using access/secret keys or another authentication mechanism. The specified class must provide an accessible constructor accepting java.net.URI and org.apache.hadoop.conf.Configuration, or an accessible default constructor. </description> </property>
<property> <name>fs.AbstractFileSystem.oss.impl</name> <value>org.apache.hadoop.fs.aliyun.oss.OSS</value> <description>The implementation class of the OSS AbstractFileSystem. If you want to use OSS as YARN’s resource storage dir via the fs.defaultFS configuration property in Hadoop’s core-site.xml, you should add this configuration to Hadoop's core-site.xml </description> </property> <property> <name>fs.oss.endpoint</name> <description>Aliyun OSS endpoint to connect to. An up-to-date list is provided in the Aliyun OSS Documentation. </description> </property> <property> <name>fs.oss.impl</name> <value>org.apache.hadoop.fs.aliyun.oss.AliyunOSSFileSystem</value> </property> <property> <name>fs.oss.proxy.host</name> <description>Hostname of the (optinal) proxy server for Aliyun OSS connection</description> </property> <property> <name>fs.oss.proxy.port</name> <description>Proxy server port</description> </property> <property> <name>fs.oss.proxy.username</name> <description>Username for authenticating with proxy server</description> </property> <property> <name>fs.oss.proxy.password</name> <description>Password for authenticating with proxy server.</description> </property> <property> <name>fs.oss.proxy.domain</name> <description>Domain for authenticating with proxy server.</description> </property> <property> <name>fs.oss.proxy.workstation</name> <description>Workstation for authenticating with proxy server.</description> </property> <property> <name>fs.oss.attempts.maximum</name> <value>20</value> <description>How many times we should retry commands on transient errors.</description> </property> <property> <name>fs.oss.connection.establish.timeout</name> <value>50000</value> <description>Connection setup timeout in milliseconds.</description> </property> <property> <name>fs.oss.connection.timeout</name> <value>200000</value> <description>Socket connection timeout in milliseconds.</description> </property> <property> <name>fs.oss.paging.maximum</name> <value>1000</value> <description>How many keys to request from Aliyun OSS when doing directory listings at a time. </description> </property> <property> <name>fs.oss.multipart.upload.size</name> <value>10485760</value> <description>Size of each of multipart pieces in bytes.</description> </property> <property> <name>fs.oss.upload.active.blocks</name> <value>4</value> <description>Active(Concurrent) upload blocks when uploading a file.</description> </property> <property> <name>fs.oss.multipart.download.threads</name> <value>10</value> <description>The maximum number of threads allowed in the pool for multipart download and upload.</description> </property> <property> <name>fs.oss.multipart.download.ahead.part.max.number</name> <value>4</value> <description>The maximum number of read ahead parts when reading a file.</description> </property> <property> <name>fs.oss.max.total.tasks</name> <value>128</value> <description>The maximum queue number for multipart download and upload.</description> </property> <property> <name>fs.oss.max.copy.threads</name> <value>25</value> <description>The maximum number of threads allowed in the pool for copy operations.</description> </property> <property> <name>fs.oss.max.copy.tasks.per.dir</name> <value>5</value> <description>The maximum number of concurrent tasks allowed when copying a directory.</description> </property> <property> <name>fs.oss.multipart.upload.threshold</name> <value>20971520</value> <description>Minimum size in bytes before we start a multipart uploads or copy. Notice: This property is deprecated and will be removed in further version. </description> </property> <property> <name>fs.oss.multipart.download.size</name> <value>102400/value> <description>Size in bytes in each request from ALiyun OSS.</description> </property> <property> <name>fs.oss.list.version</name> <value>2</value> <description>Select which version of the OSS SDK's List Objects API to use. Currently support 2(default) and 1(older API). </description> </property> <property> <name>fs.oss.buffer.dir</name> <description>Comma separated list of directories to buffer OSS data before uploading to Aliyun OSS</description> </property> <property> <name>fs.oss.acl.default</name> <value></vaule> <description>Set a canned ACL for bucket. Value may be private, public-read, public-read-write. </description> </property> <property> <name>fs.oss.server-side-encryption-algorithm</name> <value></vaule> <description>Specify a server-side encryption algorithm for oss: file system. Unset by default, and the only other currently allowable value is AES256. </description> </property> <property> <name>fs.oss.connection.maximum</name> <value>32</value> <description>Number of simultaneous connections to oss.</description> </property> <property> <name>fs.oss.connection.secure.enabled</name> <value>true</value> <description>Connect to oss over ssl or not, true by default.</description> </property>
若要測試 oss://
檔案系統用戶端,需要兩個傳遞驗證詳細資料給測試執行器的檔案。
auth-keys.xml
core-site.xml
這兩個組態檔案必須放入 hadoop-tools/hadoop-aliyun/src/test/resources
。
core-site.xml
此檔案已預先存在,並會擷取 auth-keys.xml
中建立的組態。
在大部分情況下,都不需要修改,除非在測試期間需要設定特定非預設屬性。
auth-keys.xml
此檔案會觸發阿里雲 OSS 模組的測試。沒有此檔案,此模組中的所有測試都不會執行
它包含連線到阿里雲 OSS 所需的存取金鑰 ID/機密和代理資訊,還應提供 OSS 儲存桶 URL。
test.fs.oss.name
:阿里雲 OSS 測試的儲存桶 URL儲存桶的內容會在測試過程中清除,因此請勿將儲存桶用於測試以外的任何用途。
在 /test/resources
下建立檔案 contract-test-options.xml
。如果未定義特定檔案 fs.contract.test.fs.oss
測試路徑,這些測試將會略過。執行任何這些測試也需要憑證,它們可以從 auth-keys.xml
複製,或透過直接 XInclude 納入。以下是 contract-test-options.xml
的範例
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <include xmlns="http://www.w3.org/2001/XInclude" href="auth-keys.xml"/> <property> <name>fs.contract.test.fs.oss</name> <value>oss://spark-tests</value> </property> <property> <name>fs.oss.impl</name> <value>org.apache.hadoop.fs.aliyun.oss.AliyunOSSFileSystem</value> </property> <property> <name>fs.oss.endpoint</name> <value>oss-cn-hangzhou.aliyuncs.com</value> </property> <property> <name>fs.oss.buffer.dir</name> <value>/tmp/oss</value> </property> <property> <name>fs.oss.multipart.download.size</name> <value>102400</value> </property> </configuration>