OpenSearch - 3sam5oh/webtoon-search-service GitHub Wiki

OpenSearch ๊ณต์‹ ๋งํฌ

OpenSearch JAVA USER_GUIDE ๊ณต์‹ ๋งํฌ

OpenSearch Docker Image ๊ณต์‹ ๋งํฌ, OpenSearch Docker Image Version ๋งํฌ

OpenSearch docker-compose ๊ณต์‹ ๋งํฌ

Note

AWS OpenSearch Service๋ฅผ Docker Image๋กœ ํ†ตํ•ด local ํ™˜๊ฒฝ์—์„œ ๊ตฌํ˜„

๋ณด์•ˆ ํ”Œ๋Ÿฌ๊ทธ๊ฐ€ ๋น„ํ™œ์„ฑํ™” ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. Product ํ™˜๊ฒฝ์— ์ ์šฉ x

OpenSearch 2.15 ์ด๋ฏธ์ง€๋ฅผ ๊ธฐ๋ณธ์œผ๋กœ ์‚ฌ์šฉํ•˜๋ฉฐ, Nori ํ•œ๊ตญ์–ด ํ˜•ํƒœ์†Œ ๋ถ„์„๊ธฐ ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์ž๋™์œผ๋กœ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

๊ฐœ์š”

์ด ๊ฐ€์ด๋“œ๋Š” Docker์™€ Docker Compose๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ OpenSearch ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์„ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค. ์ด ์„ค์ •์€ OpenSearch์™€ OpenSearch Dashboards๋ฅผ ํฌํ•จํ•˜๋ฉฐ, ๋‹ค์–‘ํ•œ ํ™˜๊ฒฝ ๋ณ€์ˆ˜์™€ ํ”Œ๋Ÿฌ๊ทธ์ธ ์„ค์ •์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ ์ดˆ๊ธฐํ™” ์Šคํฌ๋ฆฝํŠธ๋ฅผ ํ†ตํ•ด ๋ฐ์ดํ„ฐ ์ธ๋ฑ์‹ฑ์„ ์ž๋™ํ™”ํ•ฉ๋‹ˆ๋‹ค.

Local ๊ตฌํ˜„?

  • ๋น„์šฉ ์ ˆ๊ฐ: ์‹ค์ œ OpenSearch ํด๋ผ์šฐ๋“œ ์„œ๋น„์Šค๋Š” ๋†’์€ ๋น„์šฉ์ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ํ…Œ์ŠคํŠธ ๋ฐ ๊ฐœ๋ฐœ ๊ณผ์ •์—์„œ๋Š” ๋กœ์ปฌ์—์„œ ๊ตฌํ˜„ํ•˜๋ฉด ๋น„์šฉ์„ ์ ˆ๊ฐํ• ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ํ™˜๊ฒฝ ์ผ๊ด€์„ฑ: OpenSearch image๋ฅผ ํ™œ์šฉํ•˜๋ฉด ๋‹ค๋ฅธ ๊ฐœ๋ฐœ์ž์™€ ๋™์ผํ•œ ํ™˜๊ฒฝ์„ ๊ณต์œ ํ•˜๊ธฐ ์ข‹์Šต๋‹ˆ๋‹ค.
  • ๋‹จ์ผ ๋…ธ๋“œ ํด๋Ÿฌ์ŠคํŠธ ํ™œ์šฉ: ๊ฐ„ํŽธํ•˜๊ฒŒ ํ…Œ์ŠคํŠธ ํ™˜๊ฒฝ์„ ๊ตฌ์ถ•ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ๋น ๋ฅธ ํ”ผ๋“œ๋ฐฑ, ๋„คํŠธ์›Œํฌ ์ง€์—ฐ x: ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ์ฆ‰์‹œ ํ™•์ธํ•  ์ˆ˜ ์žˆ๊ณ , ๋„คํŠธ์›Œํฌ ์ง€์—ฐ ์—†์ด ๋น ๋ฅด๊ฒŒ ์ž‘์—…์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

