EZ Linux Admin random header image

When asking about a networking issue, get these details from the server

April 5th, 2010 by EZ linux · No Comments

Kernal version

uname -a

Nic / Lan driver version

dmesg | grep r8169

Internet controller

lspci -nn | grep Ethernet

Details on etho nic card

sudo ethtool eth0

Module size

lsmod | grep r8169

Module versions

cat /proc/modules | grep r8169

Don’t worry all these commands are safe and just for reporting.


→ No Comments Tags: Cheat Sheets · Hardware · Linux Commands · Linux Tricks


Mod_cband the new Mod_Bandwidth

March 29th, 2010 by EZ linux · 1 Comment

I spent hours trying to get mod_bandwidth to work simply because I have used it for years. But now with Apache 2.0 times have changed and there is a better option for Linux and it’s free. The new mod to regulate bandwidth and more is called Mod_cband I’m not sure what cband means but I can guess channel bandwidth.

Here is how to get it set up with Cantos 5.3 easily.

I wanted to host for my brother the latest WoW patch, but at a hefty 450 MB, I didn’t want to blow all my bandwidth on it either. I am setting a limit for the download at 2.5 TB of bandwidth, and limiting it to 5mbs at 10 connections a second. My hardware is RHEL 4 running on a P4 with Plesk 8. In the guide to follow, you’ll see a few steps that wouldn’t be needed on a non-plesk system. To setup bandwidth limiting for the host, we need to be able to compile a new apache module against our system, and then install and configure it.

Step 1: The prereqs

First I needed to setup a yum repository for FC4. This can be accomplished by issuing an RPM command:

rpm -ivh http://rpm.livna.org/livna-release-4.rpm

Now that you can access the RPM packages, we need to install http-devel using yum:

yum install httpd-devel

If all went well, we can now extract, compile, and install mod_cband for apache:

cd /tmp
wget http://cband.linux.pl/download/mod-cband-0.9.7.4.tgz
tar xzvf mod-cband-0.9.7.4.tgz
cd mod-cband-0.9.7.4
./configure
make
make install

If all went well, restart apache with the new module (you can check httpd.conf to make sure the module is going to be loaded):

/etc/init.d/httpd restart

Step 2: Configuration

Here’s where the Plesk part gets annoying. We can’t just edit our vhosts file, because plesk writes over it all the time. Instead, we edit a /home/httpd/vhosts/*/subdomains/*/conf/vhost.conf file. Mine looks like this:

CBandScoreboard /var/www/scoreboard
CBandPeriod 4W
CBandDefaultExceededCode 509
CBandLimit 2500G
CBandSpeed 5000 5 10
CBandRemoteSpeed 1600 3 1
<Location /cband-status>
SetHandler cband-status
</Location>
<Location /cband-status-me>
SetHandler cband-status-me
</Location>

What does this mean? (1) Use /var/www/scoreboard to log usage and limits (2) Reset the limit count every 4 weeks (3) Throw a 509 error when the limits are exceeded (4) Allow 2.5TB per period (5) Allow 5mbs with 5 requests a second and 10 connections at a time oeverall (6) Allow 1.6mbs with 3 requests a second and 1 connections at a time per client (7) Allow us to access a page at /cband-status to view the status.

You’ll also need to issue commands to make the scoreboard directory, and to allow apache to own it:

mkdir /var/www/scoreboard
chown apache:apache /var/www/scoreboard

Finally, Plesk requires you to inform it of your work:

/usr/local/psa/admin/sbin/websrvmng -u –vhost-name=yourdomain.com

If you restart Apache now, everything should work!

/etc/init.d/httpd restart

Step 3: An Example

You can take a peek at my status page right now if you’d like. It looks a bit like this:

A quick note, I simply just added:

CBandPeriod 4W
CBandLimit 10000G
CBandSpeed 12000 40 80
CBandRemoteSpeed 6400 12 4

Now this set the limit to about 12 megs (MPS) a second which is a lot, but this customer is paying $250 a month to cover it. Most websites should max at about 5 MPS. I left out the other options because I didn’t need them and it’s less load on the server without them.

→ 1 Comment Tags: Cheat Sheets · Cpanel and WHM · Linux Security · Linux Software / Scripts · Linux Tricks


Raise apache 2.0 max clients hard limit in cpanel

March 23rd, 2010 by EZ linux · No Comments

Apache 2.0 makes raising the max client from the default 256 hard limit a little harder now. If you have cpanel then it’s even a little harder or I should you just need to know what to do, figuring it out is a shot in the dark.

One main difference is you have raise the server limit if you want to raise the max client limit.

The easiest way to do this is to go to:

  1. Web Hosting Manager
  2. Then click Apache Configuration
  3. Then click Include Editor
  4. Then click the apache version under the pre-main include
  5. Then add this to the input section:

