Friday, December 27, 2013

How to remove old lock file terminating mongodb

dileep@dileep-VirtualBox:~$ sudo mongod --dbpath /var/lib/mongodb/
Sat Dec 28 01:36:55.801
Sat Dec 28 01:36:55.803 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Sat Dec 28 01:36:55.804
Sat Dec 28 01:36:55.933 [initandlisten] MongoDB starting : pid=2656 port=27017 dbpath=/var/lib/mongodb/ 32-bit host=dileep-VirtualBox
Sat Dec 28 01:36:55.936 [initandlisten]
Sat Dec 28 01:36:55.937 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
Sat Dec 28 01:36:55.937 [initandlisten] **       32 bit builds are limited to less than 2GB of data (or less with --journal).
Sat Dec 28 01:36:55.938 [initandlisten] **       Note that journaling defaults to off for 32 bit and is currently off.
Sat Dec 28 01:36:55.939 [initandlisten] **       See http://dochub.mongodb.org/core/32bit
Sat Dec 28 01:36:55.939 [initandlisten]
Sat Dec 28 01:36:55.940 [initandlisten] db version v2.4.8
Sat Dec 28 01:36:55.941 [initandlisten] git version: a350fc38922fbda2cec8d5dd842237b904eafc14
Sat Dec 28 01:36:55.941 [initandlisten] build info: Linux bs-linux32.10gen.cc 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_49
Sat Dec 28 01:36:55.942 [initandlisten] allocator: system
Sat Dec 28 01:36:55.942 [initandlisten] options: { dbpath: "/var/lib/mongodb/" }
**************
Unclean shutdown detected.
Please visit http://dochub.mongodb.org/core/repair for recovery instructions.
*************
Sat Dec 28 01:36:55.951 [initandlisten] exception in initAndListen: 12596 old lock file, terminating
Sat Dec 28 01:36:55.952 dbexit:
Sat Dec 28 01:36:55.952 [initandlisten] shutdown: going to close listening sockets...
Sat Dec 28 01:36:55.953 [initandlisten] shutdown: going to flush diaglog...
Sat Dec 28 01:36:55.955 [initandlisten] shutdown: going to close sockets...
Sat Dec 28 01:36:55.956 [initandlisten] shutdown: waiting for fs preallocator...
Sat Dec 28 01:36:55.957 [initandlisten] shutdown: closing all files...
Sat Dec 28 01:36:55.959 [initandlisten] closeAllFiles() finished
Sat Dec 28 01:36:55.959 dbexit: really exiting now

To remove the Error we only do ,

dileep@dileep-VirtualBox:/$ cd var/lib/mongodb
dileep@dileep-VirtualBox:/var/lib/mongodb$ sudo rm mongod.lock
dileep@dileep-VirtualBox:/var/lib/mongodb$ ls
local.0  local.ns  _tmp

Then have to put the mongod --repair comand for repairing the mongodb. or else try to do the

 sudo mongod --dbpath /var/lib/mongodb/      command in the terminal.

Then the mongodb will work again.




Thursday, December 26, 2013

HTTPS server (SSL) Implementation in node.js

Node.js provides HTTP server as one of the core libraries. So there is no need for a separate HTTP server. But if you are developing any application in node js which needs secure transactions then HTTPS server is necessary for it. So it can allow private information to be transmitted without the problems of eavesdropping, data tampering, or message forgery between your node.js  server and your visitor’s browser.
Developer should add SSL certificate in code to implement HTTPS server in node.js. In my last post I have explained, how to create self-signed SSL certificate in Ubuntu. It has commands and detail explanation for generating self-signed SSL in any Unix OS.  So for testing purpose you do not need to buy SSL certificate.
You can implement HTTPS server using simple steps:
Prerequisites:
  • node.js
Before start to implement HTTPS server please make sure that you have installed node.js in your system.
Commands to Create self-signed SSL certificate 
If you need a detail explanation and process, you can get it here. Following are commands to generate self-signed SSL in any Unix OS :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Become root first

$ apt-get install openssl

$ mkdir /etc/ssl/self-signed && cd /etc/ssl/self-signed

$ openssl genrsa -des3 -out server.key 2048

$ openssl rsa -in server.key -out server.key.insecure

$ mv server.key server.key.secure && mv server.key.insecure server.key

$ openssl req -new -key server.key -out server.csr

