'분류 전체보기'에 해당되는 글 1583건

  1. 2021.08.04 [Elasticsearch] force merge 에 대한 정리
  2. 2021.08.02 [Log4J2] Executable Jar + Springboot framework 사용 예.
  3. 2021.07.27 [OpenJDK] 다운로드 받아서 설치.
  4. 2021.07.27 [Bash] 문자열 비교 예제
  5. 2021.07.19 [HikariCP] Java 버전 호환
  6. 2021.07.15 [JUnit] intellij 에서 junit 테스트 코드 작성 시 경험 하는 에러.
  7. 2021.07.14 [Docker] 로컬에 MySQL 설치 합니다.
  8. 2021.07.12 [Elasticsearch] Field Name Length Limit.
  9. 2021.07.06 [Elasticsearch] arirang dictionary 에 영어+한글 복합어 분해 추가.
  10. 2021.07.06 [Elasticsearch] bin/start, bin/stop

[Elasticsearch] force merge 에 대한 정리

Elastic/Elasticsearch 2021. 8. 4. 08:12

공식 문서 참고)

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html

 

API)

POST /my-index-000001/_forcemerge

 

force merge 는 너무 많이 생성된 Segments 파일을 병합 하거나 삭제 된 문서를 물리적으로 병합 하면서 제거 하거나 하는 작업을 수행 하게 됩니다.

 

보통은 merge policy 에 의해서 자동으로 수행이 되긴 하지만 간혹 수동으로 실행을 해야 할 때도 발생을 합니다.

그럼 Segments 파일을 어느 정도 수준으로 유지 하는게 좋을까요?

 

그 전에 확인할 사항이 있습니다.

 

1. Segment 파일에 문서 수가 많나요?

2. Segment 파일에 문서의 크기가 큰 것일까요?

 

결국 이 Segments 파일은 IndexWriter 즉, 색인 보다는 검색에 영향을 많이 주는 요소라고 보면 됩니다.

 

짧은 용량의 Segments 파일이 많이 있다고 가정 하면 파일 수 만큼의 IndexeReader 가 준비 되어야 하고 그에 맞는 thread 가 일을 해야 하기 때문에 다소 성능이 떨어 질 수도 있습니다.

반대로, 용량이 큰 Segments 파일이 있다고 하면 Single thread 로 동작 하기 때문에 역시 성능이 떨어 질 수 있기도 합니다.

 

그래서 가장 최적의 Segment file 의 크기와 수를 구해야 검색 성능을 확보 할 수 있습니다.

보통은 Primary shard 와 Replica shard 를 가지고 접근을 하게 됩니다. 그러다 Node 수준까지 접근 하게 되고 더 나아가 Application 수준까지 ...

 

Segment 파일이 가질 수 있는

- 최대 문서의 수는 Integer.MAX_VALUE (2,147,483,519) 만큼 가질 수 있습니다.

- 문서 하나의 최대 크기는 2GB 입니다.

 

제가 제안 하는 범용적인 Segment 파일은

- 최대 문서 수는 1천만 ~ 5천만

- Segment file 크기는 2GB ~ 5GB

- Segment file 수는 Core 크기와 같거나 1/2 만큼

정도 인것 같습니다.

 

Segment 는 Lucene 기준으로 검토를 하셔야 하고 Elasticsearch 기준으로 확장 한다고 하면 Shard 까지 검토를 하셔야 합니다.

 

제가 제안한 정보를 기준으로 단순 예를 들어 보면)

- 코어가 10개 라고 하고

- 1/2 만큼의 Segments file : 5개

- Shard 1개의 크기는 5 개 Segments file x 2GB : 10GB

 

대략 Node와 Shard size estimation 하는 방법에서 제시 한 것과 어느 정도 부합 한다는 것을 볼 수 있습니다.

 

:

[Log4J2] Executable Jar + Springboot framework 사용 예.

ITWeb/개발일반 2021. 8. 2. 20:45

 

