Ceph Swift 접속 및 파일 업/다운로드 cloud 인프라 구축

Ceph 접속을 하기 위해 접속시 사용할 노드에
Swift client를 설치해야합니다.
아래의 명령어를 차례로 입력하면 설치됩니다.

#apt-get install python-setuptools
#easy_install pip
#pip install --upgrade setuptools
#pip install --upgrade python-swiftclient

설치가 끝나면 아래 명령어로 test해볼 수 있습니다.

#swift -A http://10.19.143.116:7480/auth/1.0 -U testuser:swift -K '244+fz2gSqoHwR3lYtSbIyomyPHf3i7rgSJrF/IA'
-A 는 Auth를 의미, 인증 Url을 넣습니다.
-U 는 User를 의미, 계정생성시에 입력한 유저명을 넣습니다.
-K 는 접속키로, 계정생성시에 받은 키를 넣습니다.

접속이 성공적으로 되었다면 아래와 같이 명령어 관련된 내용이 출력됩니다.
Command-line interface to the OpenStack Swift API.

Positional arguments:
  <subcommand>
    delete               Delete a container or objects within a container.
    download             Download objects from containers.
    list                 Lists the containers for the account or the objects
                         for a container.
    post                 Updates meta information for the account, container,
                         or object; creates containers if not present.
    copy                 Copies object, optionally adds meta
    stat                 Displays information for the account, container,
                         or object.
    upload               Uploads files or directories to the given container.
    capabilities         List cluster capabilities.
    tempurl              Create a temporary URL.
    auth                 Display auth related environment variables.


예를 들어 간단하게 정보를 조회하고자 한다면 아래의 명령어를 입력하면 됩니다.
#swift -A http://10.19.143.116:7480/auth/1.0 -U testuser:swift -K '244+fz2gSqoHwR3lYtSbIyomyPHf3i7rgSJrF/IA' stat

output :
                                    Account: v1
                                 Containers: 3
                                    Objects: 1
                                      Bytes: 190
Objects in policy "default-placement-bytes": 0
  Bytes in policy "default-placement-bytes": 0
   Containers in policy "default-placement": 3
      Objects in policy "default-placement": 1
        Bytes in policy "default-placement": 190
                              Accept-Ranges: bytes
                                X-Timestamp: 1531297697.97379
                X-Account-Bytes-Used-Actual: 4096
                                 X-Trans-Id: tx000000000000000000056-005b45bfa1-1013-default
                               Content-Type: text/plain; charset=utf-8
                     X-Openstack-Request-Id: tx000000000000000000056-005b45bfa1-1013-default


업로드시에는 아래와 같이 입력해주면 됩니다.
#swift -A http://10.19.143.116:7480/auth/1.0 -U testuser:swift -K '244+fz2gSqoHwR3lYtSbIyomyPHf3i7rgSJrF/IA' upload my-container test.txt
 my-container 는 컨테이너 이름이고, 논리적인 폴더와 같은 역할을 합니다. 해당 이름의 컨테이너가 있다면 그 컨테이너에 데이터를 저장하고 없는 경우는 해당 이름의 컨테이너를 생성하여 데이터를 저장합니다.
text.txt 는 저장할 파일의 이름입니다.

다운로드 시에는 upload를 download로 바꿔주시면 됩니다.
#swift -A http://10.19.143.116:7480/auth/1.0 -U testuser:swift -K '244+fz2gSqoHwR3lYtSbIyomyPHf3i7rgSJrF/IA' download my-container test.txt

덧글

댓글 입력 영역


구글애드

메모장

null