이번 포스트는 Elasticsearch를 공부하면서 참고한 자료들을 단순히 주제별로 정리한 포스트입니다.

 

1. ELK 스택

Elasticsearch + Logstash + Kibana 스택 구축 가이드

Digital Ocean - [how to install]

 

2. elasticsearch-dump [엘라스틱서치-덤프]

엘라스틱 서치에 있는 파일들을 json 포맷이나 csv 포맷으로 저장하는 파이썬 모듈 

2.1. Copy

2.2. Backup

 

3.4. merge

curl -XPOST 'localhost:9200/kimchy,elasticsearch/_forcemerge?pretty'

Best way, using reindex API

POST _reindex
{
  "conflicts": "proceed",
  "source": {
  "index": ["twitter", "blog"],
  "type": ["tweet", "post"]
  },
  "dest": {
  "index": "all_together"
  }
}

 

3.5. mapping

PUT post
{
  "mappings":{
    "nulled":{
      "properties":{
        "user":{
        "type":"text"
        },
        "title":{
        "type":"text"
        },
        "detail":{
        "type":"text"
        },
        "url":{
        "type":"text"
        },
        "datetime":{
        "type":"date","format":"YYYY-MM-dd HH:mm"
        }
     }
   }
}



반응형

이번 포스트의 주제는 파이썬으로 azure 서버 blob 스토리지 관리 입니다.

azure 에서 blob 스토리지를 생성하고 관리하는 과정은 다음 포스트에서 단계적으로 다룰 예정이며, 이번 포스트에서는 azure blob 스토리지에 있는 파일들을 로컬에서 저장하는 역할을 하는 파이썬 스크립트에 대해 작성하도록 하겠습니다!

 

먼저, 테스팅한 환경 정보입니다!

 

- 우분투 18.04 lts 환경

- 파이썬 패키지(pip)가 설치되어 있고, 파이썬 2.x 활용

 

파이썬 스크립트 작성 전, 확인해야하는 요소들

- account_name ( 여기서 name에 있는 정보들이 account_name 입니다. )

 

 

- access keys ( 여기서 account_name과 동시에 access keys 정보를 확인할 수 있습니다. )

해당 탭은 storage accounts 탭에서 특정 account에 접근 시 활성화되는 관리 창입니다.

( 관리 창이라는 표현이 맞는 지 모르겠습니다ㅠ 혹시 적절한 표현을 아시는 분은 피드백주시면 바로 반영하도록 하겠습니다. )

 

 

 

- container_name

특정 account에 접근하신 다음, 아래와 같이 blobs 탭이 창에 활성화되실텐데, 여기서 blobs에 접근하시면,

아래와 같은 정보들이 보여지게 됩니다. 여기서 name에 있는 정보들이 container_name 입니다.

 

 

 

 

다음은 azure blob 스토리지로부터의 파일 다운로드를 위한 파이썬 스크립트입니다.

from azure.storage.blob import BlockBlobServiceimport os

#connect azure blob storage
#azure blob storage와의 연동
block_blob_service = BlockBlobService(account_name='<account name>', account_key='<access keys>')
 
#set the saved file information
#로컬에서의 파일 저장 경로 설정
local_path = '<file path>'

#azure blob 스토리지 내의 저장할 파일 정보 설정
local_file_name = '<file name>'container_name = '<container_name>'

full_path_to_file = os.path.join(local_path, str.replace(local_file_name ,'.txt', '_DOWNLOADED.txt'))print("\nDownloading blob to " + full_path_to_file)block_blob_service.get_blob_to_path(container_name, local_file_name, full_path_to_file)

 

Reference

참고자료

 

Microsoft Azure Storage Library for Python

https://azure-storage.readthedocs.io

https://github.com/Azure/azure-storage-python

 

반응형

+ Recent posts