Archive for February, 2016

[mongodb] move docs from one collection to another one

February 24, 2016 Leave a comment
var documentsToMove = db.collectionA.find({});
documentsToMove.forEach(function(doc) { 

Tip from here.

Categories: mongodb Tags:

[manjaro] Apache + PHP + RockMongo

February 20, 2016 Leave a comment

On my Manjaro box I wanted to use RockMongo. It’s a very nice web-based utility for MongoDB, like PHPMyAdmin for MySQL.

However, after an upgrade of my system it stopped working :(

It works on another machine of mine where I installed the packages “apache22” and “php-apache22”. However, on my main desktop I cannot install “php-apache22” again, the compilation terminates with an error message that I couldn’t resolve.

So, I had to use the packages “apache” and “php-apache”. I could make it work with the following package versions:

  • apache 2.4.18-1
  • php-apache 5.6.16-1
  • php 7.0.3-1
  • php-mongo 1.6.12-1

php-apache: the current version is 7.x, which uses PHP 7. RockMongo didn’t work with that, so I had to downgrade to this specific version.

php-mongo: there is a newer package called php-mongodb (notice the “db” at its end). With php-mongodb RockMongo didn’t cooperate. I couldn’t even find php-mongo (it’s deprecated I think) so I had to copy the files of this package (only 2 files) from my laptop to my desktop machine.

Using these versions of the packages and following these installation steps, finally I could make RockMongo work.

One more thing: to avoid an automatic update of “php-apache”, I added it to yaourt’s ignore list.

Here are the files of php-mongo (link). I couldn’t find this package anywhere so I copied it from my laptop where I still had it. It’s for x86_64 systems. I don’t say you should use it because it’s absolutely not safe. So I just say that I put it here for myself if I need it in the future. The README.txt file shows the rights / owner / group settings of the files.

Categories: manjaro Tags: , ,

monitor just one process with “top”

February 18, 2016 Leave a comment
top -p PID
Categories: bash Tags: , , ,

open .svg file in inkscape

February 18, 2016 Leave a comment

I wanted to open an SVG file in Inkscape but it dropped me some error: “namespace warning : xmlns: URI &ns_svg; is not absolute”.

I found the solution here. Steps to follow:

$ sudo apt-get install libxml2-utils sgml-data

$ xmllint --noent bad.svg > bad-fixed.svg
Categories: bash Tags: ,

[manjaro] if yaourt asks too much

February 16, 2016 Leave a comment

You are getting tired of these questions:

Edit PKGBUILD ? [Y/n] ("A" to abort)
Edit <pkg_name>.install ? [Y/n] ("A" to abort)

How to get rid of them?

In this blog post I found a solution that I sum up here:

First, copy the global yaourtrc file to your HOME directory:

cp /etc/yaourtrc ~/.yaourtrc

Then, edit ~/.yaourtrc and add these two lines to its end:



Update (20170203)
If you want yaourt not to ask any confirmation question when upgrading packages, use the “--noconfirm” option. Example:

yaourt -Syua --noconfirm
Categories: manjaro Tags: ,


February 15, 2016 Leave a comment

The tool screenfetch displays system/theme information in the terminal.

Here is a screenshot:


Looks good IMO. It can detect your distro and show the appropriate logo.

Categories: bash, linux

MongoDB: upgrade to the WiredTiger storage engine

February 7, 2016 Leave a comment

I started to use the MongoDB 2.x series and since then I’ve upgraded to MongoDB 3.2. MongoDB 3.0 introduced pluggable storage engines. In 3.0 the default was MMAPv1 but in 3.2 the default became the WiredTiger storage engine that has some advantages: document level concurrency, compression on data and indexes, etc. So naively, I checked my configuration:

$ mongo
MongoDB shell version: 3.2.0
connecting to: test
> db.serverStatus().storageEngine
{ "name" : "mmapv1", "supportsCommittedReads" : false }


Well, since I had some MMAPv1 databases when I upgraded MongoDB, it continued to use the old storage engine, so it’s understandable why I didn’t have WiredTiger. When I got over the shock, I decided to upgrade to the new engine. Here are the steps (under Manjaro):

Make a full backup of your databases:

$ mongodump --out <exportDirectory>

Stop the mongod process:

$ systemctl stop mongodb

Try to start the mongo shell with the command “mongo”. If it fails, then the server is correctly stopped.

Rename your database folder and create a new one. The “#” prompt means a root prompt.

# cd /var/lib
# mv mongodb mongodb.mmapv1
# mkdir mongodb
# chown mongodb mongodb
# chgrp daemon mongodb

Make a copy of your log file:

# cd /var/log/mongodb
# mv mongod.log mongod.log.mmapv1

Edit the config file /etc/mongodb.conf . I still had the old format (the new format uses YAML), but if it works then I don’t replace it yet. Add the following line to its end:


Now restart the server:

$ systemctl start mongodb

And check if it uses the new engine:

$ mongo
MongoDB shell version: 3.2.0
connecting to: test
> db.serverStatus().storageEngine
{ "name" : "wiredTiger", "supportsCommittedReads" : true }

Great! Now restore the databases that we backed up in the first step.

$ mongorestore <exportDirectory>

It will take a while. Let’s do a final check. Print the stats of a collection (sample):

$ mongo
MongoDB shell version: 3.2.0
connecting to: test
> show dbs
> use mydb
switched to db mydb
> show collections
> db.mycoll.stats()
        "ns" : "crunchbase.companies",
        "count" : 18801,
        "size" : 72236994,
        "avgObjSize" : 3842,
        "storageSize" : 36052992,
        "capped" : false,
        "wiredTiger" : {
                "metadata" : {
                        "formatVersion" : 1

It’s in WiredTiger format. Awesome.

If you want, you can delete the folder /var/lib/mongodb.mmapv1 with the old databases. But first make sure that everything works as before the migration.