How to connect to MongoDB EC2 instance

前端 未结 6 784
失恋的感觉
失恋的感觉 2020-12-31 02:05

we have an EC2 MongoDB 2.4 instance from Amazon MarketPlace. when i try to access it from my computer using the mongo command like so:

mongo xx-xx-xx-xx-xx.c         


        
6条回答
  •  长情又很酷
    2020-12-31 02:14

    The following two steps enabled the remote connection for me:

      1. Opening the inbound rould for my VPC at port 27017 VPC -> Security -> Security Groups -> choose your instance's TCP roule -> click "Edit Rules" -> add a rule with Type: "Custom TCP Rule", Protocol: TCP, Port Range: 27017, Source: Custom 0.0.0.0/0 -> save
      1. SSH into your instance -> sudo vi /etc/mongod.conf -> set bindIp: 0.0.0.0 -> save -> sudo service mongod restart

    After that you will be able to connect into you remote mongo instance with mongo --host YOUR_INSTANCE_IP

提交回复
热议问题