java.lang.NumberFormatException 尝试连接到 HBase 时
java.lang.NumberFormatException when trying to connect to HBase
我正在设置 HBase 配置 new HBaseGraphConfiguration().set("hbase.zookeeper.quorum", ZOOKEPER_QORUM_NODE)
其中
ZOOKEPER_QORUM_NODE = "172.31.17.251:2181,172.31.17.252:2181,172.31.17.253:2181";
但是它抛出 java.lang.NumberFormatException
,错误的部分是
Caused by: java.lang.NumberFormatException: For input string: "2181]"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at org.apache.zookeeper.client.ConnectStringParser.<init>(ConnectStringParser.java:72)
错误行之前的控制台输出是
2018-05-30 14:40:52 INFO org.apache.zookeeper.ZooKeeper - Initiating client connection, connectString=[172.31.17.251:2181, 172.31.17.252:2181, 172.31.17.253:2181] sessionTimeout=180000 watcher=hconnection-0x25a65b770x0, quorum=[172.31.17.251:2181, 172.31.17.252:2181, 172.31.17.253:2181], baseZNode=/hbase
2018-05-30 14:40:52 INFO org.apache.zookeeper.ZooKeeper - Initiating client connection, connectString=[172.31.17.251:2181, 172.31.17.252:2181, 172.31.17.253:2181] sessionTimeout=180000 watcher=hconnection-0x25a65b770x0, quorum=[172.31.17.251:2181, 172.31.17.252:2181, 172.31.17.253:2181], baseZNode=/hbase
如何解决?
一些尝试调试的建议:
首先,您可以专门为客户端端口提供单独的 属性,而不是使用 IP:port
表示法:hbase.zookeeper.property.clientPort
因此请尝试分别提供这两个参数 - - 一个逗号分隔的地址列表,第二个参数只是这个数字(不过我将它作为字符串传递,所以 "2181"
)
其次,重要提示:通常在此处提供 IP 地址时要小心,因为 HBase 在 IP 地址和主机名方面似乎非常挑剔。使用主机名并将这些 IP 地址与所需的主机名
一起放在客户端的 /etc/hosts
文件中会更好
感谢@VS_FF 的回答,我已经找到问题所在,现在也发布完整的回答
这个问题的简解就是conf.setDelimiterParsingDisabled(true);
首先建议分别设置hbase.zookeeper.quorum = "ip1,ip2,ip3"
(主机ip)和hbase.zookeeper.property.clientPort = 2181
(端口)
IP 地址字符串输入到 HBase 配置中。然后,它有两种解析方法,由
控制
conf = new PropertiesConfiguration();
conf.setDelimiterParsingDisabled(true);
如果应用此setDelimiterParsingDisabled(true)
,则配置将原始字符串输入zookeeper,表示"ip1,ip2,ip3"
,否则setDelimiterParsingDisabled(false)
(这是默认设置),在这种情况下,它会输入一个数组给动物园管理员,说 [ip1,ip2,ip3]
.
但是zookeeper需要得到一个String
变量,所以如果是setDelimiterParsingDisabled(false)
,它会先把数组转成String
,加上括号[]
.
最后,zookeeper 解析 String
变量,使用符号拆分 ,
,这就是为什么它最终得到 ip1 = "[ip1", ip2 = "ip2", ip3 = "ip3]"
并抛出一个 NumberFormatException
我正在设置 HBase 配置 new HBaseGraphConfiguration().set("hbase.zookeeper.quorum", ZOOKEPER_QORUM_NODE)
其中
ZOOKEPER_QORUM_NODE = "172.31.17.251:2181,172.31.17.252:2181,172.31.17.253:2181";
但是它抛出 java.lang.NumberFormatException
,错误的部分是
Caused by: java.lang.NumberFormatException: For input string: "2181]"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at org.apache.zookeeper.client.ConnectStringParser.<init>(ConnectStringParser.java:72)
错误行之前的控制台输出是
2018-05-30 14:40:52 INFO org.apache.zookeeper.ZooKeeper - Initiating client connection, connectString=[172.31.17.251:2181, 172.31.17.252:2181, 172.31.17.253:2181] sessionTimeout=180000 watcher=hconnection-0x25a65b770x0, quorum=[172.31.17.251:2181, 172.31.17.252:2181, 172.31.17.253:2181], baseZNode=/hbase
2018-05-30 14:40:52 INFO org.apache.zookeeper.ZooKeeper - Initiating client connection, connectString=[172.31.17.251:2181, 172.31.17.252:2181, 172.31.17.253:2181] sessionTimeout=180000 watcher=hconnection-0x25a65b770x0, quorum=[172.31.17.251:2181, 172.31.17.252:2181, 172.31.17.253:2181], baseZNode=/hbase
如何解决?
一些尝试调试的建议:
首先,您可以专门为客户端端口提供单独的 属性,而不是使用 IP:port
表示法:hbase.zookeeper.property.clientPort
因此请尝试分别提供这两个参数 - - 一个逗号分隔的地址列表,第二个参数只是这个数字(不过我将它作为字符串传递,所以 "2181"
)
其次,重要提示:通常在此处提供 IP 地址时要小心,因为 HBase 在 IP 地址和主机名方面似乎非常挑剔。使用主机名并将这些 IP 地址与所需的主机名
一起放在客户端的/etc/hosts
文件中会更好
感谢@VS_FF 的回答,我已经找到问题所在,现在也发布完整的回答
这个问题的简解就是conf.setDelimiterParsingDisabled(true);
首先建议分别设置hbase.zookeeper.quorum = "ip1,ip2,ip3"
(主机ip)和hbase.zookeeper.property.clientPort = 2181
(端口)
IP 地址字符串输入到 HBase 配置中。然后,它有两种解析方法,由
控制conf = new PropertiesConfiguration();
conf.setDelimiterParsingDisabled(true);
如果应用此setDelimiterParsingDisabled(true)
,则配置将原始字符串输入zookeeper,表示"ip1,ip2,ip3"
,否则setDelimiterParsingDisabled(false)
(这是默认设置),在这种情况下,它会输入一个数组给动物园管理员,说 [ip1,ip2,ip3]
.
但是zookeeper需要得到一个String
变量,所以如果是setDelimiterParsingDisabled(false)
,它会先把数组转成String
,加上括号[]
.
最后,zookeeper 解析 String
变量,使用符号拆分 ,
,这就是为什么它最终得到 ip1 = "[ip1", ip2 = "ip2", ip3 = "ip3]"
并抛出一个 NumberFormatException