Category Archives: Random

This is about stuff that just doesn’t fit anywhere else … basically anything random that I write about :)

Cara konfigurasi MongoDB replicaSet

Quick Intro

So MongoDB has been the main database my team and I have developed our software platform on for the last 5 years. Its easy to learn and so far for us allows for a much faster development process.

We also found that as long as the right processes are put in place for apps that still require some sort of structure within the application, its a really nice DB to use if we still do want some relations between collections.

Now before we get into a spat about RDBMS vs NoSQL , this is just from the experience that I have had bringing my team up with complex software projects and the current technologies they are used to using since they are newer or younger software engineers.

To note, I personally spent a good portion of mys software engineering career using RDBMS’s but as of late I have also pretty much already moved away from RDBMS’s when I can help it and moved into the NoSQL world whole heartedly.

MongoDB Replica Sets

Now this post is not about MongoDB vs NoSQL or any sort of comparision but more about how to configure MongoDB as a replicaSet within a lab setting so that we can understand how it works and play with certain failover situations.

So quickly , what is a MongoDB replica Set configuration. MongoDB replicaset configurations are ways that we can provide a HA setting for our application (with HA meaning High availability).

HA configurations are used when the data needs to reside on many different nodes physically dis-joint and present in various different areas. Replica sets have a configuration where there is a primary node or master node which means the current active node for which read’s and writes to the database are made.

How to do the setup

Jadi sekarang yang penting, cara setup dan konfigurasi MongoDB buat replicaset. Please note, the assumptions are as follows:

  • 3 nodes used for the replicaSet
  • MongoDB 4.2.8 being used (should be OK though for various versions)
  • Operating system is Centos 07
  • Assuming no DNS server to add the actual full DNS names

Step 1) Install MongoDB

  • Install MongoDB. The first step is to install the MongoDB database, as this is a Centos 07 installation we will update the repo to look at the MongoDB repo. To see a full instruction on how to do this we can refer to this document here by MongoDB.
  • But essentially the steps are:
    • create the new repo at : /etc/yum.repos.d/mongodb-org-4.2.repo
    • Add the repo details:
[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
  • Execute the yum install command as follows
    • “yum install -y mongodb-org”

Step 2) Update the host file

  • Update the host files with the actual names of the hostname of the MongoDB servers so that we don’t have to configure them with IP addresses but with hostnames instead.
  • So assuming I have 3 servers I add them into the host file and give it the names

Step 3) Run the MongoDB installation

  • Lets look at how to run up the MongoDB processes. Note: If you are running the MongoDB as a lab setup you can run it as root , but as an installation for production please consider the proper security requirements for your setup to ensure that your database is safe and secure. With that , lets look at the setup.
  • Start the mongod process on each server :

Lets look at the command line parameters:

  • –bind_ip is the ip address that the mongod process will bind to
  • –port is the port that this process will listen on requests from
  • -dbpath is the path where all of the mongo data files will reside
  • –replSet is the name of the replica set

Note that in this case I am running the mongod with nohup , this ensures that mongod runs in the background. Now we repeat this process on each of the different servers which are servers

  • mongodb02.in.sidonesia.com on port 27017
  • mongodb03.in.sidonesia.com on port 27017

Step 4) Configure the replicaSet

  • After the MongoDB mongod processes have been run on each machine the next step is to create and connect all the nodes to create the replica set. The following steps will allow the process to happen

