1. ๊ฐœ๋…

๐Ÿ’ก
Elasticsearch๋ž€? ์™„์ „๊ด€๋ฆฌํ˜• ์„œ๋น„์Šค์ธ Amazon Elasticsearch Service๋Š” Elasticsearch ํด๋Ÿฌ์Šคํ„ฐ ์„ค์ •, ๋ฐฐํฌ, ๊ตฌ์„ฑ, ํŒจ์น˜ ๋ฐ ๋ชจ๋‹ˆํ„ฐ๋ง์„ ๊ด€๋ฆฌํ•˜๋ฏ€๋กœ ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ์‹œ๊ฐ„์„ ์ค„์—ฌ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ตฌ์ถ•์— ๋” ๋งŽ์€ ์‹œ๊ฐ„์„ ํ• ์• ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Amazon Elasticsearch Service๋Š” ์˜คํ”ˆ ์†Œ์Šค Elasticsearch API, ๊ด€๋ฆฌํ˜• Kibana, Logstash์™€์˜ ํ†ตํ•ฉ, ๊ธฐํƒ€ AWS ์„œ๋น„์Šค ๋ฐ SQL ์ฟผ๋ฆฌ๋ฅผ ์ œ๊ณตํ•˜๋ฏ€๋กœ ๊ธฐ์กด ๋„๊ตฌ ๋ฐ ์ฝ”๋“œ๋ฅผ ๊ณ„์† ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์ •๋ฆฌ
    • Elasticsearch๋Š” ๊ฒ€์ƒ‰์„ ์œ„ํ•ด ๋‹จ๋…์œผ๋กœ ์‚ฌ์šฉ๋˜๊ธฐ๋„ ํ•˜๋ฉฐ, ELK(Elasticsearch / Logstatsh / Kibana) ์Šคํƒ์œผ๋กœ๋„์‚ฌ์šฉ๋œ๋‹ค.
    • Logstash

      ๋‹ค์–‘ํ•œ ์†Œ์Šค(DB, csvํŒŒ์ผ) ์˜ ๋กœ๊ทธ ๋˜๋Š” ํŠธ๋žœ์žญ์…˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ˆ˜์ง‘, ์ง‘๊ณ„, ํŒŒ์‹ฑํ•˜์—ฌ Elasticsearch๋กœ ์ „๋‹ฌ

    • Elasticsearch

      Logstash๋กœ ๋ถ€ํ„ฐ ๋ฐ›์€ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฒ€์ƒ‰ ๋ฐ ์ง‘๊ณ„๋ฅผ ํ•˜์—ฌ ํ•„์š”ํ•œ ๊ด€์‹ฌ ์ •๋ณด ํš๋“

    • Kibana

      Elasicsearch์˜ ๋น ๋ฅธ ๊ฒ€์ƒ‰์„ ํ†ตํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ์‹œ๊ฐํ™” ๋ฐ ๋ชจ๋‹ˆํ„ฐ๋ง

    • ์šฉ์–ด
      1. cluster
        • Elastisearch ์—์„œ ๊ฐ€์žฅ ํฐ ์‹œ์Šคํ…œ ๋‹จ์œ„๋ฅผ ์˜๋ฏธ
        • ์ตœ์†Œ ํ•˜๋‚˜ ์ด์ƒ์˜ ๋…ธ๋“œ์˜ ์ง‘ํ•ฉ
        • ์„œ๋กœ ๋‹ค๋ฅธ ํด๋Ÿฌ์Šคํ„ฐ๋Š” ๋ฐ์ดํ„ฐ ์ ‘๊ทผ,๊ตํ™˜์„ ํ• ์ˆ˜์—†๋Š” ๋…๋ฆฝ์  ์‹œ์Šคํ…œ
        • ์—ฌ๋Ÿฌ ๋Œ€์˜ ์„œ๋ฒ„๊ฐ€ ํ•˜๋‚˜์˜ ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ๊ณ , ํ•œ ์„œ๋ฒ„์— ์—ฌ๋Ÿฌ๊ฐœ์˜ ํด๋Ÿฌ์Šคํ„ฐ ์กด์žฌ ๊ฐ€๋Šฅ
      1. ๋…ธ๋“œ
        • Elasticsearch ๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ํ•˜๋‚˜์˜ ๋‹จ์œ„ ํ”„๋กœ์„ธ์Šค๋ฅผ ์˜๋ฏธ
        • ์—ญํ• ์— ๋”ฐ๋ผ Master-eligible,Data,Tribe ๋…ธ๋“œ๋กœ ๊ตฌ๋ถ„
        • node ์ข…๋ฅ˜
          1. master-eligible node ๋งํฌ )

            ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ์ œ์–ดํ•˜๋Š” ๋งˆ์Šคํ„ฐ๋กœ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ๋…ธ๋“œ๋ฅผ ๋งํ•ฉ๋‹ˆ๋‹ค.

            ์—ฌ๊ธฐ์„œ master ๋…ธ๋“œ๊ฐ€ ํ•˜๋Š” ์—ญํ• ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

            • ์ธ๋ฑ์Šค ์ƒ์„ฑ, ์‚ญ์ œ
            • ํด๋Ÿฌ์Šค๋” ๋…ธ๋“œ๋“ค์˜ ์ถ”์ , ๊ด€๋ฆฌ
            • ๋ฐ์ดํ„ฐ ์ž…๋ ฅ ์‹œ ์–ด๋Š ์ƒค๋“œ์— ํ• ๋‹นํ•  ๊ฒƒ์ธ์ง€
          1. Data node ๋งํฌ )

            ๋ฐ์ดํ„ฐ์™€ ๊ด€๋ จ๋œ CRUD ์ž‘์—…๊ณผ ๊ด€๋ จ์žˆ๋Š” ๋…ธ๋“œ์ž…๋‹ˆ๋‹ค.

            ์ด ๋…ธ๋“œ๋Š” CPU, ๋ฉ”๋ชจ๋ฆฌ ๋“ฑ ์ž์›์„ ๋งŽ์ด ์†Œ๋ชจํ•˜๋ฏ€๋กœ ๋ชจ๋‹ˆํ„ฐ๋ง์ด ํ•„์š”ํ•˜๋ฉฐ, master ๋…ธ๋“œ์™€ ๋ถ„๋ฆฌ๋˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

          1. Ingest node ๋งํฌ )

            ๋ฐ์ดํ„ฐ๋ฅผ ๋ณ€ํ™˜ํ•˜๋Š” ๋“ฑ ์‚ฌ์ „ ์ฒ˜๋ฆฌ ํŒŒ์ดํ”„๋ผ์ธ์„ ์‹คํ–‰ํ•˜๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.

          1. Coordination only node ๋งํฌ )

            data node์™€ master-eligible node์˜ ์ผ์„ ๋Œ€์‹ ํ•˜๋Š” ์ด ๋…ธ๋“œ๋Š” ๋Œ€๊ทœ๋ชจ ํด๋Ÿฌ์Šคํ„ฐ์—์„œ ํฐ ์ด์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

            ์ฆ‰ ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ์™€ ๋น„์Šทํ•œ ์—ญํ• ์„ ํ•œ๋‹ค๊ณ  ๋ณด์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

      1. ์ธ๋ฑ์Šค(index) / ์ƒค๋“œ(shard) / ๋ณต์ œ (Replica)
        1. ์ธ๋ฑ์Šค
          • Elasticsearch์—์„œ index๋Š” RDBMS์—์„œ database์™€ ๋Œ€์‘ํ•˜๋Š” ๊ฐœ๋…์ž…๋‹ˆ๋‹ค.
          • ๋˜ํ•œ shard์™€ replica๋Š” Elasticsearch์—๋งŒ ์กด์žฌํ•˜๋Š” ๊ฐœ๋…์ด ์•„๋‹ˆ๋ผ, ๋ถ„์‚ฐ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์‹œ์Šคํ…œ์—๋„ ์กด์žฌํ•˜๋Š” ๊ฐœ๋…์ž…๋‹ˆ๋‹ค.
        1. ์ƒค๋”ฉ( sharding )
          •  ๋ฐ์ดํ„ฐ๋ฅผ ๋ถ„์‚ฐํ•ด์„œ ์ €์žฅํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

            ์ฆ‰, Elasticsearch์—์„œ ์Šค์ผ€์ผ ์•„์›ƒ์„ ์œ„ํ•ด index๋ฅผ ์—ฌ๋Ÿฌ shard๋กœ ์ชผ๊ฐ  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

            ๊ธฐ๋ณธ์ ์œผ๋กœ 1๊ฐœ๊ฐ€ ์กด์žฌํ•˜๋ฉฐ, ๊ฒ€์ƒ‰ ์„ฑ๋Šฅ ํ–ฅ์ƒ์„ ์œ„ํ•ด ํด๋Ÿฌ์Šคํ„ฐ์˜ ์ƒค๋“œ ๊ฐฏ์ˆ˜๋ฅผ ์กฐ์ •ํ•˜๋Š” ํŠœ๋‹์„ ํ•˜๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค.

        1. replica
          • ๋˜ ๋‹ค๋ฅธ ํ˜•ํƒœ์˜ shard๋ผ๊ณ  ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

            ๋…ธ๋“œ๋ฅผ ์†์‹คํ–ˆ์„ ๊ฒฝ์šฐ ๋ฐ์ดํ„ฐ์˜ ์‹ ๋ขฐ์„ฑ์„ ์œ„ํ•ด ์ƒค๋“œ๋“ค์„ ๋ณต์ œํ•˜๋Š” ๊ฒƒ์ด์ฃ .

          ๋”ฐ๋ผ์„œ replica๋Š” ์„œ๋กœ ๋‹ค๋ฅธ ๋…ธ๋“œ์— ์กด์žฌํ•  ๊ฒƒ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.

      1. ํŠน์ง•
        1. Scale-oute
          • ์ƒค๋“œ๋ฅผ ํ†ตํ•ด ๊ทœ๋ชจ๊ฐ€ ์ˆ˜ํ‰์  ํ™•์žฅ
        1. ๊ณ ๊ฐ€์šฉ์„ฑ
          • Replica๋ฅผ ํ†ตํ•ด ๋ฐ์ดํ„ฐ์˜ ์•ˆ์ •์„ฑ ๋ณด์žฅ
        1. Schema Free
          • json ๋ฌธ์„œ๋ฅผ ํ†ตํ•ด ๋ฐ์ดํ„ฐ ๊ฒ€์ƒ‰์„ ์ˆ˜ํ–‰ํ•˜๋ฏ€๋กœ ์Šคํ‚ค๋งˆ ๊ฐœ๋… x
        1. Restful
          • ๋ฐ์ดํ„ฐ CURD ์ž‘์—…์€ HTTP Restful API๋ฅผ ํ†ตํ•ด ์ˆ˜์ •ํ•˜๋ฉฐ, ๊ฐ๊ธฐ ๋‹ค์Œ๊ณผ๊ฐ™๋‹ค

            Restful

            Data CRUDElasticsearch Restful
            SELECTGET
            INSERTPUT
            UPDATEPOST
            DELETEDELETE

