RSS feed

PowerDNS 2.9.21-2 RPM's

January 17th, 2009 | Posted in Linux, PowerDNS | No Comments

The latest (dynamic) RPM’s for PowerDNS can be downloaded below. Please note, these RPM’s only include the MySQL and pipe backend!

 

pdns-2.9.21-2.x86_64.src.rpm

pdns-2.9.21-2.i386.src.rpm

pdns-2.9.21-2.x86_64.rpm

pdns-2.9.21-2.i386.rpm

 

Or you can download the GPL source tarball which includes the spec files for both x86_64 and i386

 

pdns-2.9.21-2.tar.gz



PTY allocation request failed on channel 0

January 16th, 2009 | Posted in Debian, Linux, Xen | No Comments

After creating a new VM on Debian Lenny, I got the following when trying to ssh into the DomU;

PTY allocation request failed on channel 0
stdin: is not a tty

Run the following to fix the issue;

apt-get install udev



Policyd Build Error

December 21st, 2008 | Posted in Debian, Linux | No Comments

policyd error Your OS doesnt support MSG_NOSIGNAL or SO_NOSIGPIPE

apt-get install g++ gcc

policyd.h:52:19: error: mysql.h: No such file or directory

apt-get install libmysqlclient15-dev


repair corrupted journal

December 21st, 2008 | Posted in Linux | No Comments

boot from cd – linux rescue

sh-3.1# umount /mnt/sysimage/data
sh-3.1# tune2fs -O ^has_journal /dev/sda6
sh-3.1# e2fsck -y /dev/sda6
sh-3.1# mount -t ext3 /dev/sda6 /mnt/sysimage/data
sh-3.1# rm -f /mnt/sysimage/data/.journal
sh-3.1# umount /mnt/sysimage/var
sh-3.1# tune2fs -j /dev/sda6
sh-3.1# exit


umount: device is busy

December 17th, 2008 | Posted in Linux | No Comments

To see what processes are accessing the disk partition you can use either lsof or fuser.

lsof /tmp
mysqld   13103    mysql    6u   REG  8,6     0     12 /tmp/ibisfIna (deleted)
mysqld   13103    mysql    7u   REG  8,6   504     13 /tmp/ibjWhwnX (deleted)
mysqld   13103    mysql    8u   REG  8,6     0     14 /tmp/ibi5qTnK (deleted)
mysqld   13103    mysql   12u   REG  8,6     0     15 /tmp/ibhsV78x (deleted)
java     18852  tomcat4  mem    REG  8,6 16384  96580 /tmp/hsperfdata_tomcat4/18852

# fuser -m /dev/sda6
/dev/sda6:           13103 18852

# ps aux | grep 13103
mysql  13103  2.7  1.6 143892 34252 ? Sl  Oct11 2692:12 /usr/libexec/mysqld

# ps aux | grep 18852
tomcat4 18852  0.0  1.8 283192 37928 ? Sl  Dec16 1:28 /usr/java/j2sdk1.4.2/bin/java

You can then gracefully shutdown the daemon using the disk partion and unmount it.


3ware tw_cli

December 16th, 2008 | Posted in Linux | No Comments

7000 and 8000 series 3ware Escaladeā„¢ ATA RAID controllers manual

http://www.3ware.com/support/UserDocs/CLI_UG.pdf

http://www-d0.fnal.gov/~melnit/tw_cli.8.html



PowerDNS with Geo Backend

December 6th, 2008 | Posted in Linux, PowerDNS | 1 Comment

A short guide on how to setup powerdns with the geo and mysql backends to redirect visitors to servers closer to their geographic location.

So how does it work?

We delegate geo.www.domain.com to our powerdns servers that run the geo backend. The backend looks up the IP address of the user’s resolver in a data structure obtained from zz.countries.nerd.dk.

This returns the ISO country code, which is then fed through a map file to determine what CNAME to respond with. Our www.domain.com record is actually just a CNAME to www.geo.domain.com which is driven by the geo backend. Our map contains the following:

$RECORD www
$ORIGIN domain.com

After the above each ISO country code is listed and essentially where you want to send them, for example:

0 pool
# Andorra
20 eu
# United Arab Emirates
784 eu
# Afghanistan
4 eu
# Antigua and Barbuda
28 eu
# Angola
24 za

0 pool is a round robin DNS pool of all our servers located across the globe.

The rest, as you can see, is redirected to either eu or za. Note, the file is HUGE and only a few entries has been pasted here.

Our powerdns configuration looks like this:

geo-zone=geo.domain.com
geo-soa-values=ns0.domain.com,hostmaster@domain.com
geo-ns-records=ns0.domain.com,ns1.domain.com
geo-ip-map-zonefile=/home/geo/zz.countries.nerd.dk.rbldnsd
geo-maps=/etc/powerdns/geo-maps
launch=geo,gmysql

The zz.countries.nerd.dk.rbldnsd file countains all countries and their ISO country numbers. More information and how to get a copy of this (rsync once a week) can be obtained from http://countries.nerd.dk/more.html.

Our normal DNS domains and records are stored in MySQL, more information regarding that can be found in the powerdns documentation.

Here are some DNS query examples:

