Dekoratives Bildchen

Performance Tuning for Linux Software Raid

After finishing my Homeserver project I wanted to get the maximum of performance. At the end of my research in the web i have created following script:

# Get Arrays and physical Disks for active Raid5 Volumes

ARRAYS=""
DISKS=""

for field in `cat /proc/mdstat | grep "active raid5"`
do
  if [[ "x${field:0:2}x" == "xmdx" ]]
  then
    ARRAYS="$ARRAYS $field"
  elif [[ "x${field:0:2}x" == "xsdx" ]]
  then
    DISKS="$DISKS ${field:0:3}"
  fi
done

# Changes on physical Devices
for disk in $DISKS
do
  #Set read-ahead to 16MB
  blockdev --setra 16384 /dev/$disk
  #Device Queue Tuning
  echo 1024 > /sys/block/$disk/queue/read_ahead_kb
  echo 256 > /sys/block/$disk/queue/nr_requests
  #Disable NCQ
  echo 1 > /sys/block/$disk/device/queue_depth
done

# Changes on Raid Arrays
for array in $ARRAYS
do
  #Set read-ahead to 64MB
  blockdev --setra 64536 /dev/$array
  #Increase stripe-cache size
  echo 16384 > /sys/block/$array/md/stripe_cache_size
done

This are the optimal and tested settings for my system. The numbers can differ from system to system. You have to test.

Howto tunnel TCP connections over SSH

Network Layout:

tcp-tunnel-overview

There is one server which is only connectable via SSH. This server hosts two additional services: git and http. We have no access to the firewall and can’t forward the ports. The server is a linux system, as clients windows and linux are a option.

We can use the comon git port on our client, but we can’t use port 80 on the client because there is already a webserver running.

Server configuration:

Changes in /etc/ssh/sshd_config:

....
Port 22
....
AllowTCPForwarding yes
...

Linux Client:

Only a few parameters are needed to tunnel our git and web service:

me@client$ ssh -L 10080:localhost:80 -L 9418:localhost:9418 user@server
user@server$ 

As soon as the SSH session starts, you can connect to localhost:10000 for access to the web server. The git service listens on the same port as on the server, so you only have to change the server configuration to localhost in your git client.

Windows Client:

I use putty a very common ssh client:

Open putty and enter username and destination server:

putty-server.

In Connection->SSH->Tunnels configure the tunnels:

putty-tunnel

Just click open and start the session.

Now you should connect to the tunneled services as shown in the linux config.

Multi-Language WordPress with xili-language Plugin

I started this blog at first to write about things i have tested or built in my private life. But then VMware and Linux got more and more and i thought it would be could to blog in two languages.

There are many plugins or ways to do this in wordpress and i decided to use xili-language.

This plugin extends the create new post page with a additional window where you can select a language for this post.

beitrag-neu

It is easy to change the default language of your wordpress Blog, but i set it to the prefered language of the browser:

languages-front-end-settings

This was the point where my blog displayed the corresponding posts for the selected language, but i had problems with the widgets on the right side.No language setting took any effect. The widgets were displayed in german.

The change of the sidebar widgets to the special xili-language versions didn’t change anything.

The solution came from the perfect support of the xili dev team. The reason was the preselected german language in wordpress’ wp-config.php.

Änderung in der wp-config.php

[von]define('WPLANG', 'de_DE');

[zu]  define('WPLANG', '');

After that i had to allow xili-language to change the default wp domain and another step was finished.

languages-expert-settings

The xili-language widgets changed now their languages as expected. But the original ones remained english. In the categories widget only the title was translated, but the categories itself didn’t.

For this you need a language file like the one for wordpress itself. This files are located in themes/zeesynergie/includes/lang for my theme.

I created a own local-de_DE.po file and inserted following text. A little later i read that it is normally done in a child theme.

msgid "Hardware"
msgstr "Hardware"