$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Above commands will generate two files server.key(private key to SSL certificate) and server.crt(signed certificate) in /etc/ssl/self-signed folder.
Node.js Code to implement HTTPS server
Now create a file server.js in your system. And add following code in it :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//Include the https and ,file system modules
var https = require('https');
var fs = require('fs');

//Create the server options object, specifying the SSL key & cert
var options = {
key: fs.readFileSync('/etc/ssl/self-signed/server.key'),
cert: fs.readFileSync('/etc/ssl/self-signed/server.crt')
};

//Create the HTTPS enabled server - listening on port 443
https.createServer(options, function (req, res) {
res.writeHead(200);
res.end("hello world\n");
}).listen(443);
Code Explanation :
Following is line by line explanation of above code:
1
2
var https = require('https');
var fs = require('fs');
In above two lines we are adding HTTPS and FS modules which are required for SSL implementation. After including require modules we need to add SSL files (key and cert files) path. We have already generated self-signed SSL and its files are stored in /etc/ssl/self-signed folder.
1
2
3
4
var options = {
key: fs.readFileSync('/etc/ssl/self-signed/server.key'),
cert: fs.readFileSync('/etc/ssl/self-signed/server.crt')
};
In above code we are adding server.key and server.crt files path in options array variable. Now we need to create HTTPS server and pass this files through options variable to it.
1
2
3
4
https.createServer(options, function (req, res) {
res.writeHead(200);
res.end("hello world\n");
}).listen(443);
In above code lines, we have created HTTPS server by using createServer method. In it we have passed options variable as a parameter which contains SSL files path. And this server is listening on port no 443 which is a HTTPS port.
If you buy authenticated SSL certificate from any trusted service provider then you will get .key and .crt files. Just save this files in your system and replace self-signed SSL files path with this new authenticated files in above code.
Now open terminal and goto path where you have saved server.js file in your system. And run following command:
1
node server.js
Now open your favourite browser and enter https://localhost in address bar and press enter key. You will get hello world text in browser. That means you have successfully implemented HTTPS server in node.js. Please note that if you are using any other port than 443 then please mention that port number in url. For example, if you are using port number 8443 then enter https://localhost: 8443 url in browser.


Monday, December 23, 2013

Create self-signed SSL certificate in UbuntuinShare
What is SSL Certificate?
SSL is an acronym for Secure Sockets Layer. SSL Certificates are small data files that digitally bind a cryptographic key to an organisation’s details. It creates an encrypted connection between your web server and your visitor’s browser, allowing for private information to be transmitted without the problems of eavesdropping, data tampering, or message forgery. When SSL gets install on web server,  it activates the padlock and the https protocol (over port 443).
What is Self-signed SSL Certificate?
Organisation needs to buy SSL certificate from trusted hosting companies and its prices are very high. So, for development and testing purpose organisation can use self-signed SSL certificates. This self-signed SSL are certificates which get locally create on web server where it needs for testing of new SSL implementation. It is an identity certificate signed by its own creator; however, they are considered to be less trustworthy.
This temporary certificate generates an error in the client browser to the effect that the signing certificate authority is unknown and not trusted because it’s not signed by any known trusted CA authority.
SSL Certificate Files:
SSL certificate needs .key and .crt files. This files represent both parts of a certificate, .key is a private and .crt is a public part of certificate that means key being the private key to the certificate and crt being the signed certificate.
How to create Self-Signed SSL certificate in Ubuntu?
The openssl library is required to generate self-signed SSL certificate in Ubuntu. Open terminal and become root first . Now check if you already have openssl installed. Use following command for it:
1
$ which openssl
If above command returns path like /usr/bin/openssl , that means your system has openssl. But if it does not return any path then you will need to install openssl yourself. Use following command to install openssl:
1
$ apt-get install openssl
After installing openssl, private key (.key file) and signed certificate (.crt file) is required for SSL certificate. We need to store .key and .crt files in a single folder.
1
$ mkdir /etc/ssl/self-signed && cd /etc/ssl/self-signed
Above commands create self-signed folder on /etc/ssl path. Following are simple four steps which will guide you to create self-signed SSL certificate for your web server.
Step 1 :  Create a Private Key
The first step is to create your RSA Private Key. This key will be 1024 bit RSA key which will be encrypted using Triple-DES and will be store in a PEM format so that it will be readable as ASCII text. Command to create RSA key:
1
$ openssl genrsa -des3 -out server.key 1024
Edited:
Due to the increasing computing power available to decrypt SSL certificates, the Certificate Authority Browser (CAB) Forum (the entity that establishes SSL industry standards) requires that all SSL certificates issued after Jan. 1, 2014, use at least 2048-bit keys. SSL certificates that use 1024-bit keys are no longer secure. Command to create 2048 bit RSA key:
1
$ openssl genrsa -des3 -out server.key 2048
Step 2 : Remove pass-phrase from key
One side-effect of private key is that, Apache always ask for pass-phrase when web server gets start. But we can remove this pass-phrase restriction using following command:
1
$ openssl rsa -in server.key -out server.key.insecure
Now rename files:
1
$ mv server.key server.key.secure && mv server.key.insecure server.key
Step 3 : Generate a CSR (Certificate Signing Request)
Once private key is generated and pass-phrase restriction is removed, you should generate certificate signing request(CSR). During CSR generation, you will get prompted for different information which are the certificates attribute. Please note when you will get prompt for “Common Name”, you should enter complete name of your domain. For example if request is getting generate for shivalibari.com then please enter shivalibari.com as a common name. So this domain name will get protected with SSL like : https://shivalibari.com. Use following command for CSR generation:
1
$ openssl req -new -key server.key -out server.csr
Step 4 : Generate Self-Signed SSL Certificate
Use following command to generate self-signed certificate:
1
$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
This certificate can get use for 365 days.
Using above simple four steps you can successfully create self-signed SSL certificate. You can use the filesserver.key and server.crt which are located in /etc/ssl/self-signed into your code or in any programming language to implement SSL or HTTPS connection with your web application.