springboot framework 을 이용해서 executable jar 구현 시 log4j2 사용 예)
- @Slf4j 사용
- logback.xml 사용
- -Dlogback.configurationFile=$DIR_HOME/logback.xml

로그가 중복으로 남을 경우)
https://logging.apache.org/log4j/2.x/manual/configuration.html#Additivity
- <logger name="..." ... additivity="false" />
- 단순하게 보면, Logger 에 선언 된 appender 로 한번 기록하고 root logger 에 의해서 한번 기록 하게 되는 구조 입니다.

build.gradle 예)
configurations.all {
  exclude module: 'spring-boot-starter-logging'
}
...중략...
dependencies {
...중략...
  compile group: 'org.slf4j', name: 'slf4j-api', version: "${props.getProperty('slf4j')}"
  compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: "${props.getProperty('log4j')}"
  compile group: 'ch.qos.logback', name: 'logback-classic', version: "${props.getProperty('logback')}"
  compile group: 'ch.qos.logback', name: 'logback-core', version: "${props.getProperty('logback')}"
...중략...
}

 

:

[OpenJDK] 다운로드 받아서 설치.

ITWeb/개발일반 2021. 7. 27. 09:46

아래 주소에서 설치할 버전 선택 후 다운로드 받아서 설치 하셔도 됩니다.

 

Early Access

https://download.java.net/java/early_access/jdk18/7/GPL/openjdk-18-ea+7_linux-x64_bin.tar.gz

 

GA

https://jdk.java.net/archive/

 

AdoptOpenJDK

https://adoptopenjdk.net/release_notes.html

https://adoptopenjdk.net/archive.html?variant=openjdk8&jvmVariant=hotspot 

 


                  

:

[Bash] 문자열 비교 예제

ITWeb/개발일반 2021. 7. 27. 08:11
#!/bin/bash

retry='retry'

if [ $retry = "retry" ]; then
  echo 'true - 1'
fi

if [[ $retry = "retry" ]]; then
  echo 'true - 2'
fi

if [[ "$retry" = "retry" ]]; then
  echo 'true - 3'
fi

세 예제 다 true 리턴 합니다.

:

[HikariCP] Java 버전 호환

ITWeb/개발일반 2021. 7. 19. 11:46

빌드 환경과 맞춰서 사용 하셔야 합니다.

안그러면 아래와 같은 에러를 경험 할 수 있습니다.

 

Exception in thread "main" java.lang.UnsupportedClassVersionError: com/zaxxer/hikari/HikariConfig has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

 

Artifacts
Java 11+ maven artifact:

<dependency>
   <groupId>com.zaxxer</groupId>
   <artifactId>HikariCP</artifactId>
   <version>5.0.0</version>
</dependency>
Java 8 maven artifact (maintenance mode):

<dependency>
   <groupId>com.zaxxer</groupId>
   <artifactId>HikariCP</artifactId>
   <version>4.0.3</version>
</dependency>
Java 7 maven artifact (maintenance mode):

<dependency>
   <groupId>com.zaxxer</groupId>
   <artifactId>HikariCP-java7</artifactId>
   <version>2.4.13</version>
</dependency>
Java 6 maven artifact (maintenance mode):

<dependency>
   <groupId>com.zaxxer</groupId>
   <artifactId>HikariCP-java6</artifactId>
   <version>2.3.13</version>
</dependency>

 

:

[JUnit] intellij 에서 junit 테스트 코드 작성 시 경험 하는 에러.

ITWeb/개발일반 2021. 7. 15. 09:42

아래와 같은 에러를 경험 하셨다면 intellij 에서의 설정을 변경해 주시면 됩니다.

 

Execution failed for task ':test'.
> No tests found for given includes: [com.kakaopay.stark.pipeline.indexer.PropertiesTest.testMultilineProperty](filter.includeTestsMatching)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

 

IntelliJ -> Preferences -> Build,Execution,Deployment -> Build Tools -> Gradle

Gradle projects -> Run tests using -> Gradle (Default) 를 Intellij IDEA 로 바꾸시면 됩니다.

