Windows Eclipse 调试 HBase

本文介绍了在Windows环境下使用Eclipse调试HBase的过程,包括配置步骤和常见的错误处理。在Windows上,确保Eclipse能够正确加载hbase-default.xml和hbase-site.xml配置文件。在Linux HBase设置中,可能会遇到找不到winutils.exe的问题,以及连接被拒绝的错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Hbase版本:hbase-0.98.17-hadoop2/


Windows Eclipse 配置

1. 新建maven工程,添加maven依赖
	<dependencies>
		<dependency>
			<groupId>org.apache.hbase</groupId>
			<artifactId>hbase-client</artifactId>
			<version>0.98.17-hadoop2</version>
		</dependency>
		<dependency>
			<groupId>jdk.tools</groupId>
			<artifactId>jdk.tools</artifactId>
			<version>1.7</version>
			<scope>system</scope>
			<systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
		</dependency>
	</dependencies>

	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-compiler-plugin</artifactId>
					<configuration>
						<source>1.7</source>
						<target>1.7</target>
					</configuration>
				</plugin>
				<plugin>
					<groupId>org.apache.felix</groupId>
					<artifactId>maven-bundle-plugin</artifactId>
					<extensions>true</extensions>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>

2. 工程新增Class Folder:Build Path --> Configure Build Path…


3. 将hbase配置文件hbase-site.xml添加到上一步新建的Class Folder中

若不添加hbase-site配置文件至Class Folder中,也可在代码中添加
		Configuration conf = HBaseConfiguration.create();
		conf.set("hbase.zookeeper.property.clientPort", "2181");
		conf.set("hbase.zookeeper.quorum", "192.168.1.101");

调用静态create()方法时,代码会尝试使用当前的Java classpath来加载hbase-default.xml和hbase-site.xml两个配置文件。

当然在HTable使用之前,用户也可以修改配置,因此没有没有添加hbase-site.xml至classpath中,也可在代码中添加集群信息。

4. Windows环境下本地新建Hadoop Home

Main函数添加Hadoop Home
	public static void main(String[] args) throws Exception {
		System.setProperty("hadoop.home.dir", "d:\\hadoop_home");
		......
	}

Linux Hbase 设置

~/hbase-0.98.17-hadoop2/conf$ regionservers 设置IP
vi /etc/hosts 将IP与hosts关联

常见报错


java.io.IOException: Could notlocate executable D:\hadoop_home\bin\winutils.exe in the Hadoop binaries.

解决:
本地没有设置hadoop home,见上文

org.apache.hadoop.ipc.RpcClient]- IPC Client (143695640) connection to hbase01/192.168.1.101:60020 from user1:closing ipc connection to hbase01/192.168.1.101:60020: Connection refused: nofurther information

java.net.ConnectException: Connection refused: no further information
解决:
60020为regionserver端口号,regionserver拒绝连接
/ect/hosts将局域网IP与主机名关联,取消127.0.0.1与主机名的关联
Hbas econf/regionservers 设置局域网IP,非127.0.0.1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值