In your conf file "hbase-env.sh":
Instead of the lines that you are having :
export HBASE_OPTS="-XX:+UseConcMarkSweepGC"
Add :
-Djava.security.krb5.realm= -Djava.security.krb5.kdc=
So the line will be
export HBASE_OPTS="-XX:+UseConcMarkSweepGC -Djava.security.krb5.realm= -Djava.security.krb5.kdc="
Look here for the context :Hadoop on OSX "Unable to load realm info from SCDynamicStore"
Get stuck when using java api to connect Hbase
Domanda
My local environment:
OS X 10.9.2, Hbase-0.94.17, Java 1.6
My Hbase mode: standalone
I was able to do operation in shell, but when I used java api, it did not work.
My java code:
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
public class MyLittleHBaseClient {
public static void main(String[] args) throws IOException {
Configuration config = HBaseConfiguration.create();
config.addResource("/Users/apple/Documents/tools/hbase-0.94.17/conf/hbase-site.xml");
HTable table = new HTable(config, "myLittleHBaseTable");
Put p = new Put(Bytes.toBytes("myLittleRow"));
p.add(Bytes.toBytes("myLittleFamily"), Bytes.toBytes("someQualifier"),
Bytes.toBytes("Some Value"));
table.put(p);
Get g = new Get(Bytes.toBytes("myLittleRow"));
Result r = table.get(g);
byte [] value = r.getValue(Bytes.toBytes("myLittleFamily"),
Bytes.toBytes("someQualifier"));
String valueStr = Bytes.toString(value);
System.out.println("GET: " + valueStr);
Scan s = new Scan();
s.addColumn(Bytes.toBytes("myLittleFamily"), Bytes.toBytes("someQualifier"));
ResultScanner scanner = table.getScanner(s);
try {
for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {
// print out the row we found and the columns we were looking for
System.out.println("Found row: " + rr);
}
} finally {
scanner.close();
}
}
}
Here is some of my conf doc:
###########################################hbase-env.sh:export JAVA_HOME=`/usr/libexec/java_home -v '1.6*'`
export HBASE_OPTS="-XX:+UseConcMarkSweepGC"
###########################################hbase-site.sh:
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///Users/apple/Documents/tools/hbase-0.94.17/hbase-rootdir/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/Users/apple/Documents/tools/hbase-0.94.17/hbase-zookeeper/zookeeper</value>
</property>
</configuration>
When I ran the java code above, I got the following information:
log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2014-03-31 13:20:15.037 java[873:1003] Unable to load realm info from SCDynamicStore
and then the console just stopped here and gave nothing more.(no more response)
Also I attach my /Users/apple/Documents/tools/hbase-0.94.17/logs/hbase-apple...local.log here:
https://docs.google.com/file/d/0BxtBre5A8J61Y2k3SXNtNGs1WXM/edit
Thanks for your patient, your answer will be a great help to me :)
Soluzione
Altri suggerimenti
You don't need
Configuration config = HBaseConfiguration.create();
config.addResource("/Users/apple/Documents/tools/hbase-0.94.17/conf/hbase-site.xml");
if you add this in hbase-site.xml .
and add this to your hbase-site.xml :
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
I also met this problem. I had config server name in hbase-site.xml rather than the IP, and my java client also stuck in this situation.
So I set my client system host for the server name, and I solved this case.
At first, You check clientPort in hbase-site.xml file:
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2222</value>
</property>
And in java program: You must set clientPort the same as in hbase-site.xml file:
Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.property.clientPort", "2222");