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
# 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.


open the github page for the current git repository in your browser

February 4, 2016 Leave a comment

You have a GitHub project and you are in its local folder in bash. How to open the project’s GitHub page with one command?

I found a bash function for this (credits are at the top in comments):

# Opens the github page for the current git repository in your browser
function gh() {
  giturl=$(git config --get remote.origin.url)
  if [ "$giturl" == "" ]
     echo "Not a git repository or no remote.origin.url set"
     exit 1;

  branch="$(git symbolic-ref HEAD 2>/dev/null)" ||
  branch="(unnamed branch)"     # detached HEAD
  echo "#" $giturl
  xdg-open $giturl

Just add it to the end of your ~/.bashrc file, open a new terminal (or source it) and use the “command” gh in your shell.

For more info on xdg-open see this post.

Categories: bash Tags:

open a web page from a bash script

February 4, 2016 Leave a comment

How to open a web page from a bash script?

Under Manjaro:

$ xdg-open http://your/url

However, it opened Chrome by default while I’m a Firefox believer. Here is the remedy:

$ xdg-settings set default-web-browser firefox.desktop
$ xdg-open http://your/url

Now it works as it is supposed to work.

Categories: bash, firefox Tags:

weather information

January 23, 2016 Leave a comment

You need a free weather API.

Use See the API description here.


Sample output:

	"coord": {
		"lon": 19.04,
		"lat": 47.5
	"weather": [
			"id": 600,
			"main": "Snow",
			"description": "light snow",
			"icon": "13n"
			"id": 701,
			"main": "Mist",
			"description": "mist",
			"icon": "50n"
	"base": "cmc stations",
	"main": {
		"temp": -4,
		"pressure": 1034,
		"humidity": 85,
		"temp_min": -4,
		"temp_max": -4
	"wind": {
		"speed": 2.1,
		"deg": 100
	"clouds": {
		"all": 90
	"dt": 1453579200,
	"sys": {
		"type": 1,
		"id": 5724,
		"message": 0.0092,
		"country": "HU",
		"sunrise": 1453530015,
		"sunset": 1453563103
	"id": 3054643,
	"name": "Budapest",
	"cod": 200

As can be seen, the temperature in this city is -4 Celsius.

Categories: api Tags: ,

[manjaro] install an older version of a package (downgrade)

January 5, 2016 Leave a comment

There is a problem with the newest version of a package and you want to go back to the previous version. How to do that?

Note: currently (January 2016) there is a problem with the newest truecrypt package (truecrypt 7.1a-3), you cannot mount any volume, so it is suggested to install version 7.1a-2.

Visit the official archive site at , enter packages/, and download the package with the desired version. The extension of a package is .tar.xz .

How to install it from the file system:

sudo pacman -U package.tar.xz

However, if you update all your packages with “yaourt -Syua“, this older package will be upgraded. To prevent that, edit the file “/etc/pacman.conf” and put the name of the package in an ignore list. My ignore list looks like this:

IgnorePkg   = vuze truecrypt
Categories: manjaro Tags: , ,

2015 in review

December 31, 2015 Leave a comment

The stats helper monkeys prepared a 2015 annual report for this blog.

Here's an excerpt:

The Louvre Museum has 8.5 million visitors per year. This blog was viewed about 140,000 times in 2015. If it were an exhibit at the Louvre Museum, it would take about 6 days for that many people to see it.

Click here to see the complete report.

Categories: Uncategorized Tags: ,

[manjaro] xbox 360 controller

December 31, 2015 Leave a comment

For Xmas I bought an Xbox 360 (wired) controller for me. It’s really good :) It works well under Windows but how to use it under Manjaro?

When I started Manjaro, the led on the central button (“ring of light”) was blinking and the controller didn’t work. I tried it with some games on Steam but nothing happened. Then I noticed that if I unplug and reconnect the controller, then it starts working :) Actually, the cord has an inline release and it’s simpler to disconnect and reconnect this inline release. After this the led stopped blinking and its second quadrant started to glow.

Now the controller worked with the games but I could also move the mouse pointer with the controller. It was disturbing in the games so I had to create the following file:

/etc/X11/xorg.conf.d/50-joystick.conf :

Section "InputClass"
        Identifier "joystick catchall"
        MatchIsJoystick "on"
        MatchDevicePath "/dev/input/event*"
        Driver "joystick"
        Option "StartKeysEnabled" "False"       #Disable mouse
        Option "StartMouseEnabled" "False"      #support

Restart the machine and you are done. Some tutorials suggest the “xboxdrv” package but I didn’t need that. The kernel in Manjaro includes the “xpad” kernel module and it worked well for me.

There was another problem: while I was playing, after some time the screensaver kicked in. The “caffeine-ng” package solved this issue (see also this post).


Categories: games, manjaro Tags: , , ,

Get every new post delivered to your Inbox.

Join 85 other followers