์ง๋ ์๊ฐ elasticsearch ๊ฒฐ๊ณผ๊ฐ Spring์์ ์ ๋์ค์ง ์์ ๊ฒฝ์ฐ๊ฐ ์์๋ค. ์ด๋ฅผ ํด๊ฒฐํ๊ธฐ์ํด ์๋ ์์ ์ ์งํํ๋ค.
-> ์ปดํจํฐ ์ฌ๋ถํ
ubuntu ์ด๊ณ
$ wsl -l -v
$ wsl --unregister Ubuntu-22.04
๋ค์ ์ฐ๋ถํฌ ์คํ
username: ubuntu
pw: java1234
ํจํค์ง ์
๋ฐ์ดํธ
$ sudo apt-get update
์๋ฐ(JRE, JDK์ค์น)
$ sudo apt-get install default-jre
$ sudo apt-get install default-jdk
Elasticsearch ์ค์น
$ echo "deb [signed-by=/usr/share/keyrings/elastic.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
$ sudo apt-get update
$ sudo apt-get install elasticsearch
Kibana ์ค์นํ๊ธฐ
$ sudo apt-get install kibana
Logstash ์ค์นํ๊ธฐ
$ sudo apt-get install logstash
์๋์์
$ sudo systemctl enable elasticsearch
$ sudo systemctl enable kibana
์ธ๋ถ ์ ์ ํ์ฉ
$ sudo vi /etc/elasticsearch/elasticsearch.yml
network.host: 0.0.0.0
cluster.initial_master_nodes: ["node-1"]
$ sudo systemctl restart elasticsearch
$ sudo systemctl start kibana
์ฌ์ดํธ ๋ค์ด๊ฐ์ ํ์ธ
http://localhost:9200/
http://localhost:5601/
wsl ์ ์ง
๋ช
๋ น ํ๋กฌํํธ์์
> wsl --shutdown
$ sudo systemctl stop elasticsearch
$ sudo systemctl stop kibana
$ sudo vi /etc/elasticsearch/elasticsearch.yml
์ฃผ์์ฒ๋ฆฌ
#network.host: 0.0.0.0
#cluster.initial_master_nodes: ["node-1"]
:wq
$ sudo systemctl start elasticsearch
$ sudo systemctl start kibana
์ฌ์ดํธ ๋ค์ด๊ฐ์ ํ์ธ
http://localhost:9200/
http://localhost:5601/
$ sudo systemctl stop elasticsearch
$ sudo systemctl stop kibana
$ sudo vi /etc/elasticsearch/elasticsearch.yml
์ฃผ์ ํ๊ธฐ
network.host: 0.0.0.0
cluster.initial_master_nodes: ["node-1"]
:wq
$ sudo systemctl daemon-reload
$ sudo systemctl start elasticsearch
$ sudo systemctl start kibana
์คํ๋ง ์คํ
์๋ ์ฝ๋ ๋ฃ๊ธฐ
PUT spring
{
"mappings": {
"properties": {
"message": {
"type": "text"
}
}
}
}
POST _bulk
{ "index" : { "_index" : "spring", "_id" : "1" } }
{"message":"The quick brown fox"}
{ "index" : { "_index" : "spring", "_id" : "2" } }
{"message":"The quick brown fox jumps over the lazy dog"}
{ "index" : { "_index" : "spring", "_id" : "3" } }
{"message":"The quick brown fox jumps over the quick dog"}
{ "index" : { "_index" : "spring", "_id" : "4" } }
{"message":"Brown fox brown dog"}
{ "index" : { "_index" : "spring", "_id" : "5" } }
{"message":"Lazy jumping dog"}
{ "index" : { "_index" : "spring", "_id" : "6" } }
{"message":"์ง๋ถ ์์ ๊ฐ์ ๋ญ"}
{ "index" : { "_index" : "spring", "_id" : "7" } }
{"message":"์ง๋ถ ์์ ๊ฐ์ ๋ญ ๊ทธ๋ฆฌ๊ณ ๋ฐ์ ๊ฒ์์ ๊ฐ์์ง"}
{ "index" : { "_index" : "spring", "_id" : "8" } }
{"message":"์ง๋ถ ์์ ๊ฐ์ ์ฐ๋ ๋ญ ๊ทธ๋ฆฌ๊ณ ๋ฐ์ ๊ฐ์ ๊ฒ์ผ๋ฅธ ๊ฐ์์ง"}
{ "index" : { "_index" : "spring", "_id" : "9" } }
{"message":"๊ฐ์ ๊ฒ์ผ๋ฅธ ๋ฐ๋ณด ๊ฐ์์ง ์์ ๋นจ๊ฐ์ ๋ญ"}
{ "index" : { "_index" : "spring", "_id" : "10" } }
{"message":"์กธ๊ณ ์๋ ๊ฐ์ ๊ฐ์์ง"}
New > Spring Legacy Project > Spring MVC Project > "ElasticsearchProject" > "com.text.project" > Finish
์ผ๊ด์ค์ ๊ฐ์ ธ์์ ๋ณต๋ถ
com.test.controller
- "BookController.java"
com.test.persistence
- "BookDAO.java"(I) > ์ค๋ผํด ๋ฐ์ดํฐ ์ฒ๋ฆฌ
- "BookDAOImpl.java"(C)
com.test.domain
- "BookDTO.java"
com.test.mapper
- "ProjectMapper.java"(I)
views
- "list.jsp"
ElasticsearchProject > "script.sql"