通过IDE来创建调试配置,在Intellij IDEA中,选择Edit Configurations,添加Remote,就可以看到IDE提供的调试参数,把它加到Java的运行参数里。
环境变量文件conf/hbase-env.sh里已经提供了这样的参数,只是注释掉了。找到对应的行,把注释去掉,就可以远程调试了。注意这里配置的端口要和IDE里的端口配置要一致。
# Enable remote JDWP debugging of major HBase processes. Meant for Core Developers
export HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8070"
# export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8071"
# export HBASE_THRIFT_OPTS="$HBASE_THRIFT_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8072"
# export HBASE_ZOOKEEPER_OPTS="$HBASE_ZOOKEEPER_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8073"
调试HBase时,还需要将超时时间参数设的长一些,以免因为调试时间过长导致连接超时断开、Server关闭等问题。 修改conf/hbase-site.xml,增加这几个参数。
<configuration>
<property>
<name>hbase.zookeeper.property.tickTime</name>
<value>1800000</value>
</property>
<property>
<name>zookeeper.session.timeout</name>
<value>1800000</value>
</property>
<property>
<name>hbase.client.scanner.timeout.period</name>
<value>1800000</value>
</property>
<property>
<name>hbase.rpc.timeout</name>
<value>1800000</value>
</property>
<property>
<name>hbase.rpc.shortoperation.timeout</name>
<value>1800000</value>
</property>
</configuration>
这时运行 start-hbase.sh,IDE中运行Debug,就可以调试了。
-END-