Monday, November 18, 2013

Principle : 82


If you follow these principles, you will succeed on many levels, engendering an atmosphere of trust and loyalty.  Working in such an atmosphere, the group will feel secure at a basic level that is very necessary. Insecurity creates massive stress and all the problems that attend it.

But we have to be realistic, too. Today more than ever, it takes consciousness to keep on the responsible track. For many in business, responsibility has become an old-fashioned value to be shrugged off in favour of profitability.  The financial crash of 2008 was engineered through a flagrant lack of responsibility, combined with risk-taking far out of bounds with sensible practice. Yet the lesson that the financial sector took away was the opposite of responsible. With record profits and huge bonuses in the offing, they went back to a slightly modified version of their worst practices.

Wednesday, July 10, 2013

Principle 81 :

Feel Your Fear and Do It Anyway
Every successful person I know has been willing to take a leap of faith even though they were afraid. They knew that if they didn’t act, opportunity would pass them by.
Recognize fear for what it is: a mental trick that your ego uses in attempt to protect you from the negative outcomes it imagines. You create your fear and you have the power to dissolve it as well. Use the techniques outlined in this article to overcome this powerful roadblock … so you can turn your dreams into reality and live the life you deserve. Remember, no one achieves greatness by playing it safe.

Wednesday, July 3, 2013

Principle 80 :

3 Ways to Overcome Fear
Here are three easy techniques for moving past your fears:
1.    Disappear fear by choosing a positive mental image. When we’re afraid, our minds are full of negative thoughts and images. When you are feeling afraid, tune into the images in your head. Then choose to replace them with a positive image of your desired outcome. For example, if you’re afraid that starting your own business will end in bankruptcy and losing your house, instead picture your new business becoming wildly successful and buying a second vacation home with all of the added income you’ll be earning in your new company.

2.    Focus on the physical sensations. You may feel fear in your body as a sinking feeling in your stomach, a tightening in your shoulders and chest, or an elevated heart rate. Next, focus on the feelings you’d rather be experiencing instead, such as peace and joy. Fix these two different impressions in your mind’s eye, then move back and forth between the two, spending 15 seconds or so in each. After a minute or two, you’ll find yourself feeling neutral and centered.
3.    Recall your successes. You’ve overcome countless fears to become the person you are today, whether it was learning to ride a bike, driving a car for the first time, or kissing someone for the first time. New experiences always feel a little scary. But when you face your fears and do them anyway, you build up confidence in your abilities. The situation you’re facing now and how your fear is manifesting may be different than what you’ve experienced in the past, but you know how to overcome your fears. You’ve spent a lifetime doing so successfully.

Monday, July 1, 2013

Principle 79 :

Identify Unfounded Fears
To identify the unfounded fears in your life, do this simple exercise. First, make a list of the things you are afraid to do. These are not things you are afraid of, such as spiders, but instead the things you are afraid do to, such as skydiving.
Next, restate each fear in the following format:
I want to_______________, and I scare myself by imagining ____________________.
For example, I want to start my own business, and I scare myself by imagining that I would go bankrupt and lose my house.
By completing this statement for all of the things we are afraid to do, it’s easy to see how we create our own fear by imagining negative outcomes in the future.

