Object Storage를 이용한 데이터 이전
    • PDF

    Object Storage를 이용한 데이터 이전

    • PDF

    Article Summary

    네이버 클라우드 플랫폼의 Cloud Hadoop은 Block Storage에 HDFS (Hadoop Distributed File System)을 구성하여 기본 저장소로 사용하고 있으며, Object Storage 연동을 지원하고 있습니다. Object Storage는 Public DNS를 제공하고 있기 때문에 인터넷 연결이 가능한 환경이라면 데이터를 쉽게 저장하고 다운로드할 수 있습니다. 네이버 클라우드 플랫폼 외부에서도 Object Storage를 이용하여 분석이 필요한 대용량 데이터를 네이버 클라우드 플랫폼으로 이전해 올 수 있는 장점이 있습니다.

    hadoop-vpc-use-ex6_0-0

    이 가이드는 위 그림과 같은 형태로 외부 원본 데이터를 네이버 클라우드 플랫폼 Object Storage로 이전하는 방법과 Object Storage에서 Cloud Hadoop HDFS로 이전하는 방법을 설명합니다.

    사전 작업

    Object Storage에서 데이터를 저장할 버킷을 생성해 주십시오.

    참고

    버킷 생성에 대한 자세한 내용은 Object Storage 사용 가이드를 참고해 주십시오.

    외부에서 Object Storage로 데이터 이전

    네이버 클라우드 플랫폼 Object Storage는 AWS S3와 호환되는 저장소이기 때문에 AWS CLI를 그대로 사용할 수 있습니다.
    자세한 내용은 Object Storage CLI 사용 가이드를 참고해 주십시오.

    참고

    AWS CLI에 대한 정보는 awscli 문서를 참고해 주십시오.

    1. 샘플 데이터 준비

    외부에서 Object Storage로 데이터 이전 테스트를 하기 위한 샘플 데이터를 다운로드해 주십시오.

    • 이 가이드에서는 샘플 데이터의 AllstarFull.csv 파일을 사용하여 데이터 이전 작업을 수행했습니다.
    참고

    제공되는 샘플 데이터는 Lahman's Baseball Database 2012 버전의 일부로, 데이터의 모든 저작권은 Sean Lahman에게 있습니다.

    2. AWS CLI 설치

    엣지 노드에 SSH로 접속한 후, pip install 명령어를 사용하여 AWS CLI를 설치해 주십시오.

    [sshuser@e-001-hadoop-example-hd ~]$ sudo pip install awscli==1.15.85
    DEPRECATION: Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).
    Collecting awscli==1.15.85
    Downloading https://files.pythonhosted.org/packages/2a/2a/e5ae9191c388db103bc197a444260c8fd4f4f44a8183eb922cd5ebf183cf/awscli-1.15.85-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 12.6MB/s
    Collecting PyYAML<=3.13,>=3.10 (from awscli==1.15.85)
    Downloading https://files.pythonhosted.org/packages/9e/a3/1d13970c3f36777c583f136c136f804d70f500168edc1edea6daa7200769/PyYAML-3.13.tar.gz (270kB)
    100% |████████████████████████████████| 276kB 26.3MB/s
    Collecting s3transfer<0.2.0,>=0.1.12 (from awscli==1.15.85)
    Downloading https://files.pythonhosted.org/packages/d7/14/2a0004d487464d120c9fb85313a75cd3d71a7506955be458eebfe19a6b1d/s3transfer-0.1.13-py2.py3-none-any.whl (59kB)
    100% |████████████████████████████████| 61kB 19.9MB/s
    Collecting rsa<=3.5.0,>=3.1.2 (from awscli==1.15.85)
    Downloading https://files.pythonhosted.org/packages/e1/ae/baedc9cb175552e95f3395c43055a6a5e125ae4d48a1d7a924baca83e92e/rsa-3.4.2-py2.py3-none-any.whl (46kB)
    100% |████████████████████████████████| 51kB 20.2MB/s
    Collecting colorama<=0.3.9,>=0.2.5 (from awscli==1.15.85)
    Downloading https://files.pythonhosted.org/packages/db/c8/7dcf9dbcb22429512708fe3a547f8b6101c0d02137acbd892505aee57adf/colorama-0.3.9-py2.py3-none-any.whl
    Collecting docutils>=0.10 (from awscli==1.15.85)
    Downloading https://files.pythonhosted.org/packages/22/cd/a6aa959dca619918ccb55023b4cb151949c64d4d5d55b3f4ffd7eee0c6e8/docutils-0.15.2-py3-none-any.whl (547kB)
    100% |████████████████████████████████| 552kB 22.5MB/s
    Collecting botocore==1.10.84 (from awscli==1.15.85)
    Downloading https://files.pythonhosted.org/packages/01/b7/cb08cd1af2bb0d0dfb393101a93b6ab6fb80f109ab7b37f2f34386c11351/botocore-1.10.84-py2.py3-none-any.whl (4.5MB)
    100% |████████████████████████████████| 4.5MB 5.7MB/s
    Collecting pyasn1>=0.1.3 (from rsa<=3.5.0,>=3.1.2->awscli==1.15.85)
    Downloading https://files.pythonhosted.org/packages/62/1e/a94a8d635fa3ce4cfc7f506003548d0a2447ae76fd5ca53932970fe3053f/pyasn1-0.4.8-py2.py3-none-any.whl (77kB)
    100% |████████████████████████████████| 81kB 25.1MB/s
    Collecting jmespath<1.0.0,>=0.7.1 (from botocore==1.10.84->awscli==1.15.85)
    Downloading https://files.pythonhosted.org/packages/07/cb/5f001272b6faeb23c1c9e0acc04d48eaaf5c862c17709d20e3469c6e0139/jmespath-0.10.0-py2.py3-none-any.whl
    Collecting python-dateutil<3.0.0,>=2.1; python_version >= "2.7" (from botocore==1.10.84->awscli==1.15.85)
    Downloading https://files.pythonhosted.org/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227kB)
    100% |████████████████████████████████| 235kB 25.9MB/s
    Requirement already satisfied: six>=1.5 in /usr/lib/python3.4/site-packages (from python-dateutil<3.0.0,>=2.1; python_version >= "2.7"->botocore==1.10.84->awscli==1.15.85) (1.15.0)
    Installing collected packages: PyYAML, jmespath, python-dateutil, docutils, botocore, s3transfer, pyasn1, rsa, colorama, awscli
    Running setup.py install for PyYAML ... done
    Successfully installed PyYAML-3.13 awscli-1.15.85 botocore-1.10.84 colorama-0.3.9 docutils-0.15.2 jmespath-0.10.0 pyasn1-0.4.8 python-dateutil-2.8.1 rsa-3.4.2 s3transfer-0.1.13
    

    3. 인증키 정보 확인

    생성해 둔 Object Storage 버킷에 접속하려면 네이버 클라우드 플랫폼 인증키 정보가 필요합니다.
    네이버 클라우드 플랫폼 포털 [마이페이지][인증키 관리] 에서 신규 API 인증키 생성 후, Access Key IDSecret Key를 확인해 주십시오.

    • 인증키에 대한 자세한 내용은 인증키 관리을 참고해 주십시오.
      hadoop-chadoop-use-ex6_1-2_ko

    4. 환경 설정

    다음 명령어로 사용 환경을 구성한 후 Object Storage 엔드포인트 주소를 넣어 확인해 주십시오.

    • 예제의 버킷 이름: example
    [sshuser@e-001-hadoop-example-hd ~]$ sudo aws configure
    AWS Access Key ID [None]: ACCESS_KEY_ID
    AWS Secret Access Key [None]: SECRET_KEY
    Default region name [None]:
    Default output format [None]:
    
    • example로 생성한 버킷 확인
    [sshuser@e-001-hadoop-example-hd ~]$ sudo aws --endpoint-url=https://kr.object.fin-ncloudstorage.com s3 ls 
    2020-11-25 08:53:42 example 
    

    5. 데이터 업로드

    AWS CLI의 cp 명령어를 사용하여 데이터를 Object Storage에 업로드한 후 정상적으로 업로드되었는지 확인해 주십시오.

    [sshuser@e-001-hadoop-example-hd ~]$ sudo aws --endpoint-url=https://kr.object.fin-ncloudstorage.com s3 cp AllstarFull.csv s3://example/
    upload: ./AllstarFull.csv to s3://example/AllstarFull.csv
    
    [sshuser@e-001-hadoop-example-hd ~]$ sudo aws --endpoint-url=https://kr.object.ncloudstorage.com s3 ls s3://example/
    2020-11-25 09:37:50 1708674492 AllstarFull.csv
    
    참고

    s3://[YOUR-BUCKET-NAME]/

    Object Storage에서 Cloud Hadoop HDFS로 데이터 이전

    Object Storage로 옮겨온 데이터를 Cloud Hadoop HDFS로 옮길 수 있습니다.

    1. Cloud Hadoop 엣지 노드 접속

    작업하고자 하는 Cloud Hadoop 클러스터의 엣지 노드에 접속해 주십시오.
    클러스터 엣지 노드에 접속 방법은 SSH로 클러스터 노드 접속 가이드를 참고해 주십시오.

    2. 액세스 확인

    다음 명령어를 사용하여 엣지 노드에서 Object Storage 버킷에 접근되는지 확인해 주십시오.

    [sshuser@e-001-hadoop-example-hd ~]$ hadoop fs -ls hdfs://hadoop-example/
    Found 12 items
    drwxrwxrwx - yarn hadoop 0 2020-11-25 10:17 hdfs://hadoop-example/app-logs
    drwxr-xr-x - hdfs hdfs 0 2020-11-25 10:16 hdfs://hadoop-example/apps
    drwxr-xr-x - yarn hadoop 0 2020-11-25 10:15 hdfs://hadoop-example/ats
    drwxr-xr-x - hdfs hdfs 0 2020-11-25 10:15 hdfs://hadoop-example/hdp
    drwx------ - livy hdfs 0 2020-11-25 10:15 hdfs://hadoop-example/livy-recovery
    drwx------ - livy hdfs 0 2020-11-25 10:16 hdfs://hadoop-example/livy2-recovery
    drwxr-xr-x - mapred hdfs 0 2020-11-25 10:15 hdfs://hadoop-example/mapred
    drwxrwxrwx - mapred hadoop 0 2020-11-25 10:15 hdfs://hadoop-example/mr-history
    drwxrwxrwx - spark hadoop 0 2020-11-25 10:20 hdfs://hadoop-example/spark-history
    drwxrwxrwx - spark hadoop 0 2020-11-25 10:20 hdfs://hadoop-example/spark2-history
    drwxrwxrwx - hdfs hdfs 0 2020-11-25 10:16 hdfs://hadoop-example/tmp
    drwxr-xr-x - hdfs hdfs 0 2020-11-25 10:16 hdfs://hadoop-example/user
    
    [sshuser@e-001-hadoop-example-hd ~]$ hadoop fs -mkdir hdfs://hadoop-example/sampledata/
    
    [sshuser@e-001-hadoop-example-hd ~]$ hadoop fs -ls s3a://example/
    
    참고

    hadoop fs -ls hdfs://[YOUR-CLUSTER-NAME]/
    hadoop fs -ls s3a://[YOUR-BUCKET-NAME]/

    3. 데이터 이전

    Hadoop의 대량 파일 복사를 위한 명령어인 distcp를 다음과 같이 사용하여 데이터 이전을 실행한 후 정상적으로 옮겨졌는지 확인해 주십시오.

    [sshuser@e-001-hadoop-example-hd ~]$ sudo -u {계정명} hadoop distcp -m 10 -bandwidth 100 s3a://example/* hdfs://hadoop-example/sampledata/
    20/11/25 10:30:14 INFO tools.DistCp: Input Options: DistCpOptions{atomicCommit=false, syncFolder=false, deleteMissing=false, ignoreFailures=false, overwrite=false, append=false, useDiff=false, fromSnapshot=null, toSnapshot=null, skipCRC=false, blocking=true, numListstatusThreads=0, maxMaps=10, mapBandwidth=100, sslConfigurationFile='null', copyStrategy='uniformsize', preserveStatus=[], preserveRawXattrs=false, atomicWorkPath=null, logPath=null, sourceFileListing=null, sourcePaths=[s3a://example/*], targetPath=hdfs://hadoop-example/sampledata, targetPathExists=true, filtersFile='null', verboseLog=false}
    20/11/25 10:30:15 INFO client.AHSProxy: Connecting to Application History server at m-002-hadoop-example-hd/10.41.73.166:10200
    20/11/25 10:30:16 INFO tools.SimpleCopyListing: Paths (files+dirs) cnt = 1; dirCnt = 0
    20/11/25 10:30:16 INFO tools.SimpleCopyListing: Build file listing completed.
    20/11/25 10:30:16 INFO tools.DistCp: Number of paths in the copy list: 1
    20/11/25 10:30:16 INFO tools.DistCp: Number of paths in the copy list: 1
    20/11/25 10:30:16 INFO client.AHSProxy: Connecting to Application History server at m-002-hadoop-example-hd/10.41.73.166:10200
    20/11/25 10:30:17 INFO client.RequestHedgingRMFailoverProxyProvider: Looking for the active RM in [rm1, rm2]...
    20/11/25 10:30:17 INFO client.RequestHedgingRMFailoverProxyProvider: Found active RM [rm2]
    20/11/25 10:30:17 INFO mapreduce.JobSubmitter: number of splits:1
    20/11/25 10:30:17 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1606266944151_0003
    20/11/25 10:30:18 INFO impl.YarnClientImpl: Submitted application application_1606266944151_0003
    20/11/25 10:30:18 INFO mapreduce.Job: The url to track the job: http://m-002-hadoop-example-hd:8088/proxy/application_1606266944151_0003/
    20/11/25 10:30:18 INFO tools.DistCp: DistCp job-id: job_1606266944151_0003
    20/11/25 10:30:18 INFO mapreduce.Job: Running job: job_1606266944151_0003
    20/11/25 10:30:26 INFO mapreduce.Job: Job job_1606266944151_0003 running in uber mode : false
    20/11/25 10:30:26 INFO mapreduce.Job: map 0% reduce 0%
    20/11/25 10:30:39 INFO mapreduce.Job: map 100% reduce 0%
    20/11/25 10:33:13 INFO mapreduce.Job: Job job_1606266944151_0003 completed successfully
    20/11/25 10:33:13 INFO mapreduce.Job: Counters: 38
    File System Counters
    FILE: Number of bytes read=0
    FILE: Number of bytes written=158446
    FILE: Number of read operations=0
    FILE: Number of large read operations=0
    FILE: Number of write operations=0
    HDFS: Number of bytes read=394
    HDFS: Number of bytes written=1708674492
    HDFS: Number of read operations=13
    HDFS: Number of large read operations=0
    HDFS: Number of write operations=4
    S3A: Number of bytes read=1708674492
    S3A: Number of bytes written=0
    S3A: Number of read operations=3
    S3A: Number of large read operations=0
    S3A: Number of write operations=0
    Job Counters
    Launched map tasks=1
    Other local map tasks=1
    Total time spent by all maps in occupied slots (ms)=328500
    Total time spent by all reduces in occupied slots (ms)=0
    Total time spent by all map tasks (ms)=164250
    Total vcore-milliseconds taken by all map tasks=164250
    Total megabyte-milliseconds taken by all map tasks=168192000
    Map-Reduce Framework
    Map input records=1
    Map output records=0
    Input split bytes=138
    Spilled Records=0
    Failed Shuffles=0
    Merged Map outputs=0
    GC time elapsed (ms)=392
    CPU time spent (ms)=27370
    Physical memory (bytes) snapshot=231428096
    Virtual memory (bytes) snapshot=2531233792
    Total committed heap usage (bytes)=150994944
    File Input Format Counters
    Bytes Read=256
    File Output Format Counters
    Bytes Written=0
    org.apache.hadoop.tools.mapred.CopyMapper$Counter
    BYTESCOPIED=1708674492
    BYTESEXPECTED=1708674492
    COPY=1
    
    [sshuser@e-001-hadoop-example-hd ~]$ hadoop fs -ls hdfs://hadoop-example/sampledata/
    Found 1 items
    -rw-r--r-- 2 sshuser hdfs 1708674492 2020-11-25 10:33 hdfs://hadoop-example/sampledata/AllstarFull.csv
    
    참고

    구문 형식: hadoop distcp -m 10 -bandwidth 100 s3a://[YOUR-BUCKET-NAME]/* hdfs://[YOUR-CLUSTER-NAME]/sampledata/

    참고

    단일 파일 복사 시 hadoop put 명령어를 사용하여 데이터를 이전할 수 있습니다.


    이 문서가 도움이 되었습니까?

    What's Next
    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.