To get on this command line type in : mongo “mongodb://<hostname>:<port>”

  • The next step is to configure the replica set and initiate it , to do that we use the initiate command 🙂 as per below:
  • rs.initiate() # rs = replica set commands
  • After this is complete we add the nodes 2 and 3 into the replica set using the command rs.add(“<node_name>:<node_port>”)
  • The commands look as follows when adding the different nodes, also note, ensure that network connection is available between the nodes and that you an reach the port numbers of each host , you can do this by doing a telnet to the port of the other nodes which should yeild the following output
  • As you can see there is the ^] which means that connection is successful and the host mongodb01 is contactable and the ports are open for communication
  • Next run the replica set add commands so that you add each of the nodes into the cluster as per the commands below
  • As you can see above after adding each node the status of ok is set to 1 and the nodes have been added.
  • On the other machines , inspect the log and you should see output as follows where it shows that the MongoDB instance on the specific node has been added as part of the cluster
  • After the modes have added you can also check the status of the replica set by using the command rs.status(). This will show all the information regarding the replica set including the primary and secondary nodes
  • It will show some overall information and also information on each node stored in a JSON array.
  • This is the final step , now run the mongo client command from a separate machine that has access to the cluster and you should get a prompt.
  • The command is as follows: mongo “mongodb://mongodb01.in.db.sidonesia.com,mongodb02.in.db.sidonesia.com:27017,mongodb03.in.db.sidonesia.com:27017/?replicaSet=rs0”
  • This should get you into a mongo prompt and you can now test the cluster by stopping the nodes and continuing to do work

In summary that is how to get a 3 node cluster up , you can do various tests such as mongorestore a database and see that the data is replicated across all 3 nodes by inspecting the logs.

When doing a mongorestore you only need to send it to the primary node and the replication will occur. In the next post i will write a little about the architecture of the replica set and also show how to test the replica set to ensure that it is working as expected

Hope that helps 🙂

Happy New Years 2013 to 2014 – Bandung Freediving Cabang Jakarta LOL !

WP_20140101_004

Man I am excited for this new year. Scared a little BUT mostly excited cause things are happening. However on the 31st of Dec, there is NO TIME to be scared or think to much about the future there is only time to think about what to do on Dec 31st NYE.

I was sick, had a sore throat, was feeling kinda weak, but I still didn’t wanna stay at home. There were decisions of going to bandung, decisions to stay, to go play pool, nothing was clear. I just surfed the net and drank hot tea and medicine all day to try to get better for the new year and the rest did me well.

I was tired from long hours at work getting the initial design for our product completed and I think it took its toll. Come 7 I called Rafie, where are you broooo. He answers “Downstairs”. I go down and ask him, so what we doing for NYE man … “Dunno” he answers “but I gotta pick up a cake for my mum”.

Then Ajeng whatsapp me. “Gimana Sid jadi keluar ?” Ngak tau nih. Eventually we work out there is no plans and we have the evening free. “OK Jeng jadi kita on the way … siap2”. We drive to where Ajeng is staying for her training and our plan is simple.

Go to a nice place to eat till the new years bell , blow on the horns, greet everyone happy new year and then call it a night. NOPE … this didn’t happen 😉

So we went to noodle house at living world and right outside there was a dance party setting up 😛 The music was pumping, the people were dancing and it looked like fun …

So we ate … and well, the pictures tell the rest of the story 🙂

Was a great night and I forgot that I was sick, I guess now i’m paying for it haha but thats ok. It isn’t to bad and you have to celebrate the coming of the new year.

WP_20140101_008

Have fun everyone and may your new years be everything you hope it to be !

PEACE …

WP_20140101_015

Free Diving … Kinda … Underwater Rugby :P

1482945_10202791806664589_1005649101_n

So in addition to training freediving on sundays at the Bandung Freediving club we have some fun and play different kinds of games. This week Bima introduced us to a game called underwater rugby.  If you have never heard of it then try to guess from the name, yes its pretty much what you expect.

The aim of the game is to place the ball into a basket located on the bottom of the pool. You pass the ball to team mates through the water and tackle the opponent who has the ball (all underwater). This sport requires stamina, requires strength and obviously good water and breath hold skills.

1513246_10202791804664539_270986056_n

I played it for the first time at UPI pools and now im addicted. Its awesome and after 3-4 hours of free diving training where its all about calm, peace and serenity, with long static apnea breath holds, long dynamic  with and without fins you sometimes just get the urge to punch someone and this is the perfect game 😛

944837_10202791805864569_1986664318_n

So in more detail lets describe the equipment. You have 2 buckets which act as the goals, you have a ball that is slightly heavy and negatively buoyant, you have two teams and you have a strategy. The attacking team tries to score on the opposite teams basket while the opposite team defends.

2546_10202791805104550_1160200515_n

