From 90092b8b8f9f580faefe75a7af371d2418c41f85 Mon Sep 17 00:00:00 2001 From: tmljob Date: Thu, 10 Dec 2020 10:05:34 +0800 Subject: [PATCH] Fix bug: hbase init error when kerberos is enabled fix #1292 --- hugegraph-dist/src/assembly/static/bin/init-store.sh | 4 +++- .../baidu/hugegraph/backend/store/hbase/HbaseOptions.java | 8 ++++++++ .../hugegraph/backend/store/hbase/HbaseSessions.java | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/hugegraph-dist/src/assembly/static/bin/init-store.sh b/hugegraph-dist/src/assembly/static/bin/init-store.sh index 4905ecb952..51628c0eed 100755 --- a/hugegraph-dist/src/assembly/static/bin/init-store.sh +++ b/hugegraph-dist/src/assembly/static/bin/init-store.sh @@ -22,15 +22,17 @@ ensure_path_writable $PLUGINS if [ -n "$JAVA_HOME" ]; then JAVA="$JAVA_HOME"/bin/java + EXT="$JAVA_HOME/jre/lib/ext:$LIB:$PLUGINS" else JAVA=java + EXT="$LIB:$PLUGINS" fi cd $TOP echo "Initializing HugeGraph Store..." -$JAVA -cp $LIB/hugegraph-dist-*.jar -Djava.ext.dirs=$LIB:$PLUGINS \ +$JAVA -cp $LIB/hugegraph-dist-*.jar -Djava.ext.dirs=$EXT \ com.baidu.hugegraph.cmd.InitStore \ "$CONF"/gremlin-server.yaml "$CONF"/rest-server.properties diff --git a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseOptions.java b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseOptions.java index ae74610fe0..d795bbb994 100644 --- a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseOptions.java +++ b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseOptions.java @@ -114,6 +114,14 @@ public static synchronized HbaseOptions instance() { "/etc/krb5.conf" ); + public static final ConfigOption HBASE_HBASE_SITE = + new ConfigOption<>( + "hbase.hbase_site", + "The HBase's configuration file", + null, + "/etc/hbase/conf/hbase-site.xml" + ); + public static final ConfigOption HBASE_KERBEROS_PRINCIPAL = new ConfigOption<>( "hbase.kerberos_principal", diff --git a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java index 336a6640c4..8ac922280c 100644 --- a/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java +++ b/hugegraph-hbase/src/main/java/com/baidu/hugegraph/backend/store/hbase/HbaseSessions.java @@ -33,6 +33,7 @@ import java.util.concurrent.Future; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellScanner; import org.apache.hadoop.hbase.CellUtil; @@ -135,6 +136,9 @@ public synchronized void open() throws IOException { hConfig.setInt("hbase.hconnection.threads.max", config.get(HbaseOptions.HBASE_THREADS_MAX)); + String hbaseSite = config.get(HbaseOptions.HBASE_HBASE_SITE); + hConfig.addResource(new Path(hbaseSite)); + if(isEnableKerberos) { String krb5Conf = config.get(HbaseOptions.HBASE_KRB5_CONF); System.setProperty("java.security.krb5.conf", krb5Conf);