我正在将数据从Microsoft sql服务器数据库传输到mongodb数据库。
我有2个表,我想将每个表转移到一个集合中。
我正在使用logstash。
这是我的2个配置文件:
/etc/logstash/conf.d/batch1.conf:
input {
jdbc {
jdbc_driver_library => "/usr/share/java/mssql-jdbc-6.4.0.jre8.jar"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:sqlserver://x.y.z.a"
jdbc_user => "sa"
jdbc_password => "<sqlserverpassword>"
schedule => "* * * * *"
statement => "select * from test.dbo.table1 where id_table1>:sql_last_value"
tracking_column => id_table1
use_column_value => true
last_run_metadata_path => "/var/lib/logstash/last_table1"
}
}
output {
mongodb {
uri => 'mongodb://mongodbuser:mongodbpassword@localhost/bddtest'
database => "mydb"
collection => "collection1"
}
}
/etc/logstash/conf.d/batch2.conf:
input {
jdbc {
jdbc_driver_library => "/usr/share/java/mssql-jdbc-6.4.0.jre8.jar"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:sqlserver://x.y.z.a"
jdbc_user => "sa"
jdbc_password => "<sqlserverpassword>"
schedule => "* * * * *"
statement => "select * from test.dbo.table2 where id_table2>:sql_last_value"
tracking_column => id_table2
use_column_value => true
last_run_metadata_path => "/var/lib/logstash/last_table2"
}
}
output {
mongodb {
uri => 'mongodb://mongodbuser:mongodbpassword@localhost/bddtest'
database => "mydb"
collection => "collection2"
}
}
这很奇怪:批处理作业似乎工作正常。
但是当我查看mongodb collection1和collection2集合时,我会看到同一件事,它是table1和table2的合并!
我不明白为什么要合并数据!
谢谢