Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with persistent mongoDB data on EC2
    primarykey
    data
    text
    <p>I'm trying to store data in a mongoDB database on Amazon EC2. I'm using starcluster to configure and start the EC2 instance. I have an EBS volume mounted at /root/data. I installed mongoDB following the instructions <a href="http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/" rel="nofollow">here</a>. When I log in to the EC2 instance I am able to type <code>mongo</code>, which brings me to the mongo shell with the <code>test</code> database. I have then added some data to a database, let's say <code>database1</code>, with various collections in it. When I exit the EC2 instance and terminate it, using <code>starcluster terminate mycluster</code>, and then create a new, different instance, the <code>database1</code> data is no longer shown in the mongo shell. </p> <p>I have tried changing the dbpath in the <code>/etc/mongodb.conf</code> file to <code>/root/data/mongodb</code>, which is the EBS volume, and then start and stop the <code>mongodb</code> service using <code>sudo service mongodb stop</code> and <code>sudo service mongodb start</code>. I then try <code>mongo</code> again and receive </p> <pre><code>MongoDB shell version: 2.2.2 connecting to: test Sat Jan 19 21:27:42 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91 exception: connect failed </code></pre> <p>An additional issue is that whenever I terminate the EC2 instance any changes I made to the config file disappear.</p> <p>So my basic question is: how do I change where mongoDB stores its data on EC2 so that the data will remain when I terminate one EC2 instance and then start another EC2 instance.</p> <h3>Edit:</h3> <p>In response to the first answer:</p> <ol> <li>The directory does exist</li> <li>I changed the owner to <code>mongodb</code></li> <li>I then issued the command <code>sudo service mongodb stop</code></li> <li>Checked to see if the port is released using <code>netstat -anp | grep 27017</code>. There was no output.</li> <li>Restarted mongodb using <code>sudo service mongodb start</code></li> <li>Checked for port 27017 again and receive no output.</li> <li>Tried to connect to the mongo shell and received the same error message. </li> <li>Changed the <code>mongodb.conf</code> back to the original settings, restarted mongodb as in the above steps, and tried to connect again. Same error. </li> </ol> <p>The EBS volume is configured in the starcluster config to be reattached on each startup. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload