Hadoop-Aliyun 모듈: Aliyun Web Services 통합
Hadoop-Aliyun 모듈: Aliyun Web Services 통합
hadoop-aliyun 모듈은 Aliyun Object Storage Service (Aliyun OSS)와의 Aliyun 통합을 지원해요. 생성된 JAR 파일 hadoop-aliyun.jar는 이 지원에 필요한 모든 외부 artifact에 대한 전이적(transitive) 의존성도 선언해요 — 다운스트림 애플리케이션이 이 지원을 쉽게 사용할 수 있게 해줘요. Apache Hadoop의 기본 클래스패스의 일부로 만들려면 hadoop-env.sh의 HADOOP_OPTIONAL_TOOLS 목록에 'hadoop-aliyun'이 있는지 확인하면 돼요.
출처: 문서
본문
개요 (Overview)
hadoop-aliyun 모듈은 Aliyun Object Storage Service (Aliyun OSS)와의 Aliyun 통합을 지원해요. 생성된 JAR 파일 hadoop-aliyun.jar는 이 지원에 필요한 모든 외부 artifact에 대한 전이적 의존성도 선언해요 — 다운스트림 애플리케이션이 이 지원을 쉽게 사용할 수 있게 해줘요. Apache Hadoop의 기본 클래스패스의 일부로 만들려면 hadoop-env.sh의 HADOOP_OPTIONAL_TOOLS 목록에 'hadoop-aliyun'이 있는지 확인하면 돼요.
기능 (Features)
- Aliyun OSS에 저장된 데이터를 읽고 씀.
- 표준 Hadoop
FileSystem인터페이스를 구현해 계층적 파일시스템 뷰를 제시. - MapReduce 작업의 데이터 소스 또는 싱크 역할을 할 수 있음.
경고 1: 객체 스토어는 파일시스템이 아니다 (Warning #1: Object Stores are not filesystems)
Aliyun OSS는 "객체 스토어"의 한 예예요. 확장성과 특히 고가용성을 달성하기 위해 Aliyun OSS는 클래식 "POSIX" 파일시스템이 약속하는 제약 중 일부를 완화했어요. 특히:
- 원자적 연산 (Atomic operations):
delete()와rename()은 재귀적인 파일별(file-by-file) 연산으로 구현돼요. 파일 수에 비례하는 시간이 최소한 걸리며, 그 동안 부분 업데이트가 보일 수 있어요.delete()와rename()은 원자성을 보장할 수 없어요. 연산이 중단되면 파일시스템은 중간 상태로 남아요. - 파일 소유자와 그룹은 유지되지만 권한 모델은 강제되지 않아요. 인가는 Aliyun Resource Access Management (Aliyun RAM)을 통해 전체 Aliyun 계정 수준에서 발생해요.
- 디렉터리 마지막 접근 시간은 추적되지 않아요.
- append 연산은 지원되지 않아요.
경고 2: 디렉터리 마지막 접근 시간은 추적되지 않는다 (Warning #2: Directory last access time is not tracked)
이것에 의존하는 Hadoop 기능은 예기치 않은 동작을 할 수 있어요. 예를 들어 YARN의 AggregatedLogDeletionService는 적절한 로그 파일을 제거하지 않을 거예요.
경고 3: 당신의 Aliyun 자격 증명은 가치가 있다 (Warning #3: Your Aliyun credentials are valuable)
당신의 Aliyun 자격 증명은 서비스 비용을 지불할 뿐만 아니라 데이터에 대한 읽기·쓰기 접근을 제공해요. 계정을 가진 사람은 누구나 데이터셋을 읽을 수 있을 뿐만 아니라 삭제할 수도 있어요. 자격 증명은 안전하게 보관하고 데이터를 보호해야 해요.
경고 4: Aliyun E-MapReduce가 제공하는 Aliyun OSS 클라이언트는 이 구현과 다르다 (Warning #4: The Aliyun OSS client provided by Aliyun E-MapReduce are different from this implementation)
이 Hadoop-Aliyun 구현과 Aliyun의 E-MapReduce 배포는 다른 것을 제공해요. 특정 구성이 둘 사이에 다르게 동작한다면 이 문서에 설명된 동작이 표준이에요.
OSS 인증 속성 (OSS Authentication properties)
<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>
기타 속성 (Other properties)
<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>10</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>524288</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.fast.upload.buffer</name>
<value>disk</value>
<description>
The buffering mechanism to use.
Values: disk, array, bytebuffer, array_disk, bytebuffer_disk.
"disk" will use the directories listed in fs.oss.buffer.dir as
the location(s) to save data prior to being uploaded.
"array" uses arrays in the JVM heap
"bytebuffer" uses off-heap memory within the JVM.
Both "array" and "bytebuffer" will consume memory in a single stream up to the number
of blocks set by:
fs.oss.multipart.upload.size * fs.oss.upload.active.blocks.
If using either of these mechanisms, keep this value low
The total number of threads performing work across all threads is set by
fs.oss.multipart.download.threads(Currently fast upload shares the same thread tool with download.
The thread pool size is specified in "fs.oss.multipart.download.threads"),
with fs.oss.max.total.tasks values setting the number of queued work items.
"array_disk" and "bytebuffer_disk" support fallback to disk.
</description>
</property>
<property>
<name>fs.oss.fast.upload.memory.limit</name>
<value>1073741824</value>
<description>
Memory limit of "array_disk" and "bytebuffer_disk" upload buffers.
Will fallback to disk buffers if used memory reaches the limit.
</description>
</property>
<property>
<name>fs.oss.buffer.dir</name>
<value>${env.LOCAL_DIRS:-${hadoop.tmp.dir}}/oss</value>
<description>Comma separated list of directories to buffer
OSS data before uploading to Aliyun OSS.
Yarn container path will be used as default value on yarn applications,
otherwise fall back to hadoop.tmp.dir
</description>
</property>
<property>
<name>fs.oss.acl.default</name>
<value></value>
<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></value>
<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>
hadoop-aliyun 모듈 테스트 (Testing the hadoop-aliyun Module)
oss:// 파일시스템 클라이언트를 테스트하려면 테스트 러너에 인증 세부 정보를 전달하는 두 파일이 필요해요:
auth-keys.xmlcore-site.xml
이 두 구성 파일은 hadoop-tools/hadoop-aliyun/src/test/resources에 넣어야 해요.
core-site.xml
이 파일은 사전에 존재하며 auth-keys.xml에 만든 구성을 소스로 참조해요. 대부분의 경우 수정이 필요 없어요. 테스트 중에 특정 비-기본 속성을 설정해야 하는 경우를 제외하고요.
auth-keys.xml
이 파일은 Aliyun OSS 모듈의 테스트를 트리거해요. 이 파일이 없으면 이 모듈의 어떤 테스트도 실행되지 않아요. Aliyun OSS에 연결하는 데 필요한 access key Id/secret, 프록시 정보가 들어 있고, OSS bucket URL도 제공해야 해요.
test.fs.oss.name: Aliyun OSS 테스트용 bucket의 URL. 테스트 과정에서 bucket의 내용이 정리되므로, 테스트 목적 외에는 bucket을 사용하지 마세요.
Hadoop contract 테스트 실행 (Run Hadoop contract tests)
/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>
더 알아보기 (Learn more)
- 원문: 문서