After installing Elastic Search in system if we start elastic search it will work because by default Bootstrap Memory is false. If this is false then elastic search will use all the resources. So, to overcome this we need to lock the memory so that elastic search will use only limited resources.
But once we change the setting to true then it will not work because your memory is not locked and some other step also needed and this error will mostly occur in CentOS.
So, below are the notes which you need to do after turning on bootstrap memory.
sudo gedit /etc/security/limits.conf
After that in 'gedit' paste the below line in the end,
elasticsearch - nofile 65536
Now, type the below command to overwrite the Elastic Search settings,
sudo systemctl edit elasticsearch
After above command don't get panic you will get blank screen paste the below line to that screen,
After that execute the below command,
sudo systemctl daemon-reload
This command is optional, because in Ubuntu by default selinux is diabled but in CentOS it is enabled so we need to disable the selinux and if you are a CentOS user than execute this command,
sudo gedit /etc/sysconfig/selinux
and edit the status of selinux to 'disabled'.
After that restart your system.