Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up mongoDB raspberry pi

i just installed mongopi from https://github.com/RickP/mongopi and it working correctly after doing a few adjustments mainly $ sudo chown $USER /data/db. However my mongo and mongod calls arent persistent i do PATH=$PATH:/opt/mongo/bin/ & export PATH however this does not last on next ssh session. Also how can I make mongo initialize at startup? I did all the steps from the github repo.

like image 948
Jareddlc Avatar asked Oct 04 '22 10:10

Jareddlc


1 Answers

For the path part of the question:

To get the path working you should put it in a script that runs every time you log in. Generally there is a rc-file for you shell in your home directory. Type

echo $SHELL

to see what shell you are running. Go to your home directory:

cd

and then open the file that is called .(your shell)rc - that is, if you are running bash, open .bashrc

nano .bashrc

add the path at the end of this file:

PATH=$PATH:/opt/mongo/bin
export PATH

For the initialization part of the question:

Download and edit this script: Mongo init.d at github

You'll need to change the value of the DEAMON at line 50. I had some other troubles, but you should probably be ok if you create a configuration file (that probably could be empty) and refer to it from line 57. Also, you need to add a mongodb user that the server should run as. You can edit this on line 95, but the default is probably a good idea.

When all this editing is done, you move the file to /etc/init.d/mongodb, like so:

sudo mv init.d /etc/init.d/mongodb

and then add it to the systems start-up routine

sudo update-rc.d mongodb defaults

(This is presuming you run debian. Other distros may have other commands to do this.)

Now, see to that you are not running mongod some other place, and control the service by

sudo service mongodb start
service mongodb status
sudo service mongodb stop

... and so on. This will also run automatically on start-up and shutdown.

like image 141
Bex Avatar answered Oct 12 '22 11:10

Bex