Defence is done by tackling the individual  who is holding the ball but the tackling must end the moment that individual drops the ball (so you obviously don’t drown them :P) To break it down those are the rules in a nut shell. What makes this sport so fun however, is that fact that it requires strength, stamina, tactics/strategy, teamwork and lots of underwater skills such as manoeuvrability and breath hold.

1508160_10202791806104575_1586359270_n

You may think that there is a lot in common with free diving but there isn’t all that much .. breath hold skills yes, manoeuvrability within the water yes , but staying calm and peaceful NO ! you have to swim fast, you have to be aggressive and you have to rough people up 😛

At the end of it i had scratches on my sides and some on the side of my face. Had a few bruises too. Next time I play I might just wear a hoodie so that I can prevent scratches on my face from someones long fins digging into my face … but other then that it was a fun and exciting game.

Check out the images of the game (sorry about the water, visibility was horrendous that week)

1524862_682076075170450_1895454524_nThe crew from BFD that week 🙂

Such a time waster …

IMG_0543So I got sick ! Pretty badly too, had this crazy virus combo that took me out for 3 days straight but now it looks like I am back ! I think a combination of to much work, not enough sleep, crazy weather conditions (getting cold then hot then air con), sleeping in the car, working in the car, not eating right and the odd mosquito took its toll on what i thought was my invincible body 😛

I felt really tired 3 days ago, went to the doctors for a checkup only to find out i had the double whammy, dengue fever & typhoid fever both at the same time hahaha ! Typhoid from overwork, not enough rest and not eating right and dengue from some dumbass mosquito. When doctor told me I was like *madddd* …. this cant be good, wonder how im gonna feel in a few days when this nasty combo really kicks in, but to be honest the worst thing about getting sick like this is being bored out of my wits. Sitting in bed, with the drip, SUCH A PAIN IN THE ASS.

Anyway 3 days later and I think im ok now, doctors say it takes on average about 10 days but seems like I have recovered and things are already good now, they better let me go home tomorrow otherwise i’m gonna call my friends and cousins into my hospital room and have a party in here, make lots of noise in my room till they kick my ass out LOL.

Got some work and some diving to do man , cant be sitting in bed wasting time like this 😛

GoPro Silver Edition … My Comparisons

I have been using it for a while but haven’t done a proper post on what I think about it along with my experiences … so here it is.

When I started diving I was using this really cheap (price wise not necessarily the brand because they do have some good cameras on the higher end) intova camera for the last couple of months and it has done pretty well. It’s tough (dropped it many times) and takes some nice shots underwater, it comes with an LCD screen and has all the features that you would need from an underwater camera without needing to purchase addons or anything else. It does the job 🙂 Oh and the connectors are all standard ones so its easy to find really cheap mounts too …

IMG_0420The one major difference that I noticed between the GoPro silver that I bought and the old intova camera is the 170 wide view (as opposed to 140) and that fact that even in murky waters the GoPro still takes really nice pictures. Features aside, cost aside, even in water that is hard to see through the mask, the results from the GoPro are actually really good even I thought I wouldn’t be able to see anything.

There were times when I was taking shots underwater and thinking to myself, “Crap, this is going to be a really bad set of shots” only to be pleasantly surprised to see shots that seem to show everything that even I had difficulty seeing when in the water. The problem with the GoPro is there is no LCD screen so you can’t really check then and there how the pictures have turned out or how the angles are so you just take shots and hope that the camera still works through the murky waters.

When I took the shots in Gordon’s Bay and Tulamben the water was pretty murky, no more then 8m visibility yet the video results were not to bad. I took some shots of a Wobbegong shark in the same visibility from only a few meters away using my Intova camera and you can hardly see the shark, just the slight outline. If I had my GoPro at this time the shot would have been much clearer I would say.

So in terms of quality of picture you can really tell the difference. The one thing that really annoys me is I can not preview my shots ! This should be a pretty basic feature of every camera … I think, even in the old days there was a lens that you could see through to ensure you had the camera pointed in the right direction 😛 The GoPro doesn’t even have that and if you need this feature it is an additional cost, yeah you can use the iPhone/Android App but what about if your underwater ? (I don’t think there are water proof cases for iPhones that go more then 3 or 4 meters)

