Categories
PHP Ubuntu

Adding SSH support to PHP on Ubuntu

I have previously written a post on how to add SSH support to PHP, but that post is old, and it has now become even easier to get it up and running. And therefore making it much easier to auto upgrade WordPress via SSH. (automatic, yay!)

As root, do the following:

1: apt-get install libssh2-1-dev libssh2-php

2: Check that is installed: php -m |grep ssh2

3: Restart apache: service apache2 restart

And you should now have SSH support in PHP.

Categories
Linux Ubuntu

Linux: Finding motherboard model

Just had to locate the name of the motherboard on one of my servers, here comes dmidecode to the rescue! ūüôā

To list all info it can find, simply run dmidecode. I executed the following command to find my motherboard model:

thu@dom0:~$ sudo dmidecode|grep "Product Name: "
Product Name: P5Q-E   
Product Name: P5Q-E  
thu@dom0:~$
Categories
Hardware Linux Ubuntu

Tuning Ubuntu mdadm RAID5/6

If you are using mdadm RAID 5 or 6 with Ubuntu, you might notice that the performance is not all uber all the time. Reason for this is that the default tuning settings for Ubuntu is set to rather motdest values. These can lucikly easily be tuned. I will in this article increase some settings until my read and write performance against my RAID 6 has been improved a lot.

My setup:
CPU: Intel(R) Core(TM)2 Quad CPU Q9300
RAM: 16G
Drives: 11 drives in one RAID6 with drives split over two cheap PCI-E x4 controllers and the motherboard`s internal controller.

I will test my system between each tuning by using dd for read and write testing. Since i have a nice amount of RAM available, i will use a test file of 36G. (bs=16k) Between each test (both read and write), i clear the OS disk cache with the command:

sync;echo 3 > /proc/sys/vm/drop_caches

Tuning stripe_cache_size

stripe_cache_size affects RAM used by mdadm to writing of data. Ubuntu`s default value is 256, you can verify your value by doing:

cat /sys/block/md0/md/stripe_cache_size

And changing it with:

echo *number* > /sys/block/md0/md/stripe_cache_size

Test results with stripe_cache_size=256
РWrite performance: 174 MB/s

Not to good, i therefore increased it some levels, each level with result is described below:

Test results with stripe_cache_size=512
РWrite performance: 212 MB/s

Test results with stripe_cache_size=1024
РWrite performance: 237 MB/s

Test results with stripe_cache_size=2048
РWrite performance: 254 MB/s

Test results with stripe_cache_size=4096
РWrite performance: 295 MB/s

Test results with stripe_cache_size=8192
РWrite performance: 362 MB/s

Test results with stripe_cache_size=16384
РWrite performance: 293 MB/s

Test results with stripe_cache_size=32768
РWrite performance: 326 MB/s

So, going from 256 to 32K ~doubled my write performance, not bad! ūüôā

Tuning Read Ahead

Time to change a bit on read ahead, which should impact read performance.¬†Default read ahead value is “1536”, and you can change it with the command:

blockdev --setra *number* /dev/md0

Test results with Read Ahead @ 1536
РRead performance: 717 MB/s

Test results with Read Ahead @ 4096
РRead performance: 746 MB/s

Test results with Read Ahead @ 32768
РRead performance: 731 MB/s

Test results with Read Ahead @ 262144
РRead performance: 697 MB/s

Test results with Read Ahead @ 524288
РRead performance: 630 MB/s

So oposite of the write performance tuning, this actually became worse for most of the settings. So 4096 is the best for my system.

In conclution

This is just an example on how different settings can have rather large impact on a system, both for the better and for the worse. If you are going to tune your system you have to test different setting for yourself and see what works best for your setup. ¬†Higher values does not automaticly mean better results. I ended up with “stripe_cache_size=8192” and “Read Ahead @ 4096” for my system.

If you want to make sure that your changes is saved when rebooting the system, remember to add these commands (with your values) in /etc/rc.local.

Categories
Ubuntu

Ubuntu: apt-get update gives 404 Not Found error

If you recieve “404 Not found” during a apt-get update / apt-get upgrade, the problem can be one of two things:

1)  Your Ubuntu installation is no longer supported.
You can check this by comparing the output of the command:
against the list of Ubuntu releases here:
https://wiki.ubuntu.com/Releases (Notice “End of Life” date)

If your release has reached end of life, you can do upgrade to a new release by following the guide here:
http://www.ubuntu.com/desktop/get-ubuntu/upgrade

2) Temporary problems
The mirror(s) you are using can have temporary problems, in such case you should simply try again later.

Categories
Linux Ubuntu

pwrstat: Daemon service is not found.

When trying to use the pwrstat program you may get the error message “Daemon service is not found”. Here is a simple check list to follow in order to fix it:

1) Make sure that pwrstatd is running
2) Open /etc/pwrstatd.conf, and make sure that “prohibit-client-access” is set to no.

The last one has fooled me, i cannot remember changing it, and yet it was set to off on my server. So after i corrected the setting and restarted the daemon, my pwrstat finally gave some sane data again:

root@bais:/var/log# pwrstat -status

The UPS information shows as following:

Properties:
Model Name………………. UPS VALUE
Rating Voltage…………… 230 V
Rating Power…………….. 480 Watt

Current UPS status:
State ………………….. Normal
Power Supply by …………. Utility Power
Utility Voltage …………. 230 V
Output Voltage…………… 230 V
Battery Capacity ………… 100 %
Load …………………… 41 %
Remaining Runtime ……….. 10 min.
Line Interaction…………. None