I hope everyone is ok. I am sorry to bother you with some basic questions but I am new to mongodb and i am struggling a bit.
I am a junior devOps, and i have a practice project which consist in:
1 aws instance running a nodejs application (just a simple home page) running on port 3000
2 a mongodb (configured with the application and should connect on port 27017
Inside the app configuration, there is a variable called DB_HOST(where, from the instance, we should import the link
and we should be able to connect from the app instance IP:27017/posts to the mongodb and display some random blog posts.
Now, the process i followed, was using chef,packer and terraform to spin up aws instances. the app application works just fine, but if i try to access the mongodb, keeps loading the page but nothing happens.
Here are the steps i did.
Withthe application, i implemented a nginx reverse proxy, so the communication get through port 80 instead of port 3000
in mongodb i did this
# mongod.conf # for documentation of all options, see: # http://docs.mongodb.org/manual/reference/configuration-options/ # Where and how to store data. storage: dbPath: /var/lib/mongodb journal: enabled: true # engine: # mmapv1: # wiredTiger: # where to write logging data. systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log # network interfaces net: port: <%= @port %> bindIp: <%= @bind_ip %> #processManagement: #security: #operationProfiling: #replication: #sharding: ## Enterprise-Only Options: #auditLog: #snmp:
and in the attributre i set:
default[‘mongodb’][‘port’] = 27017
default[‘mongodb’][‘bind_ip’] = ‘0.0.0.0’
doing this i should be able to connect from any ip to the port 27017.
Now, doing this, if i ssh inside my app instance and node seed my db, i can do so, but as soon as i run the command npm start, i get an error that there is another service running on port 3000.
plus i have another problem, as i need to implement a replicaset, in my DB_HOST i should implemente 3 different mongodb, so i did so:
but doing this, i get an error that i cant pass multiple values.
Any idea guys to sort out this? thank you very much for your help.