You haven't mentioned what flavor of Linux you are using, but these will cover the major types:
Each of these install guides will walk you through installing MongoDB as a package, and each package will install MongoDB as a service on your host. Services are generally designed to start at boot, run in the background, restart when upgrades are done, and be started/stopped easily and cleanly etc.
The MongoDB packages are no exception, and this would be my recommended way of installing and running MongoDB in EC2 unless you want to go for one of the pre-configured AMI's from the marketplace of course.
For reference, it is absolutely possible to run MongoDB in the background manually. You will need to specify the --fork
, --logpath
options (or the config file equivalents) at a minimum to have it run in the background (I would recommend and --logappend
as well). When you are done you can either kill
the process or use the shutdown command from the mongo
shell. Some general guidance on these options (and more) can be found here.