This is one of the reasons why I still carry the Intova camera with me. I noticed that the Intova camera takes really really nice still pictures on land and since I can preview my pictures before I take them I still use the Intova camera to take pictures on land. However underwater its gotta be the GoPro all the way 🙂 (even if I have to guess that I am pointing the camera at the correct angle and in the right direction)

As for the connectors and the cost for the addons, the only thing I can see my self purchasing would be an additional battery because the battery life sucks on this thing, but I guess with the quality of the images it is taking thats not surprising. All the mounts, I will just try to make myself 😛

Its a great device and definitely a requirement for the avid extreme sports weekend warrior ! Whats also great is their advertisement video, sometimes I play it to get my day started since its so exhilarating and gets me fired up 😛

Check it out above. BTW just noticed the first comment “Almost forgot to watch this today” HAHAHAHA …. LEGEND ….. guess im not the only one that uses this video to get their day started 🙂

Mac Book Recovery ….


IMG_0478

After 4 days of sitting idle and not being used, the macbook has recovered. I don’t know why. I tried it two days later, it didn’t work so I thought it was definitely dead. Then I took it to the apple repair shop and bam ! The geniuses plugged my laptop into the power point, the adapter came on bright (something it hadn’t done for ages) and at that moment, I knew for a split second I was going to look like the biggest dimwit to ever walk into the apple store and complain that their laptop was not booting up 😛 These guys really are geniuses !

Well I didn’t care, dimwit or not, the laptop boots up and I can now get my environment of it and let this work horse lay to rest once and for all (Look at it, its melted, its dead, it needs to rest). So happy. I walked out and asked the apple genius what could have happened and he gave me some spiel about the fact that the power point might hot have had a constant current and the surge protection prevented the power from coming on properly and booting up my laptop.

Yeah … maybe … we are in Indonesia and these things can happen. I also read things online about a state the laptop can get into which is some discharge state where it lays dead for a few hours if you let the battery completely drain but from what I had read it would not do this for a period of days only hours. Could have been anything really and If i was less busy I would try to get to the bottom of this but not right now …

Anyhoo, all is well and now much of the stress that I had is lifted. Code might not work, there might be things failing and all sorts of problems happening but if you can’t fix it cause your tools are not working thats the real time to stress, what do you do when the thing you built is not working, twiddle your thumbs ?! *STRESS*,  Other then that though, everything else and any other problem is fine … she’ll be right as we say in OZ 🙂 It’ll get fixed 😛

Have a good one guys, and jobsy, if your spirit came down to save my laptop i appreciate it … really, after being force to spend so much money just so I can develop on your amazing platform I really really appreciate it 🙂

 

