※ 버전: 7.17.0
※ 참고: https://narup.tistory.com/251
config/pipelines.yml
# Example of two pipelines:
#
- pipeline.id: "test"
pipeline.workers: 1
pipeline.batch.size: 1
path.config: "C:/Users/USER/logstash-7.17.0/config/*.config"
# config.string: "input { generator {} } filter { sleep { time => 1 } } output { stdout { codec => dots } }"
# - pipeline.id: another_test
# queue.type: persisted
config/logstash.conf
# Sample Logstash configuration for creating a simple
# Beats -> Logstash -> Elasticsearch pipeline.
input {
jdbc {
jdbc_driver_library => "C:/Users/USER/logstash-7.17.0/lib/mysql-connector-java-8.0.18.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/<DB이름>?useUnicode=true&serverTimezone=Asia/Seoul"
jdbc_user => "root" (MySql Username)
jdbc_password => "<Mysql 접속 비밀번호>"
statement => "SELECT * FROM 테이블명"
}
}
output{
stdout{}
elasticsearch{
hosts => ["http://localhost:9200"]
index => "temp"
document_id => "%{id}"
}
}
※ JDBC 드라이버 : mysql-connector-java-8.0.18.jar
$ .\logstash.bat -f config/logstash.conf
(f 인자로 "config/logstash.conf", logstash의 설정 파일 인자를 넘겨주는 작업)
※ No config path ~~ bin/config/logstash.conf ~~ 에러 뜰 경우,
C:\Users\USER\logstash-7.17.0 위치에서 $ .\bin\logstash.bat -f config/logstash.conf
postman으로 확인
temp 라는 인덱스에 잘 적재되었다.