参考 https://github.com/Barryrowe/mongo-arm
Installation Steps:
-
Download binaries
#Clone this repository git clone https://github.com/Barryrowe/mongo-arm.git
-
Create the mongo user
sudo useradd mongo sudo passwd mongo
-
Copy the mongo binaries to the desired install location
#example: cp -R binaries/2.1.1 /opt/mongo
-
Change the ownership of the installed mongo binaries so they are owned by the mongo user
chown -R mongo:mongo /path/to/installed/binaries
-
Creat the /data/db directory for MongoDB's data storage
sudo mkdir /data sudo mkdir /data/db
-
Change the ownership of the /data/db directory so it is owned by the mongo user
sudo chown mongo:mongo /data/db
Set As Service Steps (Debian)
-
Copy config/mongodb to the init.d location
sudo cp config/mongodb /etc/init.d/mongodb
-
Update /etc/init.d/mongodb to point to your install path from step 3
A. Line 50 will need to be modified to point to the mongos executable from your install path in step 3.
B. If you created a user with name other than "mongo" in step 2 you will need to update Line 95 with the user you configured.
-
Update the permissions for the mongodb init.d file so it can be executed
sudo chmod 755 /etc/init.d/mongodb
-
Copy the config/mongod.conf file to /etc/mongod.conf
sudo cp config/mongod.conf /etc/mongod.conf
-
Register the mongodb service
sudo update-rc.d mongodb defaults
-
Startup the service
sudo service mongodb start
Managing MongoDB After Install and Setting as Service
Once installed and configured, you can use these commands to manage the mongodb service you've setup.
#start the service
sudo service mongodb start
#check the service status
service mongodb status
#stop the service
sudo service mongodb stop
If your mongodb service won't start you might just get output like this:
....] Starting database: mongod/etc/init.d/mongodb: 131: ulimit: Illegal option -u
numactl:
daemuser: mongo
pidfile: /var/run/mongod.pid
daem: /opt/mongo/bin/mongod
daemopts: -- --config /etc/mongod.conf
. failed
NOTE: In this case, make sure to check the /data/db/ directory for a file mongod.lock. If mongodb isn't stopped cleanly, the mongod process can leave this lock file in place preventing the service from properly starting. Usually you can just remove the file and mongodb will start normally
#remove mongod.lock file after unclean shutdown
sudo rm /data/db/mongod.lock
Comments(1)
fffff