r/DatabaseHelp • u/ConvexMacQuestus • Jan 23 '21
Problems with writing in hbase with MapReduce
Hi! I need to write into a Hbase table (that already exists) using Mapreduce and java. I am only converting data from a nljson to HBase, so I don't use a reducer. This is for a school project so I can not change the cluster configuration (and the teacher is not really quick to fix things), but it is supposed to be ok. I use maven to create a *.jar file, and I dispatch the work through yarn. However, I got an error message. It feels like I am not configuring well my environment or something, but I really could not find the problem. Maven compiles correctly.
This is the code : https://gist.github.com/Tangrenin/17b54e164e049562fc5f42322f97f607
I tried adding this line to the main function but it does nothing different : conf.addResource(new Path("/espace/Auber_PLE-203/hbase/conf/hbase-site.xml"));
Is there a problem to fix in my code, or could it actually by the because of the cluster configuration? Otherwise is there maybe another more appropriate way to write in HBase here ?
I would greatly appreciate any help!
Here is the error message :https://gist.github.com/Tangrenin/2ac850e377ff92a289a31f80485c762f
1
u/teachmehowtodougie Jan 23 '21
Been a long time, but you are having a path issue for your site.xml. Can you confirm that file loves on that path on all of your datanodes? I also believe you can just put it on hdfs and make your life easier.
1
u/teachmehowtodougie Jan 23 '21
Re-reading your posted error the conf thing feels like a red herring. You need to grab the error log from one of the YARN containers to see what is failing. Can you post that?
1
u/teachmehowtodougie Jan 23 '21
Are you building it from source? That library most likely exists in HBase jars just Google the path of the missing library
1
u/zman0900 Jan 23 '21 edited Jan 23 '21
Use should use [this method](https://hbase.apache.org/1.2/apidocs/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.html#initTableReducerJob(java.lang.String,%20java.lang.Class,%20org.apache.hadoop.mapreduce.Job)) in your main class to set up writing to hbase. Just pass null for the reducer class. That will make sure the hbase dependencies are available to the mapper class also (using libjars) and with set up serialization config so Hadoop knows what to do with the hbase types like Put.
Also, when launching the job with
hadoop jarcommand, you may need to add the output of the commandhbase mapredcpinto your HADOOP_CLASSPATH environment variable. This should make the hbase deps available to your main class.