[Recommended reading] How long can microservices last? >>>
logstash installation
Visit https://www.elastic.co/cn/downloads/logstash to download the zip package corresponding to the es version,
Unzip the zip, enter the logstash directory, and open the cmd window in this directory.
Enter the following command in the command window:
logstash-e'input{stdin{}}output{stdout{}}'
Then enter "hello", if the result is also "hello" that the installation was successful.
Synchronize data to es
Create a new jdbc.conf file in the bin directory of logstash and enter the following:
input{
stdin{
}
jdbc{
#Database address port database name
jdbc_connection_string=>"jdbc:mysql://IP:3306/dbname"
#database username
jdbc_user=>"user"
#Database password
jdbc_password=>"pass"
#mysqljavaDriver address
jdbc_driver_library=>"/home/rzxes/logstash-5.3.1/mysql-connector-java-5.1.17.jar"
jdbc_driver_class=>"com.mysql.jdbc.Driver"
jdbc_paging_enabled=>"true"
jdbc_page_size=>"100000"
#sql statement file, you can also write SQL directly, such as statement => "select * fromtable1"
statement_filepath=>"/home/rzxes/logstash-5.3.1/test.sql"
schedule=>"*****"
type=>"jdbc"
}
}
output{
stdout{
codec=>json_lines
}
elasticsearch{
hosts=>"192.168.230.150:9200"
index => "test-1" #index name
document_type=>"form"#type名称
document_id => "% {id}" # id must be the sequence field of the data table to be queried
}}
If it is mysql, it needs mysql-connector-java-5.1.17.jar, if it is oracle, it needs ojdbc6.jar;
Enter the following command in cmd under the logstash home directory:
logstash-fjdbc.conf
Finally, check whether the data is imported into es
Reference materials: http://www.jaofuan.top/u/detail/4d87dfd8551f4449928d2c6651673ec5