Friday, June 28, 2013

Principle 78 :

Overcoming Fear in All Its Disguises

Fear is one of most common reasons people procrastinate on taking action toward their goals. In an effort to avoid failure, rejection, being embarrassed, disappointing or angering other people, getting hurt and a plethora of other things, we play it safe and avoid trying new things.

Fear is natural. But it’s important to remember that, as humans, we’ve evolved to the stage where almost all of our fears are now self-created. We scare ourselves by imagining negative outcomes to any activities we pursue or experience. In fact, psychologists like to say that fear means Fantasized Experiences Appearing Real.
Jack

Thursday, June 27, 2013

Principle 76 :

Create Goal Pictures:
Another powerful technique is to create a photograph or picture of yourself with your goal, as if it were already completed. If one of your goals is to own a new car, take your camera down to your local auto dealer and have a picture taken of yourself sitting behind the wheel of your dream car. If your goal is to visit Paris, find a picture or poster of the Eiffel Tower and cut out a picture of yourself and place it into the picture.

Create a Visual Picture and an Affirmation for Each Goal:
We recommend that you find or create a picture of every aspect of your dream life. Create a picture or a visual representation for every goal you have — financial, career, recreation, new skills and abilities, things you want to purchase, and so on.

Index Cards:
We practice a similar discipline every day. We each have a list of about 30-40 goals we are currently working on. We write each goal on a 3x5 index card and keep those cards near our bed and take them with us when we travel. Each morning and each night we go through the stack of cards, one at a time, read the card, close our eyes, see the completion of that goal in its perfect desired state for about 15 seconds, open our eyes and repeat the process with the next card.

Use Affirmations to Support Your Visualization:
An affirmation is a statement that evokes not only a picture, but the experience of already having what you want. Here’s an example of an affirmation:
I am happily vacationing 2 months out of the year in a tropical paradise, and working just four days a week owning my own business.
Repeating an affirmation several times a day keeps you focused on your goal, strengthens your motivation, and programs your subconscious by sending an order to your crew to do whatever it takes to make that goal happen.

Wednesday, June 26, 2013

Principle 75 :

Go through the following three steps:
STEP 1. Imagine sitting in a movie theater, the lights dim, and then the movie starts. It is a movie of you doing perfectly whatever it is that you want to do better. See as much detail as you can create, including your clothing, the expression on your face, small body movements, the environment and any other people that might be around. Add in any sounds you would be hearing — traffic, music, other people talking, cheering. And finally, recreate in your body any feelings you think you would be experiencing as you engage in this activity.
STEP 2. Get out of your chair, walk up to the screen, open a door in the screen and enter into the movie. Now experience the whole thing again from inside of yourself, looking out through your eyes. This is called an “embodied image” rather than a “distant image.” It will deepen the impact of the experience. Again, see everything in vivid detail, hear the sounds you would hear, and feel the feelings you would feel.
STEP 3. Finally, walk back out of the screen that is still showing the picture of you performing perfectly, return to your seat in the theater, reach out and grab the screen and shrink it down to the size of a cracker. Then, bring this miniature screen up to your mouth, chew it up and swallow it. Imagine that each tiny piece — just like a hologram — contains the full picture of you performing well. Imagine all these little screens traveling down into your stomach and out through the bloodstream into every cell of your body. Then imagine that every cell of your body is lit up with a movie of you performing perfectly. It’s like one of those appliance store windows where 50 televisions are all tuned to the same channel.
When you have finished this process — it should take less than five minutes — you can open your eyes and go about your business. If you make this part of your daily routine, you will be amazed at how much improvement you will see in your life.

Tuesday, June 25, 2013

Principle 74 :

Visualization is really quite simple. You sit in a comfortable position, close your eyes and imagine — in as vivid detail as you can — what you would be looking at if the dream you have were already realized. Imagine being inside of yourself, looking out through your eyes at the ideal result.
Mental Rehearsal
Athletes call this visualization process “mental rehearsal,” and they have been using it since the 1960s when we learned about it from the Russians.
All you have to do is set aside a few minutes a day. The best times are when you first wake up, after meditation or prayer, and right before you go to bed. These are the times you are most relaxed.
-Jack Canfield

Monday, June 24, 2013

Principle 73 :