ServerLimit 512

StartServers 32
MinSpareServers 5
MaxSpareServers 20
MaxClients 512
MaxRequestsPerChild 1000

Then save and it will ask to restart apache you click yes there.

Now your apache limit is set to 512 and cpanel will not mess with it.

Here is the explanation for each derivative in the above code:

MaxClients:

The MaxClients sets the limit on maximum simultaneous requests that can be supported by the server; no more than this number of child processes are spawned. It shouldn’t be set too low; otherwise, an ever-increasing number of connections are deferred to the queue and eventually time-out while the server resources are left unused. Setting this too high, on the other hand, will cause the server to start swapping which will cause the response time to degrade drastically. The appropriate value for MaxClients can be calculated as:

If there are more concurrent users than MaxClients, the requests will be queued up to a number based on ListenBacklog directive. Increase ServerLimit to set MaxClients above 256.

MinSpareServers, MaxSpareServers, and StartServers:

MaxSpareServers and MinSpareServers determine how many child processes to keep active while waiting for requests. If the MinSpareServers is too low and a bunch of requests come in, Apache will have to spawn additional child processes to serve the requests. Creating child processes is relatively expensive. If the server is busy creating child processes, it won’t be able to serve the client requests immediately. MaxSpareServers shouldn’t be set too high: too many child processes will consume resources unnecessarily.

Tune MinSpareServers and MaxSpareServers so that Apache need not spawn more than 4 child processes per second (Apache can spawn a maximum of 32 child processes per second). When more than 4 children are spawned per second, a message will be logged in the ErrorLog.

The StartServers directive sets the number of child server processes created on startup. Apache will continue creating child processes until the MinSpareServers setting is reached. This doesn’t have much effect on performance if the server isn’t restarted frequently. If there are lot of requests and Apache is restarted frequently, set this to a relatively high value.

MaxRequestsPerChild:

The MaxRequestsPerChild directive sets the limit on the number of requests that an individual child server process will handle. After MaxRequestsPerChild requests, the child process will die. It’s set to 0 by default, the child process will never expire. It is appropriate to set this to a value of few thousands. This can help prevent memory leakage, since the process dies after serving a certain number of requests. Don’t set this too low, since creating new processes does have overhead.

→ No Comments Tags: Cpanel and WHM · Linux Software / Scripts · Linux Tricks


Repair DNS scripts and tips

March 19th, 2010 by EZ linux · No Comments

Fixing DNS is a tricky thing, with cpanel there is a couple steps to try first.

DNS failed you are not sure why, try this first:

/scripts/cleandns
/scripts/rebuildnamedconf

Still not working, try this:

/scripts/rebuilddnsconfig
/scripts/fixdns

Basically DNS has about 5 files that need to all be in sync for named DNS to run.

I highly recommend running three servers with DNS so you have back ups if one servers fails. In this case you just transfer over the dns files and restart. Here is a list of the DNS files that need to be transferred.

named.conf.cache

named.conf.zonedir.cache

named.conf

named.conf,v

named.conf_back

named.conf.fixrndc

named.conf.prefixrndc

named.conf.rpmsave

→ No Comments Tags: Cpanel and WHM · Linux Software / Scripts


How to do a search and replace over multiple files

March 18th, 2010 by EZ linux · No Comments

You could also use find and sed, but I find that this little line of perl works nicely.
perl -pi -w -e ’s/search/replace/g;’ *.php

-e means execute the following line of code.
-i means edit in-place
-w write warnings
-p loop

Example I had the following style sheet in a section:
<link rel=”stylesheet” type=”text/css” href=”../includes/style.css”>

and I wanted the following instead:
<link rel=”stylesheet” type=”text/css” href=”admin.css”>

As each expression is a regular expression you’ve got to escape the special characters such as forward slash and .
\.\.\/includes\/style\.css

So the final line of code ends up as
perl -pi -w -e ’s/\.\.\/includes\/style\.css/admin\.css/g;’ *.php

→ No Comments Tags: Cheat Sheets · Linux Commands


You don’t need to ‘know’ Linux to use Linux

March 18th, 2010 by EZ linux · No Comments

Lately, I’ve been noticing stories about how to use Linux you need to know half-a-hundred Linux shell commands and the like. Ah, what century are you from? Today, if you can see a window and handle a mouse, you’re ready to use Linux.

And no, I’m not talking about how we’re all already using Linux in devices like the TiVo or the Droid smartphone and through Linux-powered Web sites like Google. I’m talking about using Linux on the desktop.

