How to setup and run multiple zookeeper instances on one box

In layman terms, Zookeeper is a highly available configuration management system meant for distributed systems. Distributed systems solve a lot of problems but then they present their own challenges. What happens when a node in a cluster is not able to serve due to any reason? And what if that node was leader? Zookeeper helps in such situations. Zookeeper keeps track of all the available nodes and knows what lies where. In case a leader is down it will quickly help in electing another leader. The purpose of this post is to explain how to run multiple Zookeeper instances on a single node/machine. Such a setup is also known as Zookeper ensemble. Running multiple instances on a single node means single point of failure, so this is not advisable at all. You can have 3 nodes running 7 instances,  1 small node with one instance and two bit bigger nodes with 3 instances each. One would do to cut costs.

Let’s get into action.

Get the latest release from, untar and keep the folder at one location, say /home/luser/zookeeper/.

I will be setting up this on a Debian machine named deb and inside /opt directory.

Now the most tough part(?)…configuring Zookeeper. Look for zoo.cfg file inside configuration folder named conf. Open the file in your favorite text editor and you need to configure bare minimum 3 items

  1. dataDir
  2. clientPort
  3. server.n where n is the server/instance number

There are other items which you may want to tweak based on your usage. In my case following was the pattern for 3 Zookeepers on one node

For Zookeeper 1

For Zookeeper 2

For Zookeeper 3

In case I was setting up these three on different nodes, the pattern would have been copy of each other.

For Zookeeper individual node

The last thing to pay attention to is, the myid file. This file goes inside dataDir. So for my nth Zookeeper on single node it would have been inside /var/zookeeper/data-n/myid. This file holds the server/instance number, so for nth instance the content of the file would have been value of n. So the myid file for 3 instance will contain number 3. In case of multiple nodes, myid file on node-n will have value n.

Now that config part is bit clear, there are two ways to start Zookeeper instances. I changed the zoo.cfg file for first instance and then copied the Zookeeper folder from home to /opt/zookeeper-1/ and followed this for other two instance. Then inside bin dir I just did start. You can completely avoid this and create three zoo.cfg files using pattern zoo-n.cfg and then just cd inside bin dir and run start zoo-n.cfg command to start servers. Once you have started servers you can verify the setup by connecting to individual server. For my first server I cd inside bin dir and run -server For 2nd node this command was -server and so on for 3rd. In case I had set up one node per instance, the command would have been -server node-ip-or-node-host-name:2181.

And that’s it. Your Zookeeper ensemble is up and running!

Fix “Error mounting: mount exited with exit code 13: $MFTMirr does not match $MFT (record 0).”

I was moving around 200+GB data from one WD external drive to another. Although the drives were connected to USB3 port the process was taking time. And I felt asleep and shutdown the system. Next day I connect hard drive and I see

Error mounting: mount exited with exit code 13: $MFTMirr does not match $MFT (record 0).

“Wut!” The complete text said.

Failed to mount ‘/dev/sdc1?: Input/output error NTFS is either inconsistent, or there is a hardware fault, or it’s a SoftRAID/FakeRAID hardware. In the first case run chkdsk /f on Windows then reboot into Windows twice. The usage of the /f parameter is very important! If the device is a SoftRAID/FakeRAID then first activate it and mount a different device under the /dev/mapper/ directory, (e.g. /dev/mapper/media_eahaabcc1). Please see the ‘dmraid’ documentationfor more details.

OK. But my Windows XP Centrino laptop will take ages to bootk and I do have “ntfs-3g” installed. May be it can fix this problem. And I could see these

ntfs-3g           ntfs-3g.secaudit  ntfscat           ntfscluster       ntfsdecrypt       ntfsfix           ntfsls            ntfsmove          ntfswipe          
ntfs-3g.probe     ntfs-3g.usermap   ntfsck            ntfscmp           ntfsdump_logfile  ntfsinfo          ntfsmftalloc      ntfstruncate

And we have ntfsfix utility!

sudo ntfsfix /dev/sdc1

Look for the success message and done!

How to cross post status update from Google+ to Facebook?

Though I signed up on most of the popular social platforms I am addicted to Facebook more than anything. But most of my Google Fan Boi friends are now newly launched FB clone Google+ fans. So they end up posting “things” on G+. Well, I have found a solution to cross post the thing, NOT THE COMMENTS, from Google+ to FB. There are some limitations on what all you can share. Here is how to do it.

  • Log on to Facebook and then go to
  • Locate the section “Upload via Email”, in this section you will see, what FB calls, a personal email address. Note that this is not your email address.
  • Note down the address, copy paste it somewhere or keep the page opened.
  • Sign into Google+
  • Go to “Circles”.
  • Create a circle and name it.
  • In this circle add, “Add a new person” and use your personal email address which facebook has given you.
  • Name the this contact.
  • Save the circle.
  • Now go to “Stream” page
  • Try to share some “thing”.
  • Before you hit “Share” button, click on Add circles or people to share with and choose the Circle that has your personal Facebook email.
  • Share the “thing”
  • Check your Facebook newsfeed. Voila!!!

I request all my G+ friends to please share things with Facebook till the time I have all my friends on G+. Moreover I find G+ very strange, people I dont know have added me into their circles. And I tried to follow some celebrities but they simple spam my “Stream”. Even if I comment my comment is lost in 200+ other comments.