Is ZooKeeper mandatory for Cloud
We aggregate and tag open source projects. We have collections of more than one million projects. Check out the projects section.
Cloud is nothing but more than one system or application distributed across the network, across the globe. It may have couple of application servers, database server, shared data storage, backup server and lot more. The resources in the distributed environment must have information about each other so that they could co-ordinate and share without any issues. ZooKeeper helps to do that.
ZooKeeper is basically a coordinating service. It has information about all the resources. The name space provided by ZooKeeper is much like that of a standard file system. A name is a sequence of path elements separated by a slash (/). A watcher could be created on any node and whenever any changes happens to the node its subscribers are notified. It has support for barriers and distributed queue. ACL could be applied to each node to control its access.
Download and unpack ZooKeeper. Create a config file named zoo.cfg under conf folder with below contents and start the ZooKeeper server.
To start the server, type the below command in command prompt.
ZooKeeper server could be accessed using its API. It has CLI support, which is capable of executing some basic commands. In this article we will access the server using CLI.
To start the CLI, type the below command in command prompt.
Consider in a cloud there are three database servers and one shared data storage. More than one application is running in the cloud and they need to know which database to connect.
CMD> bin\zkCli -server 127.0.0.1:2181
Type the below commands and add the database nodes using CLI.
Now the application wants to access the database IP address. It may do using API but i will explain using CLI as it will be easy to understand.
CMD> create /dbserver Database server
CMD> create /dbserver/dbserver1 192.168.144.100
CMD> create /dbserver/dbserver2 192.168.144.101
CMD> create /dbserver/dbserver3 192.168.144.102
Type the below commands in CLI.
If server is failed to get access the application will try to connect to server2. This is just an example.
CMD> ls /dbserver
[dbserver1, dbserver2, dbserver3]
CMD> get /dbserver/dbserver1
Applications and Resources in the cloud need to access the ZooKeeper to get the information at runtime. An existing database is moved to different IP then this change has to be reflected in all applications in the cloud. If all of them maintain their own settings (XML store) of the resources then it would difficult to change. With ZooKeeper it will be easier as application picks it as and when need. If any application created a watcher on the database node then it will be notified the changes so that it could handle it in better way.