Visualization of your goals and desires accomplishes four very important things.
1.) It activates your creative subconscious which will start generating creative ideas to achieve your goal.
2.) It programs your brain to more readily perceive and recognize the resources you will need to achieve your dreams.
3.) It activates the law of attraction, thereby drawing into your life the people, resources, and circumstances you will need to achieve your goals.
4.) It builds your internal motivation to take the necessary actions to achieve your dreams.

Friday, June 21, 2013

Principle 72 :

Visualize and Affirm Your Desired Outcomes: A Step-by-Step Guide

You have an awesome power that most of us have never been taught to use effectively.

Elite athletes use it. The super rich use it. And peak performers in all fields now use it. That power is called visualization.

The daily practice of visualizing your dreams as already complete can rapidly accelerate your achievement of those dreams, goals and ambitions.

Jack Canfield

Thursday, June 20, 2013

Principle 71 :

Are You Aligned?
There are a few ways to gauge whether your goals are aligned with your purpose. The first is to simply check in with yourself and ask whether achieving the goal supports your life purpose. If not, the goal is not something you should pursue.

Conveniently, human beings are equipped with an inner guidance system that tells us when we are on or off purpose based on the amount of joy we are experiencing. When you feel like you are in “flow,” you are on purpose. When working toward your goals is a chore or success is extremely difficult, stop and evaluate whether your goal is aligned with your purpose.
A final technique you can use is to probe deeper into your desire to achieve a particular goal. Ask yourself, “If I achieve this goal, what would I have then that I don’t have now?” When you have an answer, ask the question again. Continue the process until you’ve reached your root desire. Then ask whether you truly need to achieve the goal to get what you really want.
For example, you may say that you want to earn $1 million. But upon further examination, you may realize that what you really crave is the joy of pursuing what you really want to do in life, which you would be able to do wholeheartedly once you had enough money to ensure financial security. Must you become a millionaire to experience joy? Of course not. Instead, consider all the ways that you can experience what you truly want to feel and be, then make those your goals.
At its heart, effortless success is about fully embracing and expressing who you are. It means following your inner guidance to ensure that you are living your very unique purpose as much as you can. Use the tips shared in this article to identify the right goals to pursue in 2012 – and watch how much easier it becomes to achieve your dreams.

Wednesday, June 19, 2013

Principle 70 :

What Alignment Means
We’re all gifted with a set of talents and interests that tell us what we’re supposed to be doing. Once you know what your life purpose is, organize all of your activities around it. Everything you do should be an expression of your purpose. If an activity or goal doesn’t fit that formula, don’t work on it.
For example, I frequently am invited to participate in multi-level marketing companies and have on several occasions. But when I have, it’s left me feeling drained, even though the companies and their products were superior. The reason is that hosting meetings and selling opportunities to others does not support my purpose – to inspire and empower people to live their highest vision in a context of love and joy. I’ve learned through experience that the best way for me to work with MLM companies is by speaking to and training their distributors, an activity that allows me to fulfill my purpose.
Aligning with your purpose is most critical when setting professional goals. When it comes to personal goals, you have more flexibility. If you want to learn how to paint or water ski, go ahead and do so. If your goal is to get fit and lose weight, move ahead with confidence. Nurturing yourself emotionally, physically and spiritually will make you more energized, resilient and motivated to live your purpose on the professional front.
However, don’t ignore the signs that your job or career is not right for you. If you dread Monday mornings and live for the weekends, it may be a sign that it’s time to follow your heart and pursue the work you long to do.

Tuesday, June 18, 2013

Principle 69 :

The Key to Effortless Success :
We each have a unique purpose to fulfill here on Earth. Identifying, acknowledging and honoring this purpose is perhaps the most important action successful people take.
Without a purpose in life, it’s easy to get sidetracked and end up accomplishing very little. But with a purpose, everything seems to fall into place. The people, resources and opportunities you need naturally gravitate toward you. The world benefits, too, because when you act in alignment with your true life purpose, all of your actions automatically serve others.

Jack Canfield

Monday, June 17, 2013

Principle 68 :

Aligning Goals with Your Purpose:

Many people subscribe to the Protestant work ethic, which says you must work hard to prosper. But success does not require struggle and suffering. It can be effortless, meaning that you are having fun while pursuing your goals, even when you’re working incredibly hard.
The key to unlocking effortless success lies in the goals that you choose to pursue. The more your goals are aligned with your purpose, the more fun you’ll have … and the more easily you’ll achieve the success you desire