2

I am trying to connect to a VM with Accumulo. The problem is, I can't get it hooked up in Java. I can see the webpage Apache throws up, but I can't get it to work with code. I think this is a lack of knowledge issue rather than a real problem, but I can't find documentation on it. All the examples use localhost as the zooServer name, this obviously doesn't work for me.

So, here is my code:

  String instanceName = "accumulo-02"
  String zooServers = "192.168.56.5, accumulo-02.localdomain:9997"
  ZooKeeperInstance inst = new ZooKeeperInstance(instanceName, zooServers)
  ....

The rest isn't important because I cannot connect to the server.

This is also really written in Groovy. I just changed my code there for the Java guys.

Edit: The program resides on my computer. Accumulo, Hadoop, and Zookeeper are all on the VM. The ip of it is that IP and the isntance name is that name. In the config of accumulo, 'accumulo-02' is the domain for masters, slaves, and etc...

Mitchell Ingram
  • 686
  • 2
  • 11
  • 23
  • The client is running on the VM host? Is there any sort of firewall configured between the host and guest? – Scott Mar 19 '13 at 16:39
  • The client is on my computer. Accumulo, Zookeeper, and Hadoop are all on the VM. But no, there is no firewall. – Mitchell Ingram Mar 19 '13 at 16:45
  • This seems like a networking thing more than an Accumulo thing. Can you ping 192.168.56.5 from the host? The hostname "accumulo-02.localdomain" might not be resolving. You could try using an IP address there instead of a fqdn. – Scott Mar 19 '13 at 16:52
  • Yeah, I can ping 192.168.56.5. I can also view the webpage that accumulo spins up on port 50095. This isn't accumulo's fault. I am being dumb about something. I am not sure if it is the Instance name, or Zookeeper or what. Basically, if I call it what it actually is (i.e. Accumulo-02) it looks internally for accumulo. So, I need to tell it to look externally. The problem with that is then it is looking for a zookeeper name 192.168.56.5 which doesn't exist either because it is call accumulo-02. So I have a revolving door problem. – Mitchell Ingram Mar 19 '13 at 17:01
  • The instance name should whatever you named your database (this is not the hostname or IP address). The zookeepers should be a list of hostnames. Actually, I would expect a single-node setup like yours to only have one zookeeper (the IP address). Do you have the right instance name? I don't understand your "revolving door" comment... – Scott Mar 19 '13 at 17:09
  • So the instance name is right. What I mean is that because zookeeper is named accumulo-02, it looks internally. If I tell it to look to 192.168.56.5 as the host name, it looks into to it and goes 'now what?' because there isn't actually a zookeeper named by the IP. – Mitchell Ingram Mar 19 '13 at 17:11
  • 1
    Got it to work. I added the IP to my /etc/hosts under accumulo-02. Then use "accumulo-02" for the instanceName and for the ZooKeeper. – Mitchell Ingram Mar 19 '13 at 17:13
  • OK, good deal. Just out of curiosity... accumulo-02 is your VMs hostname (as specified in /etc/hostname)? I assume this differs from the VM host's hostname. I'm surprised that didn't resolve without you having to add an entry in /etc/hosts. – Scott Mar 19 '13 at 17:16
  • The VM was named accumulo-02. I don't know why it wasn't resolving. Very odd. – Mitchell Ingram Mar 19 '13 at 19:26

1 Answers1

3

To correctly specify the list of Apache ZooKeeper nodes when connecting to Apache Accumulo with the ZooKeeperInstance, the zooServers should be specified as:

  1. A comma-separated list of host:port that ZooKeeper is already set up and running on, without spaces.
  2. Ensure you are using the client port for ZooKeeper, and not the TServer. (Port 2181 is the default client port for ZooKeeper. Port 9997 is the default client port for TServers.)
  3. If you're running ZooKeeper on the default port (2181), you may omit the :port portion, leaving only a comma-separated list of hosts, or you can combine them if you have some on the non-standard port and some on the standard port, as in "proxyhost,proxyhost:2182,thirdhost:2181".
  4. It shouldn't matter whether you use the IP address or the hostname, so long as whatever you specify can be reached from the client, and the port is open and not blocked by a firewall.

See the JavaDoc comment on the constructor here.

Christopher
  • 2,427
  • 19
  • 24
  • Hey, I think I've specified everything correctly. But still I am unable to find out the problem. Please have a look at my problem here. https://stackoverflow.com/questions/47746720/failed-to-connect-to-zookeeper-within-2x-zookeeper-timeout-period-30000 – Saif Ali Khan Dec 11 '17 at 07:07