๋””๋ ‰ํ† ๋ฆฌ ๊ตฌ์กฐ

ํ˜„์žฌ ํ”„๋กœ์ ํŠธ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ตฌ์กฐ๋กœ ์„ค๊ณ„๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

project-root/
โ”œโ”€โ”€ docker-compose.dev.yml
โ”œโ”€โ”€ docker/
โ”‚   โ””โ”€โ”€ Dockerfile-opensearch
โ””โ”€โ”€ opensearch-init/
    โ”œโ”€โ”€ init-opensearch.sh
    โ”œโ”€โ”€ setup-opensearch.sh
    โ””โ”€โ”€ webtoon-mapping.json

์ฃผ์š” ์„ค์ • ์„ค๋ช…

%%{init: {'theme': 'base', 'themeVariables': { 'fontSize': '30px', 'fontFamily': 'Arial' }}}%%
flowchart LR
    A("fa:fa-play ์‹œ์ž‘")
    B("fab:fa-docker Docker<br>Compose")
    C("fa:fa-database<br>OpenSearch DB")
    D("fa:fa-chart-line<br>OpenSearch<br>Dashboards")
    E{"fa:fa-question<br>์ธ๋ฑ์Šค<br>์กด์žฌ?"}
    F["fa:fa-plus-square ์ธ๋ฑ์Šค ์ƒ์„ฑ"]
    G["fa:fa-cloud-download-alt ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ"]
    H["fa:fa-file-import ์ธ๋ฑ์‹ฑ"]
    I["fa:fa-fast-forward ์ดˆ๊ธฐํ™” ๊ฑด๋„ˆ๋›ฐ๊ธฐ"]
    K("fa:fa-flag-checkered ์™„๋ฃŒ")

    A --> B
    B --> C & D
    C --> E
    E -->|No| F
    F --> G
    G --> H
    E -->|Yes| I
    H & I --> K

    subgraph ๋ฐ์ดํ„ฐ์ฒ˜๋ฆฌ [" "]
    F
    G
    H
    end

    %% ๋…ธ๋“œ ์Šคํƒ€์ผ๋ง
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef highlight fill:#e1f5fe,stroke:#0288d1,stroke-width:3px
    classDef process fill:#e8f5e9,stroke:#4caf50,stroke-width:2px
    classDef decision fill:#fff3e0,stroke:#ff9800,stroke-width:2px

    class A,K highlight
    class B,C,D process
    class E decision
    class F,G,H,I process

    %% ๋…ธ๋“œ๋ณ„ ์Šคํƒ€์ผ
    style A font-weight:bold
    style B font-weight:bold,fill:#dce9f1
    style C font-weight:bold,fill:#fff0f5
    style D font-weight:bold,fill:#f0f8ff
    style E font-weight:bold
    style F fill:#e6fffa
    style G fill:#e6f3ff
    style H fill:#fff5e6
    style I fill:#f5e6ff
    style K font-weight:bold
    style ๋ฐ์ดํ„ฐ์ฒ˜๋ฆฌ fill:none,stroke:none

    %% ๋งํฌ ์Šคํƒ€์ผ
    linkStyle default stroke:#666,stroke-width:2px,fill:none

    %% ๋…ธ๋“œ์— ๋งํฌ ์ถ”๊ฐ€ (์˜ˆ์‹œ์šฉ ๊ฐ€์ƒ ๋งํฌ)
    click B "<a target='_blank' href='https://docs.docker.com/compose/'>Docker Compose Docs</a>"
    click C "<a target='_blank' href='https://opensearch.org/docs/latest/'>OpenSearch Docs</a>"
    click D "<a target='_blank' href='https://opensearch.org/docs/latest/dashboards/index/'>OpenSearch Dashboards Docs</a>"
