Metasploit is a penetration testing framework which can provide a platform for vulnerability scanning, identification and exploit execution on a target.
We can look up exploits from exploit-db using searchsploit , and any results are able to be used immediately within the framework.
Open - mfsconsole
SearchSploit - searchsploit $name-of-service-or-exploit
Use Exploit - use $name-or-number-of-exploit
Show Info on Exploit: info
Show Options - options
Set RHOST - set RHOST $target-ip
Run an Exploit - run or exploit
If an exploit fails, further options may be presented by Metasploit using the options command. A list of alternative payloads which we can select from using set payload $name-of-payload will be available.
Keeping in mind our information about payloads , we can find from these further presented options that if we are having difficulty with our exploit, we can see at a glance alternate routes. For example, if we are using attempting a staged reverse shell and it's not working, we can try a staged bind shell, or if we are trying a non-staged bind shell we can try a staged bind shell.
I think the other options are apparent here - try combinations and adjustments of your approach till you find what works.