기본이 되는 ES 부터 Docker 설치한 후...
ES Docker / docker-compose up -d
https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
docker-compose.yml:
version: '2.2'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.1.0
container_name: es01
environment:
- node.name=es01
- discovery.seed_hosts=es02
- cluster.initial_master_nodes=es01,es02
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata01:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- esnet
es02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.1.0
container_name: es02
environment:
- node.name=es02
- discovery.seed_hosts=es01
- cluster.initial_master_nodes=es01,es02
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata02:/usr/share/elasticsearch/data
networks:
- esnet
volumes:
esdata01:
driver: local
esdata02:
driver: local
networks:
esnet:
어짜피 테스트 환경이니까 커스트마이즈는 할 필요 없이 바로 Application 구성으로 넘어간다.
프로젝트 구성은 Spring-Boot 2 멀티 모듈 형태로 진행할까 했지만 이건 이거대로 지겨움이 있어서 단일 프로젝트로 진행.
프로젝트 구성은 IntelliJ의 생성을 그대로 유지한다.(참고로 JDK 11 을 사용해서 진행해 보기로 함.)
plugins {
id 'org.springframework.boot' version '2.1.5.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
group = 'com.tistory.eclipse4j.flux'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
springBoot {
mainClassName = 'com.tistory.eclipse4j.flux.FluxApplication'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-cache'
implementation 'org.springframework.boot:spring-boot-starter-data-elasticsearch'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
}
spring-data-elasticsearch 를 사용하려 했으나 버전의 충돌문제( es 7.1 )로 인해 그냥 늘 쓰던 high level client로 사용하기로 변경함.
data-elasticsearch 는 삭제한다.
compile group: 'org.elasticsearch', name: 'elasticsearch', version: '7.1.0'
compile group: 'org.elasticsearch.client', name: 'elasticsearch-rest-high-level-client', version: '7.1.0'