无法从 windows 远程客户端连接到 HBase 独立服务器
Unable to connect to HBase stand alone server from windows remote client
我在 centos 虚拟机上有我的 HBase 独立服务器,我的客户端在 windows 桌面上。我可以远程连接到 HBase 独立服务器而不在 windows 上安装 HBase 吗?如果是,这里有以下文件
/etc/hosts 文件
172.16.108.1 CentOS60-64 # 由 NetworkManager 添加
127.0.0.1 localhost.localdomain 本地主机
172.29.36.32 localhost.localdomain 本地主机
172.29.36.32 534CentOS64-0
hbase-site.xml文件
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///root/Desktop/HBase/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/root/Desktop/HBase/zookeeper</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>62181</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>172.29.36.32</value>
</property>
</configuration>
/conf/regrionservers 文件
本地主机
172.29.36.32
连接到 HBase 服务器的代码片段
Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", "172.29.36.32");
config.set("hbase.zookeeper.property.clientPort", "62181");
// Creating Admin
HBaseAdmin admin = new HBaseAdmin(config);
// Creating Table Descriptor
HTableDescriptor describe =admin.getTableDescriptor(org.apache.hadoop.hbase.TableName.valueOf("emp"));
// Fetching all column families
Set<byte[]> ColumnFamily = describe.getFamiliesKeys();
// Listing Out the all column families
System.out.println(ColumnFamily.size());
Iterator<byte[]> it=ColumnFamily.iterator();
while(it.hasNext())
{
System.out.println(Bytes.toString(it.next()));
}
--- 当我尝试 运行 上面的代码时,运行 花费的时间太长并引发错误...未知主机:localhost.localdomain
--- 我能够连接到以下 url :-
http://172.29.36.32:60010/master-status
PS:- 如果有人能帮助我,我将不胜感激
回答晚了,但我希望它能对某人有所帮助。
您遇到的问题可能是 /etc/hosts 文件。我认为您应该删除以下行:
172.29.36.32 localhost.localdomain 本地主机
此外,如果您连接到远程 HBase 集群 - 确保将 所有 集群主机名和 ip 添加到本地主机文件(/etc/hosts Linux 或 Windows 上的 C:\Windows\System32\drivers\etc\hosts),像这样:
172.16.108.1 CentOS60-64
172.29.36.32 534CentOS64-0
显然 Zookeper 在尝试连接到 HBase 时在某处使用主机名而不是 ip,并且在使用 Java 远程连接时可能会出现问题。
希望对您有所帮助!
也许您应该修改 /etc/hosts
文件。举个例子。
[your ip can be accessed remote] [your domain will be used by remote server ]
[your ip same as last row ] [your hostname which can get by command hostname
]
和domain
和hostname
不应出现在映射其他IP地址的其他行上。
之后客户端会使用domain
访问你的hbase server.You可以在log中获取到那个信息
可以通过以下代码查看
import java.net.InetAddress;
public class Test{
public static void main(String args[]) throws Exception{
System.out.println(InetAddress.getLocalHost().getCanonicalHostName());
}
}
我在 centos 虚拟机上有我的 HBase 独立服务器,我的客户端在 windows 桌面上。我可以远程连接到 HBase 独立服务器而不在 windows 上安装 HBase 吗?如果是,这里有以下文件
/etc/hosts 文件
172.16.108.1 CentOS60-64 # 由 NetworkManager 添加 127.0.0.1 localhost.localdomain 本地主机 172.29.36.32 localhost.localdomain 本地主机
172.29.36.32 534CentOS64-0
hbase-site.xml文件
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///root/Desktop/HBase/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/root/Desktop/HBase/zookeeper</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>62181</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>172.29.36.32</value>
</property>
</configuration>
/conf/regrionservers 文件
本地主机 172.29.36.32
连接到 HBase 服务器的代码片段
Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", "172.29.36.32");
config.set("hbase.zookeeper.property.clientPort", "62181");
// Creating Admin
HBaseAdmin admin = new HBaseAdmin(config);
// Creating Table Descriptor
HTableDescriptor describe =admin.getTableDescriptor(org.apache.hadoop.hbase.TableName.valueOf("emp"));
// Fetching all column families
Set<byte[]> ColumnFamily = describe.getFamiliesKeys();
// Listing Out the all column families
System.out.println(ColumnFamily.size());
Iterator<byte[]> it=ColumnFamily.iterator();
while(it.hasNext())
{
System.out.println(Bytes.toString(it.next()));
}
--- 当我尝试 运行 上面的代码时,运行 花费的时间太长并引发错误...未知主机:localhost.localdomain
--- 我能够连接到以下 url :- http://172.29.36.32:60010/master-status PS:- 如果有人能帮助我,我将不胜感激
回答晚了,但我希望它能对某人有所帮助。 您遇到的问题可能是 /etc/hosts 文件。我认为您应该删除以下行:
172.29.36.32 localhost.localdomain 本地主机
此外,如果您连接到远程 HBase 集群 - 确保将 所有 集群主机名和 ip 添加到本地主机文件(/etc/hosts Linux 或 Windows 上的 C:\Windows\System32\drivers\etc\hosts),像这样:
172.16.108.1 CentOS60-64
172.29.36.32 534CentOS64-0
显然 Zookeper 在尝试连接到 HBase 时在某处使用主机名而不是 ip,并且在使用 Java 远程连接时可能会出现问题。
希望对您有所帮助!
也许您应该修改 /etc/hosts
文件。举个例子。
[your ip can be accessed remote] [your domain will be used by remote server ]
[your ip same as last row ] [your hostname which can get by commandhostname
]
和domain
和hostname
不应出现在映射其他IP地址的其他行上。
之后客户端会使用domain
访问你的hbase server.You可以在log中获取到那个信息
可以通过以下代码查看
import java.net.InetAddress;
public class Test{
public static void main(String args[]) throws Exception{
System.out.println(InetAddress.getLocalHost().getCanonicalHostName());
}
}