2. ์‹ค์Šต

  • ์•„ํ‚คํ…์ฒ˜

  • ์‹ค์Šต
    • vpc flow
      1. vpc flow log ์ƒ์„ฏ
      1. cloudwatch

    • ElasticSearch
      1. ์‚ฌ์šฉ์ž ์ง€์ • ์ƒ์„ฑ

        โ†’ ํ…Œ์ŠคํŠธ ๋ชฉ์ 

    • flowlog ๋‚จ๋„๋ก ec2 ์ ‘์†
      • ๋กœ๊ทธ ํ™•์ธ

    • cloudwatch โ†’ ES ๊ตฌ๋…
      1. ESํ•„ํ„ฐ์ƒ์„ฑ
      1. ์‚ฌ์šฉํ•  ES ๋ฐ lambda role ์„ค์ •
      1. ํ•ด๋‹น role ์„ค์ •
        {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents"
              ],
              "Resource": [
                "arn:aws:logs:*:*:*"
              ]
            },
            {
              "Effect": "Allow",
              "Action": "es:ESHttpPost",
              "Resource": "arn:aws:es:*:*:*"
            }
          ]
        }
      1. ์ƒ์„ฑ

        โ†’ ์ž๋™ ์ƒ์„ฑ ํ™•์ธ

        • ์ด๋ฅผ ํ†ตํ•ด์„œ ES cluster๋กœ ์ „์†ก๋œ๋‹ค.

    • kibana ์ ‘์†

      ์ฐธ์กฐ : cognito ๊ด€๋ จ https://cherrypick.co.kr/using-the-aws-elasticsearch-service-kibana-with-aws-cognito/

      1. ์ ‘์† ํ™”๋ฉด
      1. cognito์—์„œ ์ƒ์„ฑ๋œ ID ๋ฐ ์ž„์‹œ๋น„๋ฒˆ ์ž…๋ ฅ

        โ†’ ์ดํ›„ ๋ณ€๊ฒฝ ์•”ํ˜ธ ์„ค์ •

      1. ์—๋Ÿฌ ํŽ˜์ด์ง€ ํ™•์ธ
        • cognito ์ธ์ฆ ๊ณผ์ •์—์„œ์˜ ์—๋Ÿฌ ๋ฐœ์ƒ์ด๋ฏ€๋กœ ES์—์„œ ์•ก์„ธ์Šค ์ •์ฑ…์„ ์ˆ˜์ •ํ•œ๋‹ค.
      1. ์ฐธ์กฐ ๋ธ”๋กœ๊ทธ๋ฅผ ํ†ตํ•ด์„œ cognito ์ž๊ฒฉ์ฆ๋ช… ํ’€์ƒ์„ฑ์‹œ iam์ •์ฑ…์— ์ƒ์„ฑ๋œ๋‹ค.

        โ†’ ์ด๋ ‡๊ฒŒ ์ƒ์„ฑ๋œ role์„ ์ด์šฉํ•ด์„œ ์•ก์„ธ์Šค ์ •์ฑ…์„ ์ˆ˜์ •ํ•ด์•ผํ•œ๋‹ค.

        {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Principal": {
                "AWS": "arn:aws:iam::186086016278:role/<cognito ์ž๊ฒฉ์ฆ๋ช…ํ’€role>"
              },
              "Action": "es:ESHttp*",
              "Resource": "arn:aws:es:ap-northeast-2:186086016278:domain/sssdf/*"
            }
          ]
        }
      1. ES ํ™œ์„ฑํ™”ํ›„ โ†’ kibana ์ ‘์†
      1. ์ธ๋ฑ์Šค ํŒจํ„ด ๋ฐ ๋‚˜ํƒ€๋‚ผ ํ•ญ๋ชฉ๋“ค ํ™•์ธ
      1. ํ™•์ธ

'aws' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

s3 - presigned url  (0) 2021.03.29
RDS โ†’ s3 ๋ฐฑ์—…  (0) 2021.03.29
CloudWatch / SSM Agent  (0) 2021.03.29
lb -acm ์ธ์ฆ์„œ๋ฅผ ์ด์šฉํ•œ ์ ‘์†  (0) 2021.02.09
route 53 ๋„๋ฉ”์ธ ์—ฐ๊ฒฐ  (0) 2021.02.09

+ Recent posts