10 Reasons to Upgrade to Ubuntu 15.04 (parody of a Windows 10 advertisement)

August 24, 2015 Leave a comment

And here is the original:

Found it on reddit.

Categories: fun, linux, windows 10 Tags:

Midnight Commander: remember directories on the left and right sides when you quit

August 21, 2015 Leave a comment

Problem
When you suffer enough, you will want to change. Nobody likes suffering. I’m a huge fan of MC but one thing troubled me for months: when I quit MC and restart it, it doesn’t remember the last directories in the left and right panels.

As it was driving me crazy, finally I decided to look after the problem. As usual, the solution was just 1 minute away.

Solution
A quick Google search dropped out this thread. That is:

Menu->Options->Panel options...
[x] Auto save panels setup
Categories: linux Tags: , , ,

[manjaro] compile MongoDB from source and install it manually

August 20, 2015 Leave a comment

Problem
I wanted to install MongoDB on an old 32-bit laptop of mine. After installing it from the official repository, the mongo shell died with the following error: ” Illegal instruction (core dumped)”.

Solution
The problem is that the binary file uses an instruction set that is not supported by my old 32-bit CPU:

$ cat /proc/cpuinfo | grep flags
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx bts est tm2

SSE3 is missing :( What to do? Uninstall the mongodb package and 1) compile it from source, 2) install it and 3) make it start at startup.

(1) Compile the source
I found an excellent blog post about it at http://kdenby.homelinux.com/?p=25 . Here I would sum up the steps.

Download the source from here: https://www.mongodb.org/downloads . It’s about 35 MB. The source uses the SCons build system, so install the “scons” package too. Note that the compilation process took about 6 hours on my old laptop and the work directory where compilation was being done grew to 18 GB! I didn’t have that much free space so I had to move this work directory to an external HDD :) However, when you install the binaries, they will only occupy 90 MB.

So, if you have an old CPU, edit the file SConstruct:

        if using_gcc() or using_clang():
                myenv.Append( CCFLAGS=['-march=pentium3', '-mtune=generic'] )
                #myenv.Append( CCFLAGS=['-march=nocona', '-mtune=generic'] )

The target architecture “nocona” was replaced by “pentium3”. Again, this tip is from Karl.

After this you can start the compilation and wait :)

$ scons --disable-warnings-as-errors --32 all

The blog post at http://kdenby.homelinux.com/?p=25 stops at this point.

(2) Install the binaries
I installed the binaries to /opt:

$ scons --prefix=/opt/mongo-3.0.5 install

Of course, replace “3.0.5” with your current version. I also put a symbolic link on this folder:

$ cd /opt
$ ln -s mongo-3.0.5 mongo

Note that the binaries are put into a “bin” folder, thus they are located in “/opt/mongo-3.0.5/bin/“.

Now put symbolic links in /usr/bin/ that point to the appropriate binaries in /opt/mongo/bin/. They look like this on my machine:

$ cd /usr/bin
$ ls -al | grep mongo
lrwxrwxrwx  1 root root         20 11.08.2015 08:30 mongo -> /opt/mongo/bin/mongo
lrwxrwxrwx  1 root root         21 11.08.2015 08:31 mongod -> /opt/mongo/bin/mongod
lrwxrwxrwx  1 root root         24 11.08.2015 08:31 mongoperf -> /opt/mongo/bin/mongoperf
lrwxrwxrwx  1 root root         21 11.08.2015 08:31 mongos -> /opt/mongo/bin/mongos
lrwxrwxrwx  1 root root         25 11.08.2015 08:31 mongosniff -> /opt/mongo/bin/mongosniff

(3) Make MongoDB start at startup
Create these two directories: /var/lib/mongodb and /var/log/mongodb . The mongo daemon shouldn’t run with root privileges, so we create a dedicated user for this purpose and set its password:

$ sudo adduser mongodb
$ sudo passwd mongodb

Now, the owner of the previously created two folders will be “mongodb“, and they will belong to the “daemon” group. Example on my machine:

$ cd /var/log
$ ls -al | grep mongodb
drwxr-xr-x  2 mongodb daemon            4096 11.08.2015 09:29 mongodb/

Use the chown and chgrp commands.

After this, you need to copy some config files as root. They are collected here.

First, create /etc/mongodb.conf . Mine looks like this:

# See http://www.mongodb.org/display/DOCS/File+Based+Configuration for format details
# Run mongod --help to see a list of options

bind_ip = 127.0.0.1
quiet = true
dbpath = /var/lib/mongodb
logpath = /var/log/mongodb/mongod.log
logappend = true

noprealloc = true
smallfiles = true

Next, create /usr/lib/systemd/system/mongodb.service . Sample:

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf

[Install]
WantedBy=multi-user.target

