I have wondering that Tiny Core linux does not contain MongoDB extension in the current release (7.x) repository. I decided to build it from sources by myself.
tce-load -iw gcc.tcz python.tcz linux-kernel-sources-env.tcz
Next, download and prepare to use SCons 2.3 (newer, than in tiny core repository):
wget https://bitbucket.org/scons/scons/get/2.3.6.tar.gz
tar -xzvf 2.3.6.tar.gz
cd scons-scons-6ccc44a210ae
export MYSCONS=`pwd`/src
export SCONS_LIB_DIR=$MYSCONS/engine
Now download and unpack mongo sources:
cd ~
wget http://fastdl.mongodb.org/src/mongodb-src-r3.2.11.tar.gz
tar -xzvf mongodb-src-r3.2.11.tar.gz
And start build (takes abount 20 min):
cd mongodb-src-r3.2.11/
python $MYSCONS/script/scons.py -j 4 --wiredtiger=off mongod
python $MYSCONS/script/scons.py -j 4 --wiredtiger=off mongo
-j 4 means use 4 parralel build thread.
--wiredtiger=off disables build wiredtiger engine. Won't build without this in my enviroment.
Now we have the "big" version of executables: mongod is 432.4M; mongo is 156.7M.
For make them much more compact doing that:
strip -sg mongod
strip -sg mongo
After that mongod size is 32.9M. And mongo 17.8M. Much better!
Build done!
Build
For start building we need to load some extensions:tce-load -iw gcc.tcz python.tcz linux-kernel-sources-env.tcz
Next, download and prepare to use SCons 2.3 (newer, than in tiny core repository):
wget https://bitbucket.org/scons/scons/get/2.3.6.tar.gz
tar -xzvf 2.3.6.tar.gz
cd scons-scons-6ccc44a210ae
export MYSCONS=`pwd`/src
export SCONS_LIB_DIR=$MYSCONS/engine
Now download and unpack mongo sources:
cd ~
wget http://fastdl.mongodb.org/src/mongodb-src-r3.2.11.tar.gz
tar -xzvf mongodb-src-r3.2.11.tar.gz
And start build (takes abount 20 min):
cd mongodb-src-r3.2.11/
python $MYSCONS/script/scons.py -j 4 --wiredtiger=off mongod
python $MYSCONS/script/scons.py -j 4 --wiredtiger=off mongo
-j 4 means use 4 parralel build thread.
--wiredtiger=off disables build wiredtiger engine. Won't build without this in my enviroment.
Now we have the "big" version of executables: mongod is 432.4M; mongo is 156.7M.
For make them much more compact doing that:
strip -sg mongod
strip -sg mongo
After that mongod size is 32.9M. And mongo 17.8M. Much better!
Build done!
Run & check
Now let's check how it works.
Create working dir and DB folder:
mkdir -p ~/mongodb/db
Start mongod daemon:
./mongod --dbpath ~/mongodb/db --nojournal --fork --logpath ~/mongodb/mongo.log --pidfilepath ~/mongodb/mongo.pid --storageEngine mmapv1
For check run the client - mongo. Type next some commands:
#./mongo
MongoDB shell version: 3.2.11
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
> doc1 = { name : "sombody" };
{ "name" : "sombody" }
> db.sites.insert( doc1 );
WriteResult({ "nInserted" : 1 })
> db.sites.find();
{ "_id" : ObjectId("5882eb24b3fede14d677c978"), "name" : "sombody" }
> quit();
For stop mongod daemon use command:
kill `cat ~/mongodb/mongo.pid`
For stop mongod daemon use command:
kill `cat ~/mongodb/mongo.pid`
Congratulation, you just take the power of MongoDB in your Tiny Core linux.
No comments:
Post a Comment