msgid "PC"
msgstr "PC"

msgid "Private"
msgstr "Privat"

msgid "Software"
msgstr "Software"

msgid "Linux"
msgstr "Linux"

msgid "VMware"
msgstr "VMware"

msgid "Recent Comments"
msgstr "Letzte Kommentare"

msgid "Recent Posts"
msgstr "Letzte Beiträge"

msgid "Search"
msgstr "Suchen"

msgid "Log out"
msgstr "Ausloggen"

msgid "Site Admin"
msgstr "Administration"

msgid "Login"
msgstr "Einloggen"

msgid "Entries"
msgstr "Beiträge"

msgid "Comments"
msgstr "Kommentare"

After that you can create the .mo file with following statement

msgfmt -o local-de_DE.mo local-de_DE.po

Now allmost everything will be translated. For the last to steps there is a additional plugin from xili, but i’m used to use a texteditor.

Only the search button and the two links to the feeds resists my translation effords. Before i fix this i wanted to add a menu to change languages manually.

You can add such a menu in the desgin settings under the section menu:

nav-menu

After that i stopped investing more time. There are some things that don’t work till now, but this isn’t very important to me.

Using STDIN/STDOUT streaming with rar instead of gzip/bzip2

I found it annoying for a long time, that i have only single threaded compress programs under linux when using compress from stdin.
Today i noticed a command line switch for rar which enables this for rar.

   -si[name]
     Read data from stdin (standard input), when creating
     an archive. Optional 'name' parameter allows to specify
     a file name of compressed stdin data in the created
     archive. If this parameter is missing, the name will be
     set to 'stdin'. This switch cannot be used with -v.

Now i can replace my MySQL Database Backup like this

[old]# mysqldump bigdb | bzip2 -c > bigdb.sql
[new]# mysqldump bigdb | rar a -sibigdb.sql bigdb.sql.rar

To uncompress to stdout the commands change like the following:
Das Entpacken nach stdout funktioniert dann wie folgt:

[old]# bzcat bigdb.sql.bz2 | mysql bigdb
[new]# rar -inul p bigsb.sql.rar bigdb.sql | mysql bigdb

VT-d / IOMMU with intel haswell and Z87 chipset

A sub project of Homeserver 2.0 was the virtualization of my home router.
I wanted to use pass-through of the additional nic for the external interface, so my host system can’t see any external traffic.

The steps should be easy, started virt-manager and followed these simple steps:
add-pci-1 add-pci-2

After a reboot of the vm i got a error: Connection reset by peer. The qemu process for the wasn’t started.

I got a more detailed error message with the virsh console:

server # virsh
virsh # start router-linz --console
error: Failed to start domain router-linz
error: internal error process exited while connecting to monitor: qemu-kvm: 
-device pci-assign,host=03:00.0,id=hostdev0,configfd=24,bus=pci.0,addr=0x5: 
No IOMMU found.  Unable to assign device "hostdev0"
qemu-kvm: -device pci-assign,host=03:00.0,id=hostdev0,configfd=24,bus=pci.0
,addr=0x5: Device 'kvm-pci-assign' could not be initialized
2013-10-01 17:44:52.566+0000: shutting down

Here it is: No IOMMU found. But i bought hardware that supports VT-d, a i5-4570 and a Z87 board. I rebooted my host system and checked the bios. VT-d was activated already.

Ok, I started googling and found a article about xen and HowTo activate VT-d. This article mentions special boot parameters you have to add to use this feature.

I’ve tested iommu=1 but haven’t got luck. Then i tried different combinations of the other kernel parameters in the article but none works.

Shortly before my surrender i found a mailing list post. In this post was explained to use intel_iommu=1.

Grub menu.lst edited, a short reboot of the host and then it worked.

Summary:

To activate VT-d under linux you have to add the kernel boot parameter intel_iommu=1. The VT-d/IOMMU support in the kernel alone is only half the battle.