====== MySQL River introduction ======
- what is River? The river represents a data source for ES and is also a way to synchronize data to ES with other storage methods (such as databases). It is an ES service that exists in plug-in mode, by reading the data in the river and indexing it into ES, the official river is couchdb, RABBITMQ, Twitter, Wikipedia. The main research here is the river for MySQL.
-MySQL River plugin: MySQL River installation See HTTPS://GITHUB.COM/JPRANTE/ELASTICSEARCH-RIVER-JDBC, not specifically introduced.
-Practice Testing:
* Environment:
Server 172.16.170.21 Database: Profile table User
* Create an index
curl-xput ' Http://localhost:9200/profile '
* Create data tables and index mappings
curl-xput ' http://localhost:9200/profile/user/_mapping '-d '
{
"User": {
"Properties": {
"id": {
' type ': ' String ',
"Store": "Yes"
},
' name ': {
' type ': ' String ',
"Store": "Yes"
},
"Login_name": {
' type ': ' String ',
"Store": "Yes"
}
}
}
} '
* Run River Sync data
curl-xput ' Http://localhost:9200/_river/who_jdbc_river/_meta '-d ' {
"type": "JDBC",
"jdbc": {
" Driver": "Com.mysql.jdbc.Driver",
" url": "Jdbc:mysql://localhost:3306/profile",
"user": "Root",
"password": "Root",
"SQL": "SELECT ID as _id,name,login_name from user",
"index": "Profile",
"type": "User",
"Bulk_size":
"max_bulk_requests":
" bulk_timeout": "10s",
" flush_interval": "5s",
" Schedule": "0 0-59 0-23?" * *"
}
} '
* Incremental update index
incremental update, the table requires a maintenance timestamp, and the column that discovers the timestamp update needs to be updated
curl-xput ' Http://localhost:9200/_river/who_jdbc_river/_meta '-d ' {
"type": "JDBC",
"jdbc": {
" Driver": "Com.mysql.jdbc.Driver",
" url": "Jdbc:mysql://localhost:3306/profile",
"user": "Root",
"password": "Root",
"SQL": [
{
"statement": "SELECT ID as _id,name,login_name from user where Mytimestamp >?",
"parameter": [
"$river. State.last_active_begin"
]
}
],
"index": "Profile",
"type": "User",
"Bulk_size":
"max_bulk_requests":
" bulk_timeout": "10s",
" flush_interval": "5s",
" Schedule": "0 0-59 0-23?" * *"
}
} '
Delete River
Curl-xdelete ' Localhost:9200/_river/report_jdbc_river '
Elasticsearch using river to synchronize MySQL data