dig @ns0.coretanium.net nosuchdomainhere.com A

;www.nosuchdomainhere.com. IN A

www.nosuchdomainhere.com. 604800 IN CNAME www.geo.nosuchdomainhere.com.
www.geo.nosuchdomainhere.com. 3600 IN CNAME eu.nosuchdomainhere.com.
eu.nosuchdomainhere.com. 86400 IN A 87.194.37.132

As you can see, www.nosuchdomainhere.com is a CNAME to www.geo.nosuchdomainhere.com, from there it passes through the geo backend and it says your coming from lets say Germany, our geo mapping file then says country code 276 needs to go to eu(.nosuchdomainhere.com) and eu.nosuchdomainhere.com resolves to 127.0.0.1.

And that’s it. A brief explanation on how to use powerdns with the geo backend.



Sending mail from Perl

December 3rd, 2008 | Posted in Linux, Perl | No Comments

I am using this as a skeleton in various scripts where I need to be notified of errors or successful runs…

#!/usr/bin/perl

    open(MAIL,"|/usr/lib/sendmail -t");

     print MAIL "To: you\@domain.com\n";
     print MAIL "From: name \n";
     print MAIL "Subject: your subject\n\n";
     print MAIL "\nnotification\n";

    close (MAIL);


Speed up your site by caching

December 2nd, 2008 | Posted in Linux | No Comments

Implementing caching on high traffic websites will save you loads of bandwidth and drastically speed up your site loading time for visitors. By using apache modules mod_expires and mod_header you will be able to control exactly what is cached, how long it’s cached for and how proxy servers should behave around your websites.

All static content which is not modified often like CSS documents, images, javascript and HTML can be optimised for faster loading time by telling your visitors and caching proxy servers to cache the files for a certain period of time.

When a visitor arrives at your site the browser will cache the HTML, CSS and images. As soon as the user leaves your site and returns a couple of hours later, the browser will send a If-Modified-Since conditional GET request for every cached item to check whether the file has been updated and if it needs to update the local cache. If the content has not been modified the server will return a 304 (not modified) response to the browser, if it has been modified… then it sends a fresh copy of the content and your browser will cache this new fresh copy.

By using the caching methods described in this document you will be able to specify that certain files or file types be cached for x amount of time which causes your visitors browsers to not send the If-Modified-Since conditional GET request until the set cache time has expired.

Timing Guide

300 5 Minutes
3600 1 Hour
86400 1 Day
604800 1 Week
2419200 1 Month

mod_expires

ExpiresActive On
ExpiresDefault A300
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000
ExpiresByType image/jpeg A604800
ExpiresByType image/gif A604800
ExpiresByType image/png A604800
ExpiresByType text/plain A604800
ExpiresByType application/x-shockwave-flash A604800
ExpiresByType video/x-flv A604800
ExpiresByType application/pdf A604800
ExpiresByType text/html A300

mod_headers

# One year

   Header set Cache-Control "max-age=2592000"


# One week

   Header set Cache-Control "max-age=604800"


# Never cache

   Header set Expires "Thu, 01 Dec 2000 23:00:00 GMT"
   Header set Cache-Control "no-store, no-cache, must-revalidate"
   Header set Pragma "no-cache"

Commonly used .htaccess combining both mod_expires and mod_headers

# Enable and set default to 0
ExpiresActive On
ExpiresDefault A0

# 1 Year caching

  ExpiresDefault A29030400
  Header append Cache-Control "public"


# 1 Week caching

  ExpiresDefault A604800
  Header append Cache-Control "public, proxy-revalidate"


# 2 Hour caching

  ExpiresDefault A7200
  Header append Cache-Control "private, proxy-revalidate, must-revalidate"



  ExpiresDefault A0
  Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform"
  Header set Pragma "no-cache"

Two examples – one with caching and one without

HTTP/1.1 200 OK
Date: Tue, 02 Dec 2008 23:45:41 GMT
Server: Apache/1.3.34
Last-Modified: Tue, 19 Aug 2008 21:01:23 GMT
ETag: “18c7e5-992-48ab34a3″
Accept-Ranges: bytes
Content-Length: 2450
Connection: close
Content-Type: image/gif

HTTP/1.1 200 OK
Date: Tue, 02 Dec 2008 23:46:50 GMT
Server: Apache/1.3.34
Cache-Control: max-age=604800
Expires: Tue, 09 Dec 2008 23:46:50 GMT
Last-Modified: Tue, 19 Aug 2008 21:01:23 GMT
ETag: “18c7e5-992-48ab34a3″
Accept-Ranges: bytes
Content-Length: 2450
Connection: close
Content-Type: image/gif

As you can see there are a lot of possibilities in what to cache and for how long you want it cached. I suggest further reading of each apache modules documentation to fully grasp it’s capabilities.



sed inline replace/delete

December 2nd, 2008 | Posted in Linux | No Comments

sed -i 's/foo/bar/' file(s) or *

or

sed -i '/foo/d' file(s) or *

or

find /path/to/files -type f -name myfile1 -exec sed -i 's/foo/bar/' {} \;

or

find /path/to/files -type f -name myfile1  | xargs sed -i 's/foo/bar/g'



Categories