Power off problem on Lenovo SL500 with OpenSuSE 12.1

A couple of days ago I installed OpenSuSE 12.1 on my laptop after running OpenSuSE 11.4 for quite a while. Upgradeing was no big deal. OpenSuSE has a nice tutorial on that.

The new version finally supports the integrated mobile modem out of the box which is very nice. The only annoyance I got is that the computer does not power off or reboot properly. The system just halts after the last step. I could not find any information on this problem on the net.

Do you happen to know how to fix it or at least how to debug it?


Execute command on every boot

You want to execute a command on every boot but do not want to create an init script? Well, if your *nix system supports cron jobs which is very likely it is your lucky day.

Just open the cron file for the user who in whose name the command is supposed to run.

crontab -e

Add the following line to the open cron file and obviously replace YOUR COMMAND with whatever should be run on start-up.

@reboot YOUR COMMAND

Save the changes and now on every boot your command is executed once. Simple as that!


Memcache is not cacheing

So you are using memcached to speed up your system. Than suddenly at some point you notice memcache is not helping anymore but is does not cache the part that has the worst impact on your system.

That´s what just has happened to me. Why is Memcache not cacheing I asked myself. Well, the default and highly recommend slabs size is 1 MB. Anything above just is not cached. Setting that limit higher with -I Xm (X being an integer) results in a warning which sounds really bad:

Starting memcached WARNING: Setting item max size above 1MB is not recommended!
Raising this limit increases the minimum memory requirements and will decrease your memory efficiency.

Hmm, not so good. Luckily I was able to downsize that particular item so that memcache stores it again.

I am still wondering if serving content from harddisk instead of RAM via memcached could be a good idea. I gotta try it one of these days. What do you think?


Use varnishlog to find hosts which cause most hits

If your Varnish powered server is under constant load and you are wondering who causes that varnishlog is a helpful tool.

Start off by logging IP addresses for a while.

1
varnishlog -c -i RxHeader -I X-Forwarded-For > varnish.log

After you have collected enough information use the following line to find out which IP caused the most hits on your varnish.

1
cat varnish.log | cut -d ' ' -f 12 | sort | uniq -c | sort -n

Query the ripe database to find information on the IP addresses.


Library and WordPress plugin for Textbroker

Textbroker Wordpress Plugin Order accepted 300x164 Library and WordPress plugin for Textbroker I created a library to access the API of the Textbroker marketplace more easily. The library is Open Source with a BSD licence. Feel free to grab a copy and play with it. Feedback is appreciated.

Based on that work I developed the Textbroker WordPress plug-in which makes it very easy and comfortable to place new orders and publish articles through your own WordPress installation.


Useful shell commands: last

Today I will start a new series for linux/*nix newbies called Useful shell commands. Every now and then I will write about one of the powerful commands you’ll find on your shell. I will start the series with a command called last.

# last

Calling last on your commandline gives you a list of logins. You will see who is still logged in and who was logged in before from what adress.

You can shorten the list of results with last -n XX. XX being the number of results you want to have displayed, e.g. last -n 5 for 5 lines.

# last reboot

Calling last reboot lists the reboots since the log file which tracks all logins was created.

The manual page for last – man last – will show you more parameters.


High available NFS4 server with drbd 0.8, pacemaker 1.0, heartbeat, openais on OpenSUSE 11.1

For my podcast project I got five new root servers which are all connected internally through a switch. Two of the servers are connected directly over a crossover cable. Those two servers have 3 NICs, the other 2 servers have 2 NICs.

I share the website’s HTML, images and other resources through the NFS server to all five servers. All servers work as webservers with nginx and PHP-fpm. Each server also runs one more specific service: database master, solr master, cron jobs / crawler processes, Varnish / HAproxy.

The two directly connected servers share the static website resources over drbd. Pacemaker, heartbeat and openais secure the high availability of my NFS4 server. Setting this up took quiet a bit of fiddeling as there are how-tos for so many different (and outdated) versions are floating around the internet.


php-fpm runlevel start script for OpenSuSE 11.1

Nowadays OpenSUSE comes with almost all packages I need to run a fast and reliable webserver. As I have written before I use nginx and php-fpm for our podcast service.

You can get up-to-date packages of nginx through OpenSuSE’s build service. I have not yet found a RPM package of php-fpm though. Therefore I compile it myself. This works well and I have the advantage that I can customize by PHP package.

But there is also one disadvantage. There is no system runlevel script available this way. So you cannot make use of the rc stuff on OpenSuSE and start PHP at boot time. As I have quiet a few machines to administer I decided to write my own runlevel script to start php-fpm.

Looking closer into the stuff that is already delivered with the php-fpm package is a powerful start script. I took it as the basis of my script. I had to modify it only in a few places. Big thanks to the author(s)!

It will take a few easy steps to get php-fpm running after booting.

  1. Download my modified php-fpm script to your server’s runlevel directory (/etc/rc.d).
  2. Rename the file by removing the file extension (.txt)
  3. Give your superuser (root) rights to execute it.
  4. Open the file php-fpm in your favorite editor (Vim, emacs, joe, …).
  5. Modify the three lines (php_fpm_BIN=, php_fpm_CONF=, php_fpm_PID=) on top to match your installation directory of php-fpm.
  6. Save and close the file.
  7. Start yast with yast runlevel and switch to expert mode with Alt+x
  8. Activate php-fpm for runlevels 3 and 5 (or whatever suits you). Save your changes with Alt+o. That’s it!

Now your php-fpm installation starts on boot. If you ever have to reboot your machine you do not have to think about starting php-fpm manually as the system does it for you.

Let me know if this was helpful for you, if it works and if you have any questions!


How to find out user id on linux system

For a mount command I needed to find out what user id my user account had. There are several ways to find out. As root you could look into the passwd file (most likely /etc/passwd) or on OpenSuSE use the Yast user module. But I was looking for a way to find out my user id with my ordinary user account. The command I was looking for is id. Just open up a shell (konsole on KDE4) with your active user, type id and you get all the information about your user including groups and their ids. If you just want to know the user’s id, e.g. for a shell script use

id -u USERNAME

and you get back just the id of the user. Simple as that!


System upgrade openSUSE 11.0 to openSUSE 11.1 with zypper

I had to set up a server. The hoster offers openSUSE 11.0 at the moment but no openSUSE 11.1 yet. As I like to go with the latest and greatest I decided to upgrade the system to openSUSE 11.1 after using the hoster’s installation image for openSUSE 11.0. I searched on the web how a system upgrade should be done this time. (It seems to differ all the time.) I found a zypper command chain. Change the installation reposotories in /etc/zypp/repos.d to the new version and type:

zypper refresh
zypper dist-upgrade

I did excatly that. It did refresh a few packages but as I guessed immediately not enough. I tried over. It did not help. Here is the solution. Delete all subdirectories in /var/cache/zypper and execute the commands above again.