I have created a multi-node hadoop cluster and installed hive on it. Also, on another remote machine I have installed MySQL.
I intend to export data stored in HDFS into relational database MySQL. I researched about how this can be done using Sqoop. So I found that I need to create a table in MySQL that has target columns in the same order(as present in Hive), with the appropriate SQL types. And then use the sqoop export command.
My question is:
If the table is partitioned in Hive, and if while creating the table in MySQL I partition it accordingly, will the sqoop export command preserve the partitions?
My question is similar to sqoop export mysql partition. I want to know if partitioning support has been added to sqoop.
This will help me decide whether to go ahead and install scoop for the task or to use some custom Python scripts that I have written for it.
Thank you.
Sqoop will work at the JDBC layer when talking to MySQL. It won't be aware of the underlying partitioning, MySQL will handle this as the records are inserted or updated.
Related
I have installed CDH 5.16 in a RHEL 7 server and installed kafka separately.
I am trying to load data from mysql to HDFS or Hive table on real time basis(CDC approach). That is if some data is updated or added in mysql table ,it should be immediately reflected in HDFS or Hive table.
Approach i have come up with:
Use kafka-connect to connect to mysql server and push table data to a kafka topic
and write a consumer code in spark-stream which reads the data from topic
and store it in HDFS.
One problem with this approach is, hive table on top of these files should
be refreshed periodically for the update to be reflected.
I also came to know of Kafka-Hive integration in HDP 3.1. Unfortunately i am using Hadoop 2.6.0. So cant leverage this feature.
Is there any other better way achieve this?
I am using Hadoop 2.6.0 and CDH 5.16.1
I am a new bie to Sqoop. As per my understanding, Sqoop commands are for importing data from database like MySql to HDFs and viceversa and HDFS commands are for dealing with data in HDFS, such as getting data from HDFS to local file system and viceversa. Cant we use sqoop commands to deal with data in HDFS - to get the data from local file system to hdfs and viceversa. Please let me know the exact differences between Sqoop and HDFS commands. Why do we have two separate things. Why they did not put all these commands into one set. Apologies, if my question does not make sense.
Sqoop commands serves below purposes:
1)Import/export data from any database to hdfs/hive/hbase and vice versa. Its not restrict only to hdfs import and export.
2)data can be sqooped at one go if we need to move a whole database/list of tables.
3)only incremental data can be imported via sqoop commands.
4) It also required connection driver to connect to databases
In short it deals with tables/databases.
hdfs commands:
1) It only used to transfer any type(csv,text,xls) of file from local to hdfs or vice versa. Its just serve basic functionality of moving or copying data from one system to other just like unix commands.
Sqoop only functionality to import and export data from RDBMS (Structured) to Hadoop. It does not provide any other HDFS inside activities. Once if you get the data using Sqoop to HDFS, HDFS commands will be used to process the data (copy, move,etc)
For more Sqoop functionalities http://hortonworks.com/apache/sqoop/
Yes your understanding is correct.
Sqoop commands are for :
importing data from any relational database(like mysql) to HDFS/Hive/Hbase
exporting data from HDFS/Hive/Hbase to any relational database(like mysql)
hdfs commands are for :
Copying/transferring any files (like :.txt,.csv,.xls,..etc) from local to hdfs or vice versa.
for :
Why do we have two separate things. Why they did not put all these commands into one set.
answer :
Sqoop commands
(for copying structured data b/w two different systems)
Hdfs commands
(for copying files b/w local and hdfs)
using sqoop we cannot copy files from local to hdfs and viceversa
and also
using hdfs commands we cannot copy data from hdfs to any other external databases (like mysql) and viceversa.
I created a test database for my Java program which connects to it. Now I want to use it on another PC without this test database. Is it possible to create an instance of my database to install it on a certain PC?
Notes:
The PC I want to use my Database on has no MYSQL installed
Questions:
How can I setup my database with a batch file?
Do I need to install MYSQL first or is it possible to use my database without it?
If MYSQL needs to be installed, how can I do it and how can I include my already created tables via batch file?
Edit:
We already have the tables but a new database should be installed on when the program starts the first time.
Yes. You can import your data on PC without installation of MySQL using mysqlimport.
shell> mysqlimport [options] db_name textfile1 [textfile2 ...]
There are many options available for mysqlimport. See here mysqlimport --help, -?.
NOTE : It uses .txt file.
I have a database. All I want to do is dump ALL the existing data in every table to I can then use it to simply import the SQL to my new database?
Im presuming the dump will be a bunch of MySQL INSERT statements
You can also use mysqldump, native mysql tool for this purpose.
You can use a tool such as mysql workbench or phpmyadmin to create the dump.
It will be a bunch of inserts as well as all the other data in it (such as procedures).
I am using hbase-0.90.6. I want to export the data from HBase to mysql. I know two-step process , first by running a mapreduce job to pull Hbase data into flat files, then exports flat file data into mysql.
Is their any other tool which I can use to reduce this two-step to one. Or can we use sqoop to do the same in one step. Thanks.
I'm afraid that Sqoop do not support exports directly from HBase at the moment. Sqoop can help you in the two-step process with the second step - e.g. Sqoop can take data from HDFS and export them to MySQL.
Yes Sqoop is the tool that can be used for both importing as well as exporting ur data from/to mysql and HBase
You can know more about Sqoop #
http://sqoop.apache.org