OMG … Farking Macbook :(

IMG_0474

Its freaking comatose, its dead ! This is a freaking disaster. I have my Android coding environment on this thing and hadn’t had a chance to move the environment to my new macbook because I was so busy fixing up and finalising the changes on the iPhone. Code is safe, all in the repo but environment is not, got to set up all that crap and to be honest thats what I hate most about development. Development is fun, really really fun, BUT getting the stuff set up so you can start writing the code and start seeing your creation take life is the worst part of it cause really you just want to get down to the coding.

These instances are the moments when technology gets me really mad. I was hacking away on the new macbook and forgot that the power was plugged into the new one. I fell asleep on the table because I was so tired and it completely drain the power out of the old mac that I have 🙁 Now it doesn’t boot up ?! Is it so bad that the power drained ? If its so bad shouldn’t there be a warning ? Or maybe I missed it. Anyway this really really is the fail.

Lots of people with the same issue (battery drained no more boot) and some had this happen as a result of not so severe contact issues that just needed cleaning, others where magsafe connectors and mobo’s needed to be replaced, but why do these things make themselves obvious only after the battery is drained myst be a link in there somewhere ! I wanna throw this mac book in the bin and then incinerate that bin BUT right now its got my environment for android development and this is important. I just need it to boot up for 20 mins so I can copy the files, replicate the settings and be on my way on the new macbook.

Unbolt the hard disk you say, get the files of ?! I would (I opened the macbook) but the screws on these disks are a weird star shaped design that requires special screw drivers that for the most part no one would have  (unless there was an apple genius or some sort of electrician possibly).

GRRRRRR …. OMG …..

*Takes car to Ratu plaza where apparently this is one place in Indonesia where they have apple geniuses there* ” This better work and better not cost an arm and a leg to fix” ….

Fresh Seafood @ Bali Jimbaran ….

IMG_0092

In sydney I cook most of my own food. I do that because its cheaper and I can make the food exactly as I want and not have any ingredients I don’t.

But what happens if you don’t have to cook the food yourself, BUT you can still tell them exactly how you like it, how you want it cooked and the food is so fresh that it was moving when you chose it ?

Welcome to Jimbaran, Jimbaran is a restaurant in bali which resides on the beach. It’s so “on the beach” that if your un/lucky (depend on how you see it) when the waves come in, they can actually come onto your toes and you can get your feet wet as you eat 🙂 Its a nice place to eat and the food is so delicious and cheap. On the night I ate there I bought the following

IMG_0095

  • 2kg Squid – (Half grilled & Half in salt and pepper flour)
  • 4 x Crabs – (Half in sauce tiram half in black pepper sauce)
  • 2 x Groupers – ( One grilled one fried)
  • 2kg Pipi shells in Bali sauce
  • 2kg Prawns grilled in garlic sauce

This amazing dinner cost me $64 and I was stuffed with good satisfying seafood. I remember going to Jimbaran maybe 10 years ago and it was empty. Not a single person there and only a few people cooking then eating fish caught straight out of the net, now its become very commercialised and $64 is expensive in comparison. But with the new atmosphere (music, nice tables, good drinks) its worth the additional cost because really.. for food this good, whats $64 even for a cheap tight ass like me 😛

So where is Jimbaran ? Everyone now knows where this is but to be more specific its south of Kuta (probably the most famous party place in Bali) and north of Ulawatu so its in between these two well know locations.

Check out the food selection prior to being cooked above…. 😛 and the beach atmosphere below. Awesome isn’t it 🙂

IMG_0100

Dinner for my old man’s Birthday …

IMG_0353

We had dinner out for mothers day, hurricanes so this time it was dinner in for my old mans birthday. I went and bought some rib eye meat, 2kg roll and bought some fish.

I made a ginger and shallots with garlic sauce for the fish which was cooked over a steamer. I roasted the rib eye and once it was roasted I took some of the juices that had been exposed during the cooking process and turned that into a pepper gravy.

There was also some squid so I got the pan griller out and grilled the squid, then stirred through a mildly sweet sauce that I made from a few ingredients,  through the squid for some extra flavour.

Made some garlic vegetables and fried some Lebanese bread. Made a garlic sauce with some mushrooms and olive oil to dip the fried Lebanese bread in as a starter. We had 7 people there all up and it was a nice dinner for everyone.

Sister bought a cheese cake so finished of the meal with a cheese cake 🙂

Dinner After the harvest …

IMG_0344

So, to me going shopping at Flemington was the gathering and harvesting of the food. Had to make heaps of room in the fridge and shift a lot of the food so I could get the veggies that needed to be refrigerated inside.

IMG_0348After some shifting and moving it was time to cook. Because I had so much veggies and meat to play with I didn’t have to go sparingly on the food. I also made lots of food because I had my cousin coming over with her husband.

I decided to make beans with chilli’s, mushroom, onions, parsley and garlic. I also wanted to eat the squash so I went ahead and steamed some of the squash. I made a garlic sauce and simmered it over some light heat. When the squash was nicely steamed I put the garlic sauce over the squash so that the flavour of the sauce and the taste of the squash would combine nicely. I usually do this instead of cook them together to get a  stronger flavour from the veggies and the sauce.

I then made the steak, all medium and made a chilli and garlic sauce to put on once the steak was done. I had some scallops in the fridge so I poured boiling water over them and added some salt. I kept repeating the process as the water got cold until I felt IMG_0346the scollops where tender and warm on the inside but not over cooked.

I made a ginger, garlic and shallots sauce combined with sesame oil and soy sauce, mixed them together and heated the sauce slightly. Once the shallots were soft I poured it over the scollops.

Time to cook was about 30 mins all up …