Loading
  • docker-compose.dev.yml: - opensearch-node1 ์„œ๋น„์Šค๋Š” OpenSearch ์ธ์Šคํ„ด์Šค๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์–‘ํ•œ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ํ†ตํ•ด ๋ฉ”๋ชจ๋ฆฌ ์„ค์ •, ๋…ธ๋“œ ์ด๋ฆ„, ํด๋Ÿฌ์Šคํ„ฐ ์ด๋ฆ„ ๋“ฑ์„ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    • opensearch-dashboards ์„œ๋น„์Šค๋Š” OpenSearch Dashboards๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” OpenSearch ๋ฐ์ดํ„ฐ๋ฅผ ์‹œ๊ฐํ™”ํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
    • volumes์™€ networks๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ์ดํ„ฐ ์ง€์†์„ฑ๊ณผ ๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ์„ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

  • Dockerfile-opensearch:
    • OpenSearch 2.15.0 ์ด๋ฏธ์ง€๋ฅผ ๊ธฐ๋ณธ์œผ๋กœ ์‚ฌ์šฉํ•˜๋ฉฐ, Nori ํ•œ๊ตญ์–ด ํ˜•ํƒœ์†Œ ๋ถ„์„๊ธฐ ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.
    • ์ดˆ๊ธฐํ™” ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ปจํ…Œ์ด๋„ˆ์— ๋ณต์‚ฌํ•˜๊ณ  ์‹คํ–‰ ๊ถŒํ•œ์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

  • init-opensearch.sh:
    • OpenSearch๊ฐ€ ์ค€๋น„๋  ๋•Œ๊นŒ์ง€ ๋Œ€๊ธฐํ•œ ํ›„, ์ธ๋ฑ์Šค๊ฐ€ ์—†์œผ๋ฉด ์ƒˆ๋กœ์šด ์ธ๋ฑ์Šค๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ๋งคํ•‘ ์„ค์ •์„ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.
    • setup-opensearch.sh ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ์ธ๋ฑ์‹ฑํ•ฉ๋‹ˆ๋‹ค.

  • setup-opensearch.sh:
    • ์™ธ๋ถ€ API์—์„œ ์›นํˆฐ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์™€ OpenSearch์— ์ธ๋ฑ์‹ฑํ•ฉ๋‹ˆ๋‹ค.

  • webtoon-mapping.json:
    • ์ธ๋ฑ์Šค ์„ค์ • ๋ฐ ๋งคํ•‘์„ ์ •์˜ํ•˜์—ฌ OpenSearch๊ฐ€ ๋ฐ์ดํ„ฐ๋ฅผ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๋ถ„์„ํ•˜๊ณ  ์ €์žฅํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

์ ์šฉ ๋ฐฉ๋ฒ•

docker-compose -f docker-compose.dev.yml up --build 

(or)

docker-compose -f docker-compose.dev.yml up -d

  • bash ์Šคํฌ๋ฆฝํŠธ ์‹คํ–‰์ด ์‹œ์ž‘๋˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋กœ๊ทธ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. image

๋ฉ”๋ชจ๋ฆฌ ์ตœ์ ํ™”

  • ์ ์ ˆํ•œ JVM ํž™ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์กฐ์ •ํ•˜์—ฌ ์ตœ์ ํ™”ํ•ฉ๋‹ˆ๋‹ค.
  • OPENSEARCH_JAVA_OPTS=-Xms4g -Xmx4g # JVM ํž™ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์ตœ๋Œ€ 4GB๋กœ ์„ค์ •

๊ธฐ์กด 8GB ์„ค์ • ์‹œ image

4GB ์„ค์ • ์‹œ image

ํ”„๋กœ์ ํŠธ ๋””๋ ‰ํ† ๋ฆฌ ๊ตฌ์กฐ ๋ฐ ํŒŒ์ผ ๋งํฌ

ํ”„๋กœ์ ํŠธ์˜ ์ „์ฒด ๋””๋ ‰ํ† ๋ฆฌ ๊ตฌ์กฐ๋Š” ๋‹ค์Œ ๋งํฌ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: ํ”„๋กœ์ ํŠธ ๋””๋ ‰ํ† ๋ฆฌ ๊ตฌ์กฐ

์ฃผ์š” ํŒŒ์ผ ๋งํฌ

โš ๏ธ **GitHub.com Fallback** โš ๏ธ