:

[Docker] 로컬에 MySQL 설치 합니다.

Cloud&Container/IaC 2021. 7. 14. 19:39

요즘 잘 되어 있는 container 기반으로 구성 하면 되지 않겠습니까?

 

version: '3.7'

services:
  db:
    image: mysql
    container_name: local-mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: local
      MYSQL_USER: henry
      MYSQL_PASSWORD: henry
      MYSQL_DATABASE: henry
    volumes:
      - ./data:/var/lib/mysql
    ports:
      - 3306:3306

  adminer:
    image: adminer
    restart: always
    ports:
      - 8888:8888

$ docker-compose up -d

이제 client tool 을 이용해서 접속해 보시면 됩니다. :)

:

[Elasticsearch] Field Name Length Limit.

Elastic/Elasticsearch 2021. 7. 12. 19:23

기억력을 돕기 위해서 기록 합니다.

 

참고 문서)

https://www.elastic.co/guide/en/elasticsearch/reference/master/mapping-settings-limit.html

 

index.mapping.field_name_length.limit)

Setting for the maximum length of a field name. 
This setting isn’t really something that addresses mappings explosion 
but might still be useful if you want to limit the field length. 
It usually shouldn’t be necessary to set this setting. 
The default is okay unless a user starts to add a huge number of fields with really long names.

Default is Long.MAX_VALUE (no limit).

mapping explosion 과 같은 경우에 유용 할 수 있다는 이야기 입니다.

기본은 노 제한!!

 

보너스로 그럼 Index 명은 얼마인가요?

- 255 bytes 입니다. (실제 멀티바이트 문자 이기 때문에 더 짧습니다.)

- https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#indices-create-api-path-params

 

그냥 궁금해서 추가적으로 cluster.name 과 node.name 의 max length 는 어떻게 될까 찾아 봤는데요.

Java 의 Sting 클래스의 max length 라고 보시면 됩니다.

그러나 cluster.name 과 node.name 은 가독성이 중요 하기 때문에 저렇게 길게 작명 하는 나쁜 부모는 되지 말아야 겠죠.

:

[Elasticsearch] arirang dictionary 에 영어+한글 복합어 분해 추가.

Elastic/Elasticsearch 2021. 7. 6. 14:59

그냥 작은 운영 팁 정도 입니다.

 

영어+한글로 작성된 경우 둘 다 사전에 등록 되어 있지 않다고 하면 아래와 같이 등록을 하면 됩니다.

 

예) kr모터스

extension.dic 에 한글 "모터스" 만 등록 합니다.

모터스,100000000X

 

POST http://localhost:10800/_analyze

Request)

{

"tokenizer": "arirang_tokenizer",

"filter": [

"arirang_filter"

],

"text": "kr모터스"

}

 

Response)

{

"tokens": [

{

"token": "kr모터스",

"start_offset": 0,

"end_offset": 5,

"type": "korean",

"position": 0

},

{

"token": "kr",

"start_offset": 0,

"end_offset": 2,

"type": "word",

"position": 0

},

{

"token": "모터스",

"start_offset": 2,

"end_offset": 5,

"type": "korean",

"position": 1

}

]

}

:

[Elasticsearch] bin/start, bin/stop

Elastic/Elasticsearch 2021. 7. 6. 13:16

분명 어딘가에 기록해 두었던 것 같은데 또 못찾고 있다.

그래서 손꾸락이 기억 하라고 작성해 봅니다.

 

- Elasticsearch start
#!/bin/bash

DIR_NAME=`dirname "$0"`
DIR_HOME=`cd $DIR_NAME; cd ..; pwd`

ES_JAVA_OPTS="-Xms512m -Xmx512m" $DIR_HOME/bin/elasticsearch -d -p $DIR_HOME/PID

- Elasticsearch stop
#!/bin/bash

DIR_NAME=`dirname "$0"`
DIR_HOME=`cd $DIR_NAME; cd ..; pwd`

pkill -F  $DIR_HOME/PID

 

: