You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by judesolomonc <ju...@fss.co.in> on 2013/08/29 08:46:13 UTC

Zoo Keeper - The Beginning

Hi

I am trying to use zookeeper, theoretically i can understand the
functionality of this frame work. But when it comes to the implementation
part, I am not aware of where to start and how to start. Please confirm on
my understandings or correct me if I am wrong.

Client port - It is the port where the client sends request to the zookeeper
server
server.1=10.44.71.52:4567:4587 - the server in the zookeeper cluster 4567 -
port where the zookeeper communicates when the request is sent, 4587 - the
port where the clustered servers communicates.

This configured server should be an instance of a zookeeper (Built on
zookeeper) ? or it can be any server using NIO listening on the mentioned
port ?

I have started up a zoo keeper server in two ways 

1.

NIOServerCnxn.Factory standaloneServerFactory = new
NIOServerCnxn.Factory(new InetSocketAddress(clientPort), numConnections);

		standaloneServerFactory.startup(server);

2. using QuorumPeer class

is this the correct way to start a server ? And how to receive a request
sent from the client ? As the connection is created inside the zookeeper,
how to read/see the data sent form the client in the server ?

Can someone help me with a Java code to create a zookeeper service, and
servers and to receive the request from the client and print it in the
server ?

And also for the distributed servers to handle the failover conditions ?

Thanks
Jude Solomon




--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/Zoo-Keeper-The-Beginning-tp7579030.html
Sent from the zookeeper-user mailing list archive at Nabble.com.

Re: Zoo Keeper - The Beginning

Posted by judesolomonc <ju...@fss.co.in>.
Thanks a lot Diego.

Jude Solomon



--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/Zoo-Keeper-The-Beginning-tp7579030p7579040.html
Sent from the zookeeper-user mailing list archive at Nabble.com.

Re: Zoo Keeper - The Beginning

Posted by Diego Oliveira <lo...@gmail.com>.
Jude,

   The configuration is quite right, but I see that you are trying to run a
cluster in only one computer, not in various computers (it is desirable in
production). If you would like to do so for development purpose, I
recommend you to copy the zookeeper download in tree folders, one called
zk1, zk2, zk3. All tree must have the same entry for server.*, but with
different clientPort and dataDir values. Something like:

zk1
----------------------
dataDir=/opt/data/zk1
clientPort=2181
server.2=10.44.71.52:4568:4587
server.3=10.44.71.52:4569:4588
server.1=10.44.71.52:4567:4589

zk2
----------------------
dataDir=/opt/data/zk2
clientPort=2182
server.2=10.44.71.52:4568:4587
server.3=10.44.71.52:4569:4588
server.1=10.44.71.52:4567:4589

zk3
----------------------
dataDir=/opt/data/zk3
clientPort=2183
server.2=10.44.71.52:4568:4587
server.3=10.44.71.52:4569:4588
server.1=10.44.71.52:4567:4589

Then go and start each of the server. Now the client connection string
would be "10.44.71.52:2181,10.44.71.52:2182,10.44.71.52:2183".



On Tue, Sep 3, 2013 at 3:19 AM, judesolomonc <ju...@fss.co.in> wrote:

> Diego,
>
> Thanks for the response. In case of distributed servers, the servers
> configured in the configuration file represents a zookeeper server ?
> Consider, I am configuring 3 servers
>
> clientPort=2181
> server.2=10.44.71.52:4568:4587
> server.3=10.44.71.52:4569:4587
> server.1=10.44.71.52:4567:4587
>
> All These servers should be like zkserver which you mentioned in your
> previous post ? In that case, how to up a server in clustering mode ? The
> client should still connect to the 2181 port ? what port does 4568,4569 and
> 4567 represent ? There should be a different programs running on these
> ports
> ? or the same zookeeper server but a different instance ?
>
> Jude Solomon
>
>
>
> --
> View this message in context:
> http://zookeeper-user.578899.n2.nabble.com/Zoo-Keeper-The-Beginning-tp7579030p7579038.html
> Sent from the zookeeper-user mailing list archive at Nabble.com.
>



-- 
Att.
Diego de Oliveira
System Architect
diego@diegooliveira.com
www.diegooliveira.com
Never argue with a fool -- people might not be able to tell the difference

Re: Zoo Keeper - The Beginning

Posted by judesolomonc <ju...@fss.co.in>.
Diego,

Thanks for the response. In case of distributed servers, the servers
configured in the configuration file represents a zookeeper server ?
Consider, I am configuring 3 servers

clientPort=2181
server.2=10.44.71.52:4568:4587
server.3=10.44.71.52:4569:4587
server.1=10.44.71.52:4567:4587

All These servers should be like zkserver which you mentioned in your
previous post ? In that case, how to up a server in clustering mode ? The
client should still connect to the 2181 port ? what port does 4568,4569 and
4567 represent ? There should be a different programs running on these ports
? or the same zookeeper server but a different instance ?

Jude Solomon



--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/Zoo-Keeper-The-Beginning-tp7579030p7579038.html
Sent from the zookeeper-user mailing list archive at Nabble.com.

Re: Zoo Keeper - The Beginning

Posted by Diego Oliveira <lo...@gmail.com>.
Jude,

    You will not code in the server. Think in the zookeeper as file
