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...
To correctly specify the list of Apache ZooKeeper nodes when connecting to Apache Accumulo with the ZooKeeperInstance, the zooServers should be specified as:
- A comma-separated list of host:port that ZooKeeper is already set up and running on, without spaces.
- 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.)
- 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".
- 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.
来源:https://stackoverflow.com/questions/15505166/connecting-an-external-accumulo-instance-and-java