So after our build eventually finished we are left with a few files in the build directory. Time to make a home for MongoDB. We should also add a user for the service to run under, then copy those file across to the new home. The symlink just gives us a nice way to switch versions later on. Our scripts will refer to /opt/mongo at all times, but we can point that link at whatever version we want later on, so upgrades should be simple enough.
# cd /opt
# mkdir mongo-3.0.4
# ln -s mongo-3.0.4 mongo
# useradd -d /opt/mongo -s /sbin/nologin mongo
# passwd mongo
# cp /root/Downloads/mongodb-src-r3.0.4/dbtest /opt/mongo/
# cp /root/Downloads/mongodb-src-r3.0.4/mongo /opt/mongo/
# cp /root/Downloads/mongodb-src-r3.0.4/mongobridge /opt/mongo/
# cp /root/Downloads/mongodb-src-r3.0.4/mongod /opt/mongo/
# cp /root/Downloads/mongodb-src-r3.0.4/mongoperf /opt/mongo/
# cp /root/Downloads/mongodb-src-r3.0.4/mongos /opt/mongo/
# cp /root/Downloads/mongodb-src-r3.0.4/mongosniff /opt/mongo/
# chown -R mongo:mongo mongo
# mkdir /opt/mongo-data
I guess now we should be able to get things started, lets start up a mongod and connect to it with a mongo shell!.
# ./mongod –fork –smallfiles –dbpath /opt/mongo-data/ –logpath /var/log/mongod.log
# ./mongo
> show dbs
local 0.031GB
>
> use test
switched to db test
>
> db.test.insert( { x : 1 } )
WriteResult({ “nInserted” : 1 })
>
> db.test.findOne()
{ “_id” : ObjectId(“55a9785c183a7cf4beb7e73f”), “x” : 1 }
So our build was successful, we have a working mongod and a working mongo shell 🙂 We created the “test” db and inserted a record into the “test” collection, then we queried the test db and test collection and found our new record.
Later we will setup a simple python script to capture some data and log it in the database so that we have something to query.