There is nothing — I repeat, nothing — that requires any special knowledge to use Linux on the desktop today. If you’ve already mastered Windows XP, you’ll have little more trouble moving to a Linux desktop like Red Hat’s Fedora 12; Novell’s openSUSE 11.2; or Canonical’s Ubuntu 9.10 than you would in switching over to Windows 7.

I’m not saying using Linux isn’t different from running Windows. It is. For example, you’ll need special software like Crossover Linux to run Windows-specific software.

The interfaces also aren’t the same — but then, Windows 7 and Vista’s interfaces aren’t the same as XP’s, and Mac OS X’s Aqua interface doesn’t look anything like the others. Besides, can any other operating system besides Linux let you set up the interface so that it duplicates XP’s look and feel? I think not!

What you don’t need to use desktop Linux is to learn dozens of obscure Linux shell (aka command line) programs to get work done. Neither do you need to know how to edit configuration files by hand to get Linux set up properly.

Sure, it can help to know how to use the Unix/Linux shell. I was writing shell (awk, sed, and grep) scripts to get work done in Unix, and later Linux, before many of you played your first game of solitaire on Windows 1.0. My point is, for ordinary, everyday use, you don’t need to know anymore about those things than you need to know how to edit Windows’ registry to run Windows.

I use desktop Linux every day, and I’m a Linux expert. Do you know how often I turn to a terminal to get to a shell to run commands? Maybe once a month, if that.

Between the two major Linux desktop interfaces, KDE and GNOME, Linux has you covered. For applications, many of the most popular applications, such as Firefox and OpenOffice, run just the same on Linux as they do on Windows. For other end-user programs, Linux programs such as Evolution for e-mail and Pidgin for IM are just as good, if not better, than their Windows equivalents. And again, you don’t need to know anything special to use them.

Installing new software on Linux isn’t any trouble either. Better still, major Linux distributors like Ubuntu are continuing to make installing Linux software easier than ever with programs like Ubuntu Software Center.

Don’t get me wrong: if you’re running a Linux server, you really need to know Linux’s technical guts. But you know what? If you’re running a Windows server, you also need to know Window’s version of the shell, the PowerShell.

No matter what desktop operating system you’re running, if you really want control over exactly what it does, you need to know how to manage its command line tools. But for day-to-day use, Linux’s graphical interfaces makes it just as easy to use as Windows or Mac OS X. Pretending that you need to be some kind of computer wizard to run Linux on the desktop today is just downright silly.

→ No Comments Tags: About Linux · Linux News · Linux Operating Systems


Getting a md5sum error when tranferring a cpanel account?

March 3rd, 2010 by EZ linux · No Comments

This usually means you need to upgrade Perl on the server. Here is a example of a md5sum error.

The remote server didn’t report a correct md5sum of the archive. Please ensure you selected the correct type of remote server.

To fix upgrade Perl as shown here:

http://www.ezlinuxadmin.com/2009/08/upgrading-perl-on-cpanel/

→ No Comments Tags: Cpanel and WHM · Linux Commands · Linux Software / Scripts


My new favorite rsync command

March 3rd, 2010 by EZ linux · No Comments

rsync -vae ssh 12.123.123.123:/home/dwhsbackup/daily/username/ /backup/cpbackup/daily2/username/ –bwlimit=10000 –exclude-from ‘/root/exclude.txt’

→ No Comments Tags: Linux Commands · Linux Software / Scripts · Linux Tricks


Calm down rsync if it overloads your IO memory or CPU

March 3rd, 2010 by EZ linux · No Comments

The trick is to limit I/O bandwidth for rsync.

The –bwlimit option limit I/O bandwidth. You need to set bandwidth using KBytes per second. For example, limit I/O bandwidth to 10000KB/s (9.7MB/s), enter:

rsync –delete –numeric-ids –relative –delete-excluded –bwlimit=10000 /path/to/source /path/to/dest/?

10 megs a second is plenty of speed and will keep the server running smoothly when your grabbing allot of files off of it.

→ No Comments Tags: Cheat Sheets · Linux Commands · Linux Security · Linux Software / Scripts · Linux Tricks


rsync running slow?

March 3rd, 2010 by EZ linux · No Comments

Today I was transferring files through rsync it was taking forever, my guess was the new server or old server was out of memory so I killed some procs and even rebooting the server but still it was crawling. So I thought I would think out of the box and after a couple trial and errors I tried a nic reboot and wow it was super fast from there.

/etc/init.d/network restart

I’m still not sure how the nic got blogged up but this worked like charm.

Keep in mind this is a temp fix, what you need to do is both your nic card going by adding another IP via cpanel and via the setup tool access from the root of the server. Try to separate the IP traffic that best that you can between both nic cards on the server.

→ No Comments Tags: Hardware · Linux Commands · Linux Tricks