Showing posts with label tcl. Show all posts
Showing posts with label tcl. Show all posts

Saturday, 21 January 2017

Building mongodb 3.2.11 from sources on Tiny Core Linux 7.2

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.

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`

Congratulation, you just take the power of MongoDB in your Tiny Core linux.

Thursday, 8 December 2016

Install Tiny Core Linux on Virtual Box using small "Core" (11Mb) ISO


  1. Download ISO from http://tinycorelinux.net/downloads.html
  2. Attach it to new VM and run it
  3. Optionally install SSH for more comfortable installation process:
    1. tce-load -iw openssh
    2. sudo passwd tc
    3. sudo /usr/local/etc/init.d/openssh start
  4. Create file system and mount it:
    tce-load -iw parted.tcz
    sudo parted /dev/sda mktable msdos
    sudo parted /dev/sda mkpart primary ext3 1% 99%
    sudo parted /dev/sda set 1 boot on
    mkfs.ext3 /dev/sda1
    sudo parted /dev/sda print
    sudo rebuildfstab
    mount /mnt/sda1
  5. Install grub:
    tce-load -iw grub2.tcz
    sudo -s
    grub-install --target=i386-pc --boot-directory=/mnt/sda1/boot /dev/sda
    mount /mnt/sr0/
    cp /mnt/sr0/boot/core.gz /mnt/sda1/boot/
    cp /mnt/sr0/boot/vmlinuz /mnt/sda1/boot/
  6. Configure Grub:
    1. vi /mnt/sda1/boot/grub/grub.cfg
    2. Enter:
      set timeout=3
      menuentry "Tiny Core" {
       linux /boot/vmlinuz com1=9600,8n1 loglevel=3 user=tc console=ttyS0 console=tty0 noembed nomodeset tce=sda1 opt=sda1 home=sda1
       initrd /boot/core.gz
      }
    3. Save file.
  7. Prepare filesystem:
    mkdir -p /mnt/sda1/tce
    touch /mnt/sda1/tce/mydata.tgz
    mkdir -p /mnt/sda1/opt
    mkdir -p /mnt/sda1/home
    reboot
  8. After reboot install openssh:
    tce-load -iw openssh
    sudo passwd tc
    sudo /usr/local/etc/init.d/openssh start
  9. Add some config to persistance.
    1. vi /opt/.filetool.lst
    2. Add:
      /usr/local/etc/ssh
      /etc/passwd
      /etc/shadow
    3. Save File.
  10. Add openssh to autostart
    1. vi /opt/bootlocal.sh
    2. Add:
      /usr/local/etc/init.d/openssh start
  11. Save configuration:
    filetool.sh -b
Complete image may be found here (20Mb). User/password: tc/tcuser