Now it’s time to enable and start the mongodb service:

$ systemctl enable mongodb.service
$ systemctl start mongodb.service

Verify if it’s running:

$ systemctl status mongodb.service

If it seems OK, try to connect to it with the mongo shell using the command “mongo“.

Troubleshooting
If the service doesn’t start with the systemctl command, then try to launch the server manually:

$ mongod --quiet --config /etc/mongodb.conf

You may want to remove the “--quiet” option. If it has some problems, it will print a more detailed error message than “systemctl start...“.

I wrote this post one week after I installed MongoDB, but I hope I didn’t forget any steps. Good luck!

Categories: bash, linux Tags: , , , ,

mongo shell: WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’

August 11, 2015 Leave a comment

Problem
You start the mongo shell (with the command “mongo“) and you get some warnings:

MongoDB shell version: 3.0.0
connecting to: test
Server has startup warnings: 
2015-03-13T16:28:29.405+0800 I CONTROL  [initandlisten] 
2015-03-13T16:28:29.406+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-03-13T16:28:29.406+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-03-13T16:28:29.406+0800 I CONTROL  [initandlisten] 
2015-03-13T16:28:29.407+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-03-13T16:28:29.407+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-03-13T16:28:29.407+0800 I CONTROL  [initandlisten]

How to get rid of these warnings?

Solution
This issue is addressed at http://docs.mongodb.org/manual/tutorial/transparent-huge-pages/#transparent-huge-pages-thp-settings . Here they explain what to do under Ubuntu.

But what about Manjaro? ;)

First, follow the steps of this post: https://ubuntuincident.wordpress.com/2015/08/11/manjaro-run-a-command-at-startup-as-root/ . Here it is explained how to create a script that is executed at startup. When ready, go on with the following operations:

Create the file /etc/rc.d/disable-transparent-hugepages with this content (copied from here):

#!/usr/bin/env sh

### BEGIN INIT INFO
# Provides:          disable-transparent-hugepages
# Required-Start:    $local_fs
# Required-Stop:
# X-Start-Before:    mongod mongodb-mms-automation-agent
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description:       Disable Linux transparent huge pages, to improve
#                    database performance.
### END INIT INFO

case $1 in
  start)
    if [ -d /sys/kernel/mm/transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/transparent_hugepage
    elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/redhat_transparent_hugepage
    else
      return 0
    fi

    echo 'never' > ${thp_path}/enabled
    echo 'never' > ${thp_path}/defrag

    unset thp_path
    ;;
esac

Make it executable (chmod u+x). Then edit /etc/rc.d/rc.local and add the previous script to it. Mine looks like this:

#!/usr/bin/env bash

/etc/rc.d/disable-transparent-hugepages start

Next time you reboot and start mongo you won’t see the warnings.

Categories: mongodb Tags: ,

[manjaro] run a command at startup as root

August 11, 2015 2 comments

Problem
Manjaro (and Arch) uses systemd as a system and service manager, which differs from Ubuntu’s upstart. Under Ubuntu it is enough to edit /etc/rc.local and those commands are executed upon boot. How to mimic this functionality with systemd?

Solution
I found a nice solution in this thread, posted by patroclo7. Here I just copy his solution.

Create the file /etc/rc.d/rc.local and make it executable (chmod u+x). In this file add the command(s) you want to execute at startup.

Then, create a service file for rc.local in /etc/systemd/system/rc-local.service with this content:

[Unit]
Description=/etc/rc.local compatibility
ConditionFileIsExecutable=/etc/rc.d/rc.local

[Service]
Type=oneshot
ExecStart=/etc/rc.d/rc.local
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

Finally, enable it:

systemctl enable rc-local

Now if you reboot, the commands in rc.local will be executed with root privileges.

Credits

Categories: manjaro Tags: , ,

[manjaro] ignore package update

August 9, 2015 1 comment

Problem
I installed vuze from AUR but vuze keeps updating itself. When a new version appeared in AUR, I tried to update the vuze package but it failed due to file conflict. Since vuze is actually up-to-date, there is no need to update it from AUR, and I don’t want to see any messages from the package manager either to update this package.

Solution
Put this package on an ignore list and thus the package manager won’t want to update it.

Open /etc/pacman.conf and add this line:

IgnorePkg = vuze

You can also specify several packages separated by a space. Both pacman and yaourt will ignore this (these) package(s).

Categories: manjaro Tags: , ,

turn off annoying YouTube annotations

August 9, 2015 Leave a comment

Problem
YouTube annotations are driving you crazy.

Solution
Turn ’em off for good. Follow these simple steps: http://www.businessinsider.com/turn-off-youtube-annotations-for-good-2014-8 .

Categories: tips Tags: , ,
Follow

Get every new post delivered to your Inbox.

Join 81 other followers