Namenode loads the filesystem state from fsimage and stays in safe mode and wait for data nodes to report their blocks. Safemode is a read-only mode for HDFS cluster, so that it does not prematurely start replicating the blocks. Use following command to let the namenode leave safemode forcefully.
$ hadoop dfsadmin -safemode leave
In newer versions of hadoop command is deprecated. You can use hdfs command instead of hadoop. For example:
$ hdfs dfsadmin -safemode leave
You must run hadoop fsck so sort out any inconsistencies created in the hdfs due to above command.