systems, you use it to make your services communicate.


   1. Start the Zookeeper server. Open a terminal, go to the folder you
   downloaded Zookeeper, then execute ./bin/zkServer.sh start-foreground,
   it will start Zookeeper and print the log in the console.
   2. Create a java class as described in http://pastebin.com/Csd4UHqr
   3. Add the zookeeper.jar that is in your class path, compile and run the
   program. It will list the zookeeper content.


It is possible to do a lot more using
watchers<http://zookeeper.apache.org/doc/trunk/javaExample.html>,
take a look in the recipes<http://zookeeper.apache.org/doc/trunk/recipes.html>,
or use a framework like Curator <http://curator.incubator.apache.org/>.







On Mon, Sep 2, 2013 at 6:30 AM, judesolomonc <ju...@fss.co.in> wrote:

> Diego
>
> We are planning to use zookeeper for a server fail over condition. Which
> means when a server is down, the client should be able to connect and send
> request to an alternate configured. When going through the documentation,
> we
> found that zoo keeper helps in achieving this scenario. But we are not able
> to proceed with the setting up of server. When we start the server using
> the
> NIO connection factory given in the Zoo Keeper, the socket connection is
> created by the Zoo Keeper itself using the Client port. And once the server
> is up, how to use a client to communicate to the server with that port ?
> And
> in the server, how to read the request sent b the client ? Is there any
> exposed methods to get the data from the external client ? As far I have
> checked, the object used to create the connection is not exposed. So I am
> not able to use that object to receive the data from the client. Can you
> suggest me how to proceed for the above mentioned scenario ?
>
> Jude Solomon
>
>
>
> --
> View this message in context:
> http://zookeeper-user.578899.n2.nabble.com/Zoo-Keeper-The-Beginning-tp7579030p7579036.html
> Sent from the zookeeper-user mailing list archive at Nabble.com.
>



-- 
Att.
Diego de Oliveira
System Architect
diego@diegooliveira.com
www.diegooliveira.com
Never argue with a fool -- people might not be able to tell the difference

Re: Zoo Keeper - The Beginning

Posted by judesolomonc <ju...@fss.co.in>.
Diego

We are planning to use zookeeper for a server fail over condition. Which
means when a server is down, the client should be able to connect and send
request to an alternate configured. When going through the documentation, we
found that zoo keeper helps in achieving this scenario. But we are not able
to proceed with the setting up of server. When we start the server using the
NIO connection factory given in the Zoo Keeper, the socket connection is
created by the Zoo Keeper itself using the Client port. And once the server
is up, how to use a client to communicate to the server with that port ? And
in the server, how to read the request sent b the client ? Is there any
exposed methods to get the data from the external client ? As far I have
checked, the object used to create the connection is not exposed. So I am
not able to use that object to receive the data from the client. Can you
suggest me how to proceed for the above mentioned scenario ?

Jude Solomon



--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/Zoo-Keeper-The-Beginning-tp7579030p7579036.html
Sent from the zookeeper-user mailing list archive at Nabble.com.

Re: Zoo Keeper - The Beginning

Posted by Diego Oliveira <lo...@gmail.com>.
Jude,

    May be you are misunderstanding the way Zookeeper works. It is
basically a remote file system with a lot of guaranties regarding
distributed operations in the files and folders, aka znodes. So, like you
would normally do in a file system, you just turn it on and use. There is
an executable you may start "/bin/zkServer.sh start-foreground".

   From the client side you may create and observe znodes. I have a simple
demo project that I use here in Brazil, for training and conferences, it's
variables and classes are in Portuguese but you may take o look. Also there
is some code sample in the code tree, in src/recipes/.

Att,
Diego


On Thu, Aug 29, 2013 at 3:46 AM, judesolomonc <ju...@fss.co.in>wrote:

> Hi
>
> I am trying to use zookeeper, theoretically i can understand the
> functionality of this frame work. But when it comes to the implementation
> part, I am not aware of where to start and how to start. Please confirm on
> my understandings or correct me if I am wrong.
>
> Client port - It is the port where the client sends request to the
> zookeeper
> server
> server.1=10.44.71.52:4567:4587 - the server in the zookeeper cluster 4567
> -
> port where the zookeeper communicates when the request is sent, 4587 - the
> port where the clustered servers communicates.
>
> This configured server should be an instance of a zookeeper (Built on
> zookeeper) ? or it can be any server using NIO listening on the mentioned
> port ?
>
> I have started up a zoo keeper server in two ways
>
> 1.
>
> NIOServerCnxn.Factory standaloneServerFactory = new
> NIOServerCnxn.Factory(new InetSocketAddress(clientPort), numConnections);
>
>                 standaloneServerFactory.startup(server);
>
> 2. using QuorumPeer class
>
> is this the correct way to start a server ? And how to receive a request
> sent from the client ? As the connection is created inside the zookeeper,
> how to read/see the data sent form the client in the server ?
>
> Can someone help me with a Java code to create a zookeeper service, and
> servers and to receive the request from the client and print it in the
> server ?
>
> And also for the distributed servers to handle the failover conditions ?
>
> Thanks
> Jude Solomon
>
>
>
>
> --
> View this message in context:
> http://zookeeper-user.578899.n2.nabble.com/Zoo-Keeper-The-Beginning-tp7579030.html
> Sent from the zookeeper-user mailing list archive at Nabble.com.
>



-- 
Att.
Diego de Oliveira
System Architect
diego@diegooliveira.com
www.diegooliveira.com
Never argue with a fool -- people might not be able to tell the difference