Elasticsearch using river to synchronize MySQL data

Source: Internet
Author: User
Tags curl

====== 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.