Aliyun OSS 확장
Aliyun OSS 확장 (Aliyun OSS)
Alibaba Cloud는 세계에서 3번째로 큰 클라우드 인프라 제공업체예요. OSS(객체 저장 서비스, Object Storage Service)라는 자체 저장 솔루션을 제공해요. 이 문서는 OSS를 Druid deep storage로 사용하는 방법을 설명해요.
출처: 문서
본문
Alibaba Cloud는 세계에서 3번째로 큰 클라우드 인프라 제공업체예요. 자체 저장 솔루션인 OSS(Object Storage Service)를 제공해요.
이 문서는 OSS를 Druid deep storage로 사용하는 방법을 설명해요.
설치 (Installation)
Druid와 함께 제공되는 pull-deps 도구를 사용해 middle manager와 historical 노드에 여기 설명된 대로 aliyun-oss-extensions 확장을 설치하세요.
java -classpath "{YOUR_DRUID_DIR}/lib/*" org.apache.druid.cli.Main tools pull-deps -c org.apache.druid.extensions.contrib:aliyun-oss-extensions:{YOUR_DRUID_VERSION}
활성화 (Enabling)
설치 후 common.runtime.properties의 druid.extensions.loadList에 이 aliyun-oss-extensions 확장을 추가하고 middle manager와 historical 노드를 재시작하세요.
설정 (Configuration)
먼저 common.runtime.properties에 다음 OSS 구성을 추가하세요.
OSS 저장소의 endpoint URL.
| Property | Description | Required |
|---|---|---|
druid.oss.accessKey |
OSS bucket에 접근하는 데 사용할 계정의 AccessKey ID |
yes |
druid.oss.secretKey |
OSS bucket에 접근하는 데 사용할 계정의 AccessKey Secret |
yes |
druid.oss.endpoint |
Druid 클러스터가 OSS bucket과 같은 Alibaba Cloud 리전에 호스팅되어 있다면 내부 네트워크 endpoint url을 사용하는 것이 좋아요. 그러면 OSS bucket으로의 인바운드·아웃바운드 트래픽이 무료예요. | yes |
OSS를 deep storage로 사용하려면 다음 구성을 추가하세요:
| Property | Description | Required |
|---|---|---|
druid.storage.type |
전역 deep storage 제공자. 이 확장을 사용하려면 oss로 설정해야 해요. |
yes |
druid.storage.oss.bucket |
저장 bucket 이름 | yes |
druid.storage.oss.prefix |
segment가 게시될 폴더. druid/segments를 권장해요. |
No |
OSS를 segment 파일의 deep storage로 사용한다면 index 로그도 OSS에 저장하는 것을 권장해요.
이를 위해 다음 구성을 추가하세요:
| Property | Description | Required |
|---|---|---|
druid.indexer.logs.type |
전역 deep storage 제공자. 이 확장을 사용하려면 oss로 설정해야 해요. |
yes |
druid.indexer.logs.oss.bucket |
로그를 보관하는 데 사용하는 bucket. druid.storage.oss.bucket과 같을 수 있어요. |
yes |
druid.indexer.logs.oss.prefix |
로그 파일이 게시될 폴더. druid/logs를 권장해요. |
no |
OSS에서 데이터 읽기
현재 Web Console은 OSS에서의 ingestion을 지원하지 않지만, OSS의 input source 구성을 가진 ingestion task를 제출하면 할 수 있어요.
아래는 OSS의 input source 구성을 보여줘요.
OSS Input Source
ingestion할 OSS 객체가 있는 위치의 URI로 이루어진 JSON 배열.
| property | description | Required |
|---|---|---|
| type | oss여야 해요. |
yes |
| uris | 예를 들어 oss://{your_bucket}/{source_file_path} |
uris 또는 prefixes 또는 objects 중 하나는 설정해야 해요 |
| prefixes | ingestion할 OSS 객체 위치의 URI 접두사 JSON 배열. 주어진 접두사 중 하나로 시작하는 빈 객체는 건너뛰어요. | uris 또는 prefixes 또는 objects 중 하나는 설정해야 해요 |
| objects | ingestion할 OSS object의 JSON 배열. | uris 또는 prefixes 또는 objects 중 하나는 설정해야 해요 |
| properties | 기본 OSS 구성을 재정의하기 위한 설정. 자세한 내용은 아래 참고. | no (지정하지 않으면 기본값이 사용됨) |
OSS Object
| Property | Description | Default | Required |
|---|---|---|---|
| bucket | OSS bucket 이름 | None | yes |
| path | 데이터가 위치한 경로 | None | yes |
Properties Object
| Property | Description | Default | Required |
|---|---|---|---|
| accessKey | 이 OSS InputSource의 access key에 대한 Password Provider 또는 일반 텍스트 문자열 | None | yes |
| secretKey | 이 OSS InputSource의 secret key에 대한 Password Provider 또는 일반 텍스트 문자열 | None | yes |
| endpoint | 이 OSS InputSource의 endpoint | None | no |
파일에서 읽기
Druid의 quickstart/tutorial 디렉터리에서 찾을 수 있는 rollup-data.json 파일이 Druid가 구성된 bucket의 OSS bucket에 있는 druid 폴더에 업로드되었다고 가정해 봐요.
이 경우 OSS input source의 uris 속성을 사용해 읽을 수 있어요:
{
"type" : "index_parallel",
"spec" : {
"dataSchema" : {
"dataSource" : "rollup-tutorial-from-oss",
"timestampSpec": {
"column": "timestamp",
"format": "iso"
},
"dimensionsSpec" : {
"dimensions" : [
"srcIP",
"dstIP"
]
},
"metricsSpec" : [
{ "type" : "count", "name" : "count" },
{ "type" : "longSum", "name" : "packets", "fieldName" : "packets" },
{ "type" : "longSum", "name" : "bytes", "fieldName" : "bytes" }
],
"granularitySpec" : {
"type" : "uniform",
"segmentGranularity" : "week",
"queryGranularity" : "minute",
"intervals" : ["2018-01-01/2018-01-03"],
"rollup" : true
}
},
"ioConfig" : {
"type" : "index_parallel",
"inputSource" : {
"type" : "oss",
"uris" : [
"oss://{YOUR_BUCKET_NAME}/druid/rollup-data.json"
]
},
"inputFormat" : {
"type" : "json"
},
"appendToExisting" : false
},
"tuningConfig" : {
"type" : "index_parallel",
"maxRowsPerSegment" : 5000000,
"maxRowsInMemory" : 25000
}
}
}
위 ingestion task spec을 http://{YOUR_ROUTER_IP}:8888/druid/indexer/v1/task로 POST하면 indexing service가 ingestion할 ingestion task를 생성해요.
폴더의 파일 읽기
같은 폴더의 파일을 읽고 싶다면 파일 URI를 하나씩 지정하는 대신 prefixes 속성을 사용해 Druid가 입력 파일을 찾을 폴더 이름을 지정할 수 있어요.
...
"ioConfig" : {
"type" : "index_parallel",
"inputSource" : {
"type" : "oss",
"prefixes" : [
"oss://{YOUR_BUCKET_NAME}/2020", "oss://{YOUR_BUCKET_NAME}/2021"
]
},
"inputFormat" : {
"type" : "json"
},
"appendToExisting" : false
}
...
위 spec은 ingestion task에 2020과 2021 폴더 아래의 모든 파일을 읽으라고 지시해요.
다른 bucket에서 읽기
Druid가 구성된 bucket과 다른 bucket의 파일을 읽으려면, task 제출 시 OSS InputSource의 objects 속성을 아래처럼 사용하세요:
...
"ioConfig" : {
"type" : "index_parallel",
"inputSource" : {
"type" : "oss",
"objects" : [
{"bucket": "YOUR_BUCKET_NAME", "path": "druid/rollup-data.json"}
]
},
"inputFormat" : {
"type" : "json"
},
"appendToExisting" : false
}
...
커스텀 accessKey로 읽기
기본 druid.oss.accessKey가 bucket에 접근할 수 없다면 properties로 이 비밀 정보를 커스터마이즈할 수 있어요:
...
"ioConfig" : {
"type" : "index_parallel",
"inputSource" : {
"type" : "oss",
"objects" : [
{"bucket": "YOUR_BUCKET_NAME", "path": "druid/rollup-data.json"}
],
"properties": {
"endpoint": "YOUR_ENDPOINT_OF_BUCKET",
"accessKey": "YOUR_ACCESS_KEY",
"secretKey": "YOUR_SECRET_KEY"
}
},
"inputFormat" : {
"type" : "json"
},
"appendToExisting" : false
}
...
이 properties는 위 uris·objects·prefixes 속성 중 어디에든 적용할 수 있어요.
문제 해결 (Troubleshooting)
OSS를 deep storage로 사용하거나 OSS에서 읽을 때 사용자가 가장 많이 겪는 문제는 OSS 권한과 관련돼 있어요.
해결 방법은 공식 OSS permission troubleshooting document를 참고하세요.
더 알아보기 (Learn more)
- pull-deps — 확장을 설치하는 도구를 알아봐요.
- Community extensions — 확장 로드 목록에 추가하는 방법을 배워요.
- Deep storage — deep storage의 개념을 이해해요.