Search code examples
hbase

How to specify RPC server port for hbase?


I'm starting hbase inside a docker container and want client code to be able to connect to hbase rpc server port. Problem is: it is always different (randomly selected from ephemeral ports range).

Looking through hbase code (https://github.com/apache/hbase/blob/9facfa550f1e7386be3a04d84f7e8013f5002965/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java, bindAddress from line 1078) I see that I can override port by setting "hbase.regionserver.port" or "hbase.master.port".

I tried setting these in hbase-conf.xml but without any effect - port is still random as if these properties were resolved to 0.

How do I change that?


Solution

  • Found the solution. By default Hbase starts in a standalone mode and port is selected randomly. So after reading the doc I edited the hbase-site.xml to look like this:

    <configuration>
    <property>
        <name>hbase.cluster.distributed</name>
        <value>true</value>
    </property>
    <property>
        <name>hbase.regionserver.ipc.address</name>
        <value>0.0.0.0</value>
    </property>
    <property>
        <name>hbase.master.ipc.address</name>
        <value>0.0.0.0</value>
    </property>
    

    Notice that I'm making it run in a distributed mode (pseudo-distributed in my case) and set ipc listen addresses to 0.0.0.0 for both master and regionserver (otherwise you still can't connect from outside of docker container). After these changes ports became stable so everything is fine.

    Additional note: after switching to a distributed mode I had to set JAVA_HOME specifically in hbase-env.sh. This can be found in docs though.