我想将我的本地java / scala进程连接到远程HBase服务器(v 1.1.2)(在docker中)。我有以下代码:
val config = HBaseConfiguration.create()
BasicConfigurator.configure()
config.set("hbase.zookeeper.quorum", "192.168.99.100")
config.set("hbase.zookeeper.property.clientPort","2181")
config.set("hbase.master", "192.168.99.100:9090")
val connection = ConnectionFactory.createConnection(config)
在码头工具中,我打开了以下端口:8085,2181,8080,9090,16010
直到日志中的这一行:
735 [hconnection-0x471a9022-shared--pool1-t1] DEBUG org.apache.hadoop.hbase.ipc.AbstractRpcClient - Use SIMPLE authentication for service ClientService, sasl=false
747 [hconnection-0x471a9022-shared--pool1-t1] DEBUG org.apache.hadoop.hbase.ipc.AbstractRpcClient - Connecting to docker-hbase/192.168.99.100:39160
896 [main] DEBUG org.apache.hadoop.hbase.ipc.AbstractRpcClient - Use SIMPLE authentication for service MasterService, sasl=false
896 [main] DEBUG org.apache.hadoop.hbase.ipc.AbstractRpcClient - Connecting to docker-hbase/192.168.99.100:43454
我的问题是,每次重新启动服务时,此ClientService和MasterService都会尝试连接不同的端口(在本例中为39160和43454),这样我就无法修复在docker中打开的端口。
答案 0 :(得分:1)
您需要以伪分布式模式启动HBase。有关详细信息,请参阅我的答案How to specify RPC server port for hbase?
答案 1 :(得分:0)
这是不正确的:
#!/usr/local/bin/python
import ConfigParser
config = ConfigParser.ConfigParser()
config.read('test.env')
print config.get('DB','DB_DATABASE')
应该是:
val connection = ConnectionFactory.createConnection(hconf)