# Migrating Mysql data to elasticsearch using logstash

**URL:** <https://discuss.elastic.co/t/migrating-mysql-data-to-elasticsearch-using-logstash/149395>\
**Category:** Logstash\
**Created:** [September 21, 2018, 6:26am UTC](https://discuss.elastic.co/t/migrating-mysql-data-to-elasticsearch-using-logstash/149395 "2018-09-21T06:26:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![padmaja](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@padmaja](https://discuss.elastic.co/u/padmaja)\
**Post date:** [September 21, 2018, 6:26am UTC](https://discuss.elastic.co/t/migrating-mysql-data-to-elasticsearch-using-logstash/149395/1 "2018-09-21T06:26:22Z")

</div>

Hi,  
I'm new to kibana. i need a brief explanation of how can i convert MySQL data to Elastic Search .I have just installed all the requirements and tried to convert data using jdbc input plugin but, i'm unable to do it.i didn't even understand how the process is going i just copy pasted the code from one particular website.can anyone explain the steps of how to do conversion using logstash step by step .

TIA,  
padmaja

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 21, 2018, 6:32am UTC](https://discuss.elastic.co/t/migrating-mysql-data-to-elasticsearch-using-logstash/149395/2 "2018-09-21T06:32:04Z")

</div>

Have you read [https://www.elastic.co/blog/logstash-jdbc-input-plugin](https://www.elastic.co/blog/logstash-jdbc-input-plugin)?

It's highly likely that nobody is going to write a general and detailed explanation of this just for you. If you ask a more specific question you'll have a bigger chance of getting useful responses.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 21, 2018, 6:48am UTC](https://discuss.elastic.co/t/migrating-mysql-data-to-elasticsearch-using-logstash/149395/4 "2018-09-21T06:48:25Z")

</div>

Comment out your elasticsearch output for now and verify that the stdout outputs are producing data, indicating that the jdbc input is working. Introduce complexity gradually.

---

<div class="post-metadata">

**Author:** ![padmaja](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@padmaja](https://discuss.elastic.co/u/padmaja)\
**Post date:** [September 24, 2018, 9:06am UTC](https://discuss.elastic.co/t/migrating-mysql-data-to-elasticsearch-using-logstash/149395/6 "2018-09-24T09:06:03Z")

</div>

Here, is the logstash.conf file where i specified the input and output:  
input {  
jdbc {  
jdbc\_connection\_string =\> "jdbc:mysql://localhost:3306/kibana"  
jdbc\_user =\> "xxx"  
jdbc\_password =\> "xxxxx"  
jdbc\_driver\_library =\> "/root/mysql-connector-java-5.1.30/mysql-connector-java-5.1.30-bin.jar"  
jdbc\_driver\_class =\> "com.mysql.jdbc.Driver"  
statement =\> "SELECT \* FROM datalog"

}  
}  
output {  
elasticsearch {  
"hosts" =\> "localhost:9200"  
}  
stdout { codec =\> rubydebug }  
}  
after running the above file by using ./logstash -f logstash.conf we are getting the below error:

WARNING: Could not find logstash.yml which is typically located in $LS\_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults Could not find log4j2 configuration at path /usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console  
{  
"name" =\> "abc",  
"id" =\> 1,  
"@timestamp" =\> 2018-09-24T08:48:56.067Z,  
"@version" =\> "1",  
"testid" =\> 10  
}  
{  
"name" =\> "xyz",  
"id" =\> 2,  
"@timestamp" =\> 2018-09-24T08:48:56.068Z,  
"@version" =\> "1",  
"testid" =\> 10  
}  
{  
"name" =\> "pqr",  
"id" =\> 3,  
"@timestamp" =\> 2018-09-24T08:48:56.068Z,  
"@version" =\> "1",  
"testid" =\> 30  
}

But, index is not generated for the above file.suggest me if there any modifications in the above file

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 24, 2018, 10:10am UTC](https://discuss.elastic.co/t/migrating-mysql-data-to-elasticsearch-using-logstash/149395/7 "2018-09-24T10:10:19Z")

</div>

In your elasticsearch output there shouldn't be any double quotes around `hosts`. That might not be why it doesn't work for you but start by fixing it anyway.

---

<div class="post-metadata">

**Author:** ![padmaja](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@padmaja](https://discuss.elastic.co/u/padmaja)\
**Post date:** [September 25, 2018, 4:47am UTC](https://discuss.elastic.co/t/migrating-mysql-data-to-elasticsearch-using-logstash/149395/8 "2018-09-25T04:47:27Z")

</div>

after removing the double quotes we are not getting the errors but the index pattern is not getting generated.

Output:

OpenJDK 64-Bit Server VM warning: If the number of processors is expected to inc rease from one, then you should configure the number of parallel GC threads appr opriately using -XX:ParallelGCThreads=N  
WARNING: Could not find logstash.yml which is typically located in $LS\_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults  
Sending Logstash's logs to /usr/share/logstash/logs which is now configured via log4j2.properties  
{  
"id" =\> 1,  
"name" =\> "abc",  
"testid" =\> 10,  
"@timestamp" =\> 2018-09-25T04:44:41.239Z,  
"@version" =\> "1"  
}  
{  
"id" =\> 2,  
"name" =\> "xyz",  
"testid" =\> 10,  
"@timestamp" =\> 2018-09-25T04:44:41.239Z,  
"@version" =\> "1"  
}  
{  
"id" =\> 3,  
"name" =\> "pqr",  
"testid" =\> 30,  
"@timestamp" =\> 2018-09-25T04:44:41.240Z,  
"@version" =\> "1"  
}

the indices generated:  
[root@localhost bin]# curl localhost:9200/\_cat/indices?v

health status index uuid pri rep docs.count docs.deleted store.size pri.store.size  
yellow open .kibana sIUptrmVQaWxrA3b8NYWoA 1 1 154 1 168.6kb 168.6kb

---

<div class="post-metadata">

**Author:** ![nandan\_bigdata](https://avatars.discourse-cdn.com/v4/letter/n/f07891/32.png) [@nandan\_bigdata](https://discuss.elastic.co/u/nandan_bigdata)\
**Post date:** [September 25, 2018, 5:15am UTC](https://discuss.elastic.co/t/migrating-mysql-data-to-elasticsearch-using-logstash/149395/9 "2018-09-25T05:15:52Z")

</div>

You can refer below tutorial also if you like to.

> **[Migrate Data from RDBMS To Elasticsearch Using Logstash | ELK Stack](http://nandanpriyadarshi.co.in/migrate-data-rdbms-elasticsearch-logstash/)**
>
> In this article, Migrate Data from RDBMS To Elasticsearch Using Logstash | ELK Stack in-depth steps for writting logstash config file in windows and ubuntu

---

<div class="post-metadata">

**Author:** ![padmaja](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@padmaja](https://discuss.elastic.co/u/padmaja)\
**Post date:** [September 25, 2018, 7:02am UTC](https://discuss.elastic.co/t/migrating-mysql-data-to-elasticsearch-using-logstash/149395/10 "2018-09-25T07:02:04Z")

</div>

Thanks for response.  
I have provided inputs in my file as mentioned in your tutorial .Although, index is not getting generated.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 23, 2018, 7:15am UTC](https://discuss.elastic.co/t/migrating-mysql-data-to-elasticsearch-using-logstash/149395/11 "2018-10-23T07:15:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
