The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 2]

The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 2]

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 04/05/2009

This tutorial shows how to set up a CentOS 5.3 server (x86_64) that offers all services needed by ISPs and web hosters: Apache web server (SSL-capable), Postfix mail server with SMTP-AUTH and TLS, BIND DNS server, Proftpd FTP server, MySQL server, Dovecot POP3/IMAP, Quota, Firewall, etc. This tutorial is written for the 64-bit version of CentOS 5.3, but should apply to the 32-bit version with very little modifications as well. In the end you should have a system that works reliably, and if you like you can install the free webhosting control panel ISPConfig (i.e., ISPConfig runs on it out of the box).

I will use the following software:

  • Web Server: Apache 2.2 with PHP 5.1.6
  • Database Server: MySQL 5.0
  • Mail Server: Postfix
  • DNS Server: BIND9 (chrooted)
  • FTP Server: Proftpd
  • POP3/IMAP server: Dovecot
  • Webalizer for web site statistics

Please note that this setup does not work for ISPConfig 3! It is valid for ISPConfig 2 only!

I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

 

1 Requirements

To install such a system you will need the following:

  • Download the CentOS 5.3 DVD or the six CentOS 5.3 CDs from a mirror next to you (the list of mirrors can be found here: http://isoredirect.centos.org/centos/5/isos/x86_64/).
  • a fast Internet connection.

 

2 Preliminary Note

In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100 and the gateway 192.168.0.1. These settings might differ for you, so you have to replace them where appropriate.

 

3 Install The Base System

Boot from your first CentOS 5.3 CD (CD 1) or the CentOS 5.3 DVD. Press <ENTER> at the boot prompt:

It can take a long time to test the installation media so we skip this test here:

The welcome screen of the CentOS installer appears. Click on Next:

Choose your language next:

Select your keyboard layout:

I’m installing CentOS 5.3 on a fresh system, so I answer Yes to the question Would you like to initialize this drive, erasing ALL DATA?

Now we must select a partitioning scheme for our installation. For simplicity’s sake I select Remove linux partitions on selected drives and create default layout. This will result in a small /boot and a large / partition as well as a swap partition. Of course, you’re free to partition your hard drive however you like it. Then I hit Next:

Answer the following question (Are you sure you want to do this?) with Yes:

On to the network settings. The default setting here is to configure the network interfaces with DHCP, but we are installing a server, so static IP addresses are not a bad idea… Click on the Edit button at the top right.

In the window that pops up uncheck Use dynamic IP configuration (DHCP) and Enable IPv6 support and give your network card a static IP address (in this tutorial I’m using the IP address 192.168.0.100 for demonstration purposes) and a suitable netmask (e.g. 255.255.255.0; if you are not sure about the right values, http://www.subnetmask.info might help you):

Set the hostname manually, e.g. server1.example.com, and enter a gateway (e.g. 192.168.0.1) and up to two DNS servers (e.g. 213.191.92.86 and 145.253.2.75):

Choose your time zone:

Give root a password:

  • The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 2] – Page 2
  • The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 2] – Page 3
  • The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 2] – Page 4
  • The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 2] – Page 5
  • The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 2] – Page 6
  • The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 2] – Page 7

next The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 2] – Page 2
Copyright © 2009 Falko Timme
All Rights Reserved.

Related Tutorials

How To Install Openbravo ERP On CentOS 5.2

How To Install Openbravo ERP On CentOS 5.2

This howto describes how to set up Openbravo ERP (enterprise management system) on CentOS 5.2 using PostgreSQL 8.3. Openbravo is an open source ERP solution designed specifically for the SME (small to midsize firm). Developed in a web based environment, it includes many robust functionalities which are considered part of the extended ERP: procurement and warehouse management, project and service management, production management, and financial management.

This is a follow up of Falko`s Wonderful “How To Install Openbravo ERP On Ubuntu 8.10″.

I do not issue any guarantee that this will work for you!

 

 1. Preliminary Note

 This howto assumes you have freshly installed CentOS system along with the following.

 a) Hostname:- server1.example.com

 b) Server IP:- 192.168.1.1

 You must have root privileges to run most of the actions described in this Howto.

 

2. Setup DNS

yum install bind bind-utils

#nano /etc/named.conf

options
{
    directory 		"/var/named";
    dump-file 		"data/cache_dump.db";
    statistics-file 	"data/named_stats.txt";
    memstatistics-file 	"data/named_mem_stats.txt";
    forwarders {ISP_DNS_IP;};
};
zone "example.com" IN {
	type master;
	file "forward.zone";
};

#nano /var/named/forward.zone

$TTL 3h
@	IN	SOA	server1	muffycompoqm.gmail.com. (
		1	; Serial Number
		15m	; Refresh Rate
		30m	; Retry Interval
		1h	; Expire Delay
		2h )	; Negative Cache TTL
@	IN	NS	server1
@	IN	A	192.168.1.1
server1	IN	A	192.168.1.1
www	IN	CNAME	server1.example.com.
ftp	IN	CNAME   server1.example.com.	

#nano /etc/resolv.conf

search example.com
nameserver 127.0.0.1

#chkconfig –levels 35 named on

#service named start

 

3. Installing Openbravo Dependencies

3.1 Postgresql 8.3

Exclude Postgresql from the CentOS base repository as OpenBravo uses Postgresql 8.3 which is not included in the base repository.

#nano /etc/yum.repos.d/CentOS-Base.repo

Add to the bottom of the file:

exclude=postgresql*

Download and install the RPMs from http://yum.pgsqlrpms.org:

wget http://yum.pgsqlrpms.org/reporpms/8.3/pgdg-centos-8.3-6.noarch.rpm

rpm -ivh pgdg-centos-8.3-6.noarch.rpm

yum install postgresql postgresql-server

Afterwards we have to set the PostgreSQL admin password:

sed -i ‘s/ident sameuser$/trust/’ /etc/postgresql/8.3/main/pg_hba.conf

service postgresql start

chkconfig –levels 35 postgresql on

Open a PostgreSQL shell and alter the postgres user role:

psql -U postgres

alter role postgres with password ‘testpassword';
\q

sed -i ‘s/trust$/md5/’ /etc/postgresql/8.3/main/pg_hba.conf

service postgresql reload

service postgresql restart

 

3.2 Sun Java JDK 1.6

You will have to download Java 1.6 JDK from http://java.sun.com/javase/downloads/index.jsp.

cp jdk-6u13-linux-i586.bin.bin /opt

cd /opt

sh jdk-6u13-linux-i586.bin.bin –unpack

mv jdk1-* java

echo “export JAVA_HOME=/opt/java” >> /etc/rc.local

export JAVA_HOME=/opt/java

  • How To Install Openbravo ERP On CentOS 5.2 – Page 2

next How To Install Openbravo ERP On CentOS 5.2 – Page 2
Copyright © 2009 Mfawa Alfred Onen
All Rights Reserved.

Related Tutorials

iRedMail: Build A Full-Featured Mail Server With LDAP, Postfix, RoundCube, Dovecot, ClamAV,SpamAssassin, DKIM, SPF On CentOS 5.x

iRedMail: Full-Featured Mail Server With LDAP, Postfix, RoundCube, Dovecot, ClamAV, DKIM, SPF On CentOS 5.x

Last edited 03/31/2011 

iRedMail is a shell script that lets you quickly deploy a full-featured mail solution in less than 2 minutes on CentOS 5.x and Debian (Lenny) 5.0.1 (it supports both i386 and x86_64). Its object is to make a Linux mail server installation and configuration simple and easy to use. iRedMail supports both OpenLDAP and MySQL as backends for storing virtual domains and users.This tutorial shows how to use the OpenLDAP as the backend.

The mail server components: http://code.google.com/p/iredmail/wiki/Main_Components

The discussion forum: http://www.iredmail.org/forum/

Now the newest version of iredmail start to support Debian (Lenny) 5.0.1,you can check the  install guide http://code.google.com/p/iredmail/wiki/Installation_on_Debian

.

 

Preliminary Note

In this tutorial I use:

Hostname server1.example.com
LDAP suffix: dc=example,dc=com
OpenLDAP admin account: cn=manager,dc=exmple,dc=com
Mail domain: example.com
Mail delivery (mailboxes) path: /home/vmail/domains

These settings might differ for you, so you have to replace them where appropriate.

 

Requirements

Install CentOS 5.x, I suggest to use the minimum install, make sure you don’t install Apache, PHP and MySQL. You can remove them with yum if they are installed.

Yum is working, because the installation needs to use CentOS source packages.

DNS MX record setting is no problem.

 

Installation

Download the iRedMail script:

wget http://iredmail.googlecode.com/files/iRedMail-0.7.1.tar.bz2
tar xjf iRedMail-0.7.1.tar.bz2

Run the script to install:

cd iRedMail-0.7.1
sh iRedMail.sh

Welcome page:

Mail delivery (mailboxes) path, all emails should be stored in this directory.

iRedMail supports both OpenLDAP and MySQL as backends to store virtual domains and users. OpenLDAP is selected.

LDAP suffix, normally it’s your domain name:

Set a password for the LDAP server admin. Admin account is defined in /etc/openldap/slapd.conf, normaily it’s: cn=Manager,dc=example,dc=com

Set a password for the LDAP virtual domain admin’s password. cn=vmailadmin,dc=example,dc=com is used to manage all virtual domains/users.

Add your first virtual domain:

Virtual domain administrator account for the first virtual domain. Default is ‘postmaster’.

  • iRedMail: Build A Full-Featured Mail Server With LDAP, Postfix, RoundCube, Dovecot, ClamAV, DKIM, SPF On CentOS 5.x – Page 2

next iRedMail: Build A Full-Featured Mail Server With LDAP, Postfix, RoundCube, Dovecot, ClamAV, DKIM, SPF On CentOS 5.x – Page 2
Copyright © 2009 eddiechen
All Rights Reserved.

Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (CentOS 5.3 x86_64)

Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (CentOS 5.3 x86_64)

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 04/20/2009

This tutorial is Copyright (c) 2009 by Falko Timme. It is derived from a tutorial from Christoph Haas which you can find at http://workaround.org. You are free to use this tutorial under the Creative Commons license 2.5 or any later version.

This document describes how to install a Postfix mail server that is based on virtual users and domains, i.e. users and domains that are in a MySQL database. I’ll also demonstrate the installation and configuration of Courier (Courier-POP3, Courier-IMAP), so that Courier can authenticate against the same MySQL database used by Postfix.

The resulting Postfix server is capable of SMTP-AUTH and TLS and quota (quota is not built into Postfix by default, I’ll show how to patch your Postfix appropriately). Passwords are stored in encrypted form in the database (most documents I found were dealing with plain text passwords which is a security risk). In addition to that, this tutorial covers the installation of Amavisd, SpamAssassin and ClamAV so that emails will be scanned for spam and viruses. I will also show how to install SquirrelMail as a webmail interface so that users can read and send emails and change their passwords.

The advantage of such a “virtual” setup (virtual users and domains in a MySQL database) is that it is far more performant than a setup that is based on “real” system users. With this virtual setup your mail server can handle thousands of domains and users. Besides, it is easier to administrate because you only have to deal with the MySQL database when you add new users/domains or edit existing ones. No more postmap commands to create db files, no more reloading of Postfix, etc. For the administration of the MySQL database you can use web based tools like phpMyAdmin which will also be installed in this howto. The third advantage is that users have an email address as user name (instead of a user name + an email address) which is easier to understand and keep in mind.

This howto is meant as a practical guide; it does not cover the theoretical backgrounds. They are treated in a lot of other documents in the web.

This document comes without warranty of any kind! I want to say that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

This tutorial is based on CentOS 5.3 x86_64, so you should set up a basic CentOS 5.3 server installation before you continue with this tutorial (e.g. as shown in the first six chapters of The Perfect Server – CentOS 5.3 x86_64). The system should have a static IP address. I use 192.168.0.100 as my IP address in this tutorial and server1.example.com as the hostname.

You should make sure that the firewall is off (at least for now) and that SELinux is disabled (this is important!).

I tested this setup on an x86_64 system. The setup should be similar or maybe even identical for an i386 system, but I didn’t test it.

 

2 Install Some Software

First we update our existing packages on the system:

yum update

Now we install some software that we need later on:

yum groupinstall ‘Development Tools’

yum groupinstall ‘Development Libraries’

 

3 Install Apache, MySQL, phpMyAdmin

First we enable the RPMforge repository on our CentOS system as lots of the packages that we are going to install in the course of this tutorial are not available in the official CentOS 5.3 repositories:

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

Afterwards we can install the needed packages with one single command (including the packages we need to build Courier-IMAP):

yum install ntp httpd mysql-server php php-mysql php-mbstring rpm-build gcc mysql-devel openssl-devel cyrus-sasl-devel pkgconfig zlib-devel phpmyadmin pcre-devel openldap-devel postgresql-devel expect libtool-ltdl-devel openldap-servers libtool gdbm-devel pam-devel gamin-devel

 

4 Install Courier-IMAP, Courier-Authlib, And Maildrop

Unfortunately there are no rpm packages for Courier-IMAP, Courier-Authlib, and Maildrop, therefore we have to build them ourselves.

RPM packages should not be built as root; courier-imap will even refuse to compile if it detects that the compilation is run as the root user. Therefore we create a normal user account now (falko in this example) and give him a password:

useradd -m -s /bin/bash falko
passwd falko

We will need the sudo command later on so that the user falko can compile and install the rpm packages. But first, we must allow falko to run all commands using sudo:

Run

visudo

In the file that opens there’s a line root ALL=(ALL) ALL. Add a similar line for falko just below that line:

[...]
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
falko   ALL=(ALL)       ALL
[...]

Now we are ready to build our rpm package. First become the user falko:

su falko

Next we create our build environment:

mkdir $HOME/rpm
mkdir $HOME/rpm/SOURCES
mkdir $HOME/rpm/SPECS
mkdir $HOME/rpm/BUILD
mkdir $HOME/rpm/BUILDROOT
mkdir $HOME/rpm/SRPMS
mkdir $HOME/rpm/RPMS
mkdir $HOME/rpm/RPMS/i386
mkdir $HOME/rpm/RPMS/x86_64

echo “%_topdir $HOME/rpm” >> $HOME/.rpmmacros

Now we create a downloads directory and download the source files from http://www.courier-mta.org/download.php:

mkdir $HOME/downloads
cd $HOME/downloads

wget http://prdownloads.sourceforge.net/courier/courier-authlib-0.62.2.tar.bz2
wget http://prdownloads.sourceforge.net/courier/courier-imap-4.4.1.tar.bz2
wget http://prdownloads.sourceforge.net/courier/maildrop-2.0.4.tar.bz2

Now (still in $HOME/downloads) we can build courier-authlib:

sudo rpmbuild -ta courier-authlib-0.62.2.tar.bz2

After the build process, the rpm packages can be found in $HOME/rpm/RPMS/x86_64 ($HOME/rpm/RPMS/i386 if you are on an i386 system):

cd $HOME/rpm/RPMS/x86_64

The command

ls -l

shows you the available rpm packages:

[falko@server1 x86_64]$ ls -l
total 608
-rw-r–r– 1 root root 139732 Apr 20 15:25 courier-authlib-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root root 328468 Apr 20 15:25 courier-authlib-debuginfo-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root root  35327 Apr 20 15:25 courier-authlib-devel-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root root  18307 Apr 20 15:25 courier-authlib-ldap-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root root  14497 Apr 20 15:25 courier-authlib-mysql-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root root  13711 Apr 20 15:25 courier-authlib-pgsql-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root root   8361 Apr 20 15:25 courier-authlib-pipe-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root root  35285 Apr 20 15:25 courier-authlib-userdb-0.62.2-1.x86_64.rpm
[falko@server1 x86_64]$

Select the ones you want to install, and install them like this:

sudo rpm -ivh courier-authlib-0.62.2-1.x86_64.rpm
sudo rpm -ivh courier-authlib-devel-0.62.2-1.x86_64.rpm
sudo rpm -ivh courier-authlib-mysql-0.62.2-1.x86_64.rpm

Now we go back to our downloads directory:

cd $HOME/downloads

and run rpmbuild again, this time without sudo, otherwise the compilation will fail because it was run as root:

rpmbuild -ta courier-imap-4.4.1.tar.bz2

After the build process, the rpm packages can be found in $HOME/rpm/RPMS/x86_64 ($HOME/rpm/RPMS/i386 if you are on an i386 system):

cd $HOME/rpm/RPMS/x86_64

The command

ls -l

shows you the available rpm packages:

[falko@server1 x86_64]$ ls -l
total 1920
-rw-r–r– 1 root  root  139732 Apr 20 15:25 courier-authlib-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root  root  328468 Apr 20 15:25 courier-authlib-debuginfo-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root  root   35327 Apr 20 15:25 courier-authlib-devel-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root  root   18307 Apr 20 15:25 courier-authlib-ldap-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root  root   14497 Apr 20 15:25 courier-authlib-mysql-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root  root   13711 Apr 20 15:25 courier-authlib-pgsql-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root  root    8361 Apr 20 15:25 courier-authlib-pipe-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root  root   35285 Apr 20 15:25 courier-authlib-userdb-0.62.2-1.x86_64.rpm
-rw-r–r– 1 falko falko 391473 Apr 20 15:37 courier-imap-4.4.1-1.x86_64.rpm
-rw-r–r– 1 falko falko 939716 Apr 20 15:37 courier-imap-debuginfo-4.4.1-1.x86_64.rpm
[falko@server1 x86_64]$

You can install courier-imap like this:

sudo rpm -ivh courier-imap-4.4.1-1.x86_64.rpm

Now we go back to our downloads directory:

cd $HOME/downloads

and run rpmbuild again, this time to build a maildrop package:

sudo rpmbuild -ta maildrop-2.0.4.tar.bz2

After the build process, the rpm packages can be found in $HOME/rpm/RPMS/x86_64 ($HOME/rpm/RPMS/i386 if you are on an i386 system):

cd $HOME/rpm/RPMS/x86_64

The command

ls -l

shows you the available rpm packages:

[falko@server1 x86_64]$ ls -l
total 3172
-rw-r–r– 1 root  root  139732 Apr 20 15:25 courier-authlib-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root  root  328468 Apr 20 15:25 courier-authlib-debuginfo-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root  root   35327 Apr 20 15:25 courier-authlib-devel-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root  root   18307 Apr 20 15:25 courier-authlib-ldap-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root  root   14497 Apr 20 15:25 courier-authlib-mysql-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root  root   13711 Apr 20 15:25 courier-authlib-pgsql-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root  root    8361 Apr 20 15:25 courier-authlib-pipe-0.62.2-1.x86_64.rpm
-rw-r–r– 1 root  root   35285 Apr 20 15:25 courier-authlib-userdb-0.62.2-1.x86_64.rpm
-rw-r–r– 1 falko falko 391473 Apr 20 15:37 courier-imap-4.4.1-1.x86_64.rpm
-rw-r–r– 1 falko falko 939716 Apr 20 15:37 courier-imap-debuginfo-4.4.1-1.x86_64.rpm
-rw-r–r– 1 root  root  298373 Apr 20 15:47 maildrop-2.0.4-1.x86_64.rpm
-rw-r–r– 1 root  root  767039 Apr 20 15:47 maildrop-debuginfo-2.0.4-1.x86_64.rpm
-rw-r–r– 1 root  root  134030 Apr 20 15:47 maildrop-devel-2.0.4-1.x86_64.rpm
-rw-r–r– 1 root  root   58400 Apr 20 15:47 maildrop-man-2.0.4-1.x86_64.rpm
[falko@server1 x86_64]$

You can now install maildrop like this:

sudo rpm -ivh maildrop-2.0.4-1.x86_64.rpm

After you have compiled and installed all needed packages, you can become root again by typing

exit

 

5 Apply Quota Patch To Postfix

We have to get the Postfix source rpm, patch it with the quota patch, build a new Postfix rpm package and install it.

cd /usr/src
wget http://ftp-stud.fht-esslingen.de/pub/Mirrors/centos/5.3/os/SRPMS/postfix-2.3.3-2.1.el5_2.src.rpm
rpm -ivh postfix-2.3.3-2.1.el5_2.src.rpm

The last command will show some warnings that you can ignore:

warning: user mockbuild does not exist – using root
warning: group mockbuild does not exist – using root

cd /usr/src/redhat/SOURCES
wget http://vda.sourceforge.net/VDA/postfix-2.3.3-vda.patch.gz
gunzip postfix-2.3.3-vda.patch.gz
cd /usr/src/redhat/SPECS/

Now we must edit the file postfix.spec:

vi postfix.spec

Change %define MYSQL 0 to %define MYSQL 1, add Patch0: postfix-2.3.3-vda.patch to the # Patches stanza, and finally add %patch0 -p1 -b .vda to the %setup -q stanza:

[...]
%define MYSQL 1
[...]
# Patches

Patch0: postfix-2.3.3-vda.patch
Patch1: postfix-2.1.1-config.patch
Patch3: postfix-alternatives.patch
Patch6: postfix-2.1.1-obsolete.patch
Patch7: postfix-2.1.5-aliases.patch
Patch8: postfix-large-fs.patch
Patch9: postfix-2.2.5-cyrus.patch
Patch10: postfix-CVE-2008-2936.patch
[...]
%setup -q
# Apply obligatory patches
%patch0 -p1 -b .vda
%patch1 -p1 -b .config
%patch3 -p1 -b .alternatives
%patch6 -p1 -b .obsolete
%patch7 -p1 -b .aliases
%patch8 -p1 -b .large-fs
%patch9 -p1 -b .cyrus
%patch10 -p1 -b .CVE-2008-2936
[...]

Then we build our new Postfix rpm package with quota and MySQL support:

rpmbuild -ba postfix.spec

Our Postfix rpm package is created in /usr/src/redhat/RPMS/x86_64, (/usr/src/redhat/RPMS/i386 on an i386 system) so we go there:

cd /usr/src/redhat/RPMS/x86_64

The command

ls -l

shows you the available packages:

[root@server1 x86_64]# ls -l
total 11732
-rw-r–r– 1 root root 3940163 Apr 20 15:58 postfix-2.3.3-2.1.x86_64.rpm
-rw-r–r– 1 root root 7999370 Apr 20 15:59 postfix-debuginfo-2.3.3-2.1.x86_64.rpm
-rw-r–r– 1 root root   49761 Apr 20 15:58 postfix-pflogsumm-2.3.3-2.1.x86_64.rpm
[root@server1 x86_64]#

Pick the Postfix package and install it like this:

rpm -ivh postfix-2.3.3-2.1.x86_64.rpm

  • Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (CentOS 5.3 x86_64) – Page 2
  • Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (CentOS 5.3 x86_64) – Page 3
  • Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (CentOS 5.3 x86_64) – Page 4
  • Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (CentOS 5.3 x86_64) – Page 5

next Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (CentOS 5.3 x86_64) – Page 2
[Creative Commons Attribution License]This page is licensed under a Creative Commons License.

Related Tutorials

The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 3]

The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 3]

Version 1.1
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 03/16/2010

This tutorial shows how to prepare a CentOS 5.3 x86_64 server for the installation of ISPConfig 3, and how to install ISPConfig 3. ISPConfig 3 is a webhosting control panel that allows you to configure the following services through a web browser: Apache web server, Postfix mail server, MySQL, MyDNS nameserver, PureFTPd, SpamAssassin, ClamAV, and many more.

Please note that this setup does not work for ISPConfig 2! It is valid for ISPConfig 3 only!

I do not issue any guarantee that this will work for you!

In order to learn how to use ISPConfig 3, I strongly recommend to download the ISPConfig 3 Manual.

On nearly 300 pages, it covers the concept behind ISPConfig (admin, resellers, clients), explains how to install and update ISPConfig 3, includes a reference for all forms and form fields in ISPConfig together with examples of valid inputs, and provides tutorials for the most common tasks in ISPConfig 3. It also lines out how to make your server more secure and comes with a troubleshooting section at the end.

 

1 Requirements

To install such a system you will need the following:

  • Download the CentOS 5.3 DVD or the seven CentOS 5.3 CDs from a mirror next to you (the list of mirrors can be found here: http://isoredirect.centos.org/centos/5/isos/x86_64/).
  • a fast Internet connection.

 

2 Preliminary Note

In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100 and the gateway 192.168.0.1. These settings might differ for you, so you have to replace them where appropriate.

 

3 Install The Base System

Boot from your first CentOS 5.3 CD (CD 1) or the CentOS 5.3 DVD. Press <ENTER> at the boot prompt:

It can take a long time to test the installation media so we skip this test here:

The welcome screen of the CentOS installer appears. Click on Next:

Choose your language next:

Select your keyboard layout:

I’m installing CentOS 5.3 on a fresh system, so I answer Yes to the question Would you like to initialize this drive, erasing ALL DATA?

Now we must select a partitioning scheme for our installation. For simplicity’s sake I select Remove linux partitions on selected drives and create default layout. This will result in a small /boot and a large / partition as well as a swap partition. Of course, you’re free to partition your hard drive however you like it. Then I hit Next:

Answer the following question (Are you sure you want to do this?) with Yes:

On to the network settings. The default setting here is to configure the network interfaces with DHCP, but we are installing a server, so static IP addresses are not a bad idea… Click on the Edit button at the top right.

In the window that pops up uncheck Use dynamic IP configuration (DHCP) and Enable IPv6 support and give your network card a static IP address (in this tutorial I’m using the IP address 192.168.0.100 for demonstration purposes) and a suitable netmask (e.g. 255.255.255.0; if you are not sure about the right values, http://www.subnetmask.info might help you):

Set the hostname manually, e.g. server1.example.com, and enter a gateway (e.g. 192.168.0.1) and up to two DNS servers (e.g. 213.191.92.86 and 145.253.2.75):

Choose your time zone:

Give root a password:

  • The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 3] – Page 2
  • The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 3] – Page 3
  • The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 3] – Page 4
  • The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 3] – Page 5
  • The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 3] – Page 6

next The Perfect Server – CentOS 5.3 x86_64 [ISPConfig 3] – Page 2
Copyright © 2009 Falko Timme
All Rights Reserved.

Related Tutorials

Paravirtualization With Xen On CentOS 5.3 (x86_64)

Paravirtualization With Xen On CentOS 5.3 (x86_64)

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 04/22/2009

This tutorial provides step-by-step instructions on how to install Xen (version 3.0.3) on a CentOS 5.3 (x86_64) system.

Xen lets you create guest operating systems (*nix operating systems like Linux and FreeBSD), so called “virtual machines” or domUs, under a host operating system (dom0). Using Xen you can separate your applications into different virtual machines that are totally independent from each other (e.g. a virtual machine for a mail server, a virtual machine for a high-traffic web site, another virtual machine that serves your customers’ web sites, a virtual machine for DNS, etc.), but still use the same hardware. This saves money, and what is even more important, it’s more secure. If the virtual machine of your DNS server gets hacked, it has no effect on your other virtual machines. Plus, you can move virtual machines from one Xen server to the next one.

I will use CentOS 5.3 (x86_64) for both the host OS (dom0) and the guest OS (domU).

This howto is meant as a practical guide; it does not cover the theoretical backgrounds. They are treated in a lot of other documents in the web.

This document comes without warranty of any kind! I want to say that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

This guide will explain how to set up image-based virtual machines and also LVM-based virtual machines.

Make sure that SELinux is disabled or permissive:

vi /etc/sysconfig/selinux

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

If you had to modify /etc/sysconfig/selinux, please reboot the system:

reboot

 

2 Installing Xen

To install Xen, we simply run

yum install kernel-xen xen

This installs Xen and a Xen kernel on our CentOS system.

Before we can boot the system with the Xen kernel, please check your GRUB bootloader configuration. We open /boot/grub/menu.lst:

vi /boot/grub/menu.lst

The first listed kernel should be the Xen kernel that you’ve just installed:

[...]
title CentOS (2.6.18-128.1.6.el5xen)
        root (hd0,0)
        kernel /xen.gz-2.6.18-128.1.6.el5
        module /vmlinuz-2.6.18-128.1.6.el5xen ro root=/dev/vg0/root
        module /initrd-2.6.18-128.1.6.el5xen.img
[...]

Change the value of default to 0 (so that the first kernel (the Xen kernel) will be booted by default):

[...]
default=0
[...]

The complete /boot/grub/menu.lst should look something like this:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/vg0/root
#          initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-128.1.6.el5xen)
        root (hd0,0)
        kernel /xen.gz-2.6.18-128.1.6.el5
        module /vmlinuz-2.6.18-128.1.6.el5xen ro root=/dev/vg0/root
        module /initrd-2.6.18-128.1.6.el5xen.img
title CentOS (2.6.18-128.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-128.el5 ro root=/dev/vg0/root
        initrd /initrd-2.6.18-128.el5.img

Afterwards, we reboot the system:

reboot

The system should now automatically boot the new Xen kernel. After the system has booted, we can check that by running

uname -r

[root@server1 ~]# uname -r
2.6.18-128.1.6.el5xen
[root@server1 ~]#

So it’s really using the new Xen kernel!

We can now run

xm list

to check if Xen has started. It should list Domain-0 (dom0):

[root@server1 ~]# xm list
Name                                      ID Mem(MiB) VCPUs State   Time(s)
Domain-0                                   0     3363     2 r—–     78.6
[root@server1 ~]#

  • Paravirtualization With Xen On CentOS 5.3 (x86_64) – Page 2

next Paravirtualization With Xen On CentOS 5.3 (x86_64) – Page 2
Copyright © 2009 Falko Timme
All Rights Reserved.

Related Tutorials

How To Harden PHP5 With Suhosin On CentOS 5.3

How To Harden PHP5 With Suhosin On CentOS 5.3

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 05/11/2009

This tutorial shows how to harden PHP5 with Suhosin on a CentOS 5.3 server. From the Suhosin project page: “Suhosin is an advanced protection system for PHP installations that was designed to protect servers and users from known and unknown flaws in PHP applications and the PHP core. Suhosin comes in two independent parts, that can be used separately or in combination. The first part is a small patch against the PHP core, that implements a few low-level protections against bufferoverflows or format string vulnerabilities and the second part is a powerful PHP extension that implements all the other protections.”

This document comes without warranty of any kind! I want to say that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

I have tested this on a CentOS 5.3 server with the IP address 192.168.0.100.

I will install both Suhosin parts in this tutorial, the Suhosin patch (for which we need to recompile PHP5) and the Suhosin PHP extension. To see what Suhosin can do, please refer to http://www.hardened-php.net/suhosin/a_feature_list.html. The features of the Suhosin patch are listed under Engine Protection (only with patch); all the other features come with the Suhosin extension.

 

2 Installing Apache2 And PHP5 (Optional)

(This chapter is optional if you already have Apache2 and PHP5 installed – please skip to the next chapter.)

If you don’t have Apache2 and PHP5 installed on your server, install it now:

yum install httpd php php-devel

Then create the system startup links for Apache2 and start Apache2:

chkconfig –levels 235 httpd on
/etc/init.d/httpd start

You now have a PHP5 with basic functionality on your server; if you need special PHP5 modules, you can search for them like this:

yum search php

From the output, pick the modules you need, install them like this and restart Apache2:

yum install php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc

/etc/init.d/httpd restart

 

3 Getting Details About Your PHP5 Installation

Unless you have already created virtual hosts in your Apache installation, the document root of the default web site is /var/www/html. We will now create a small PHP file (info.php) in that directory (if you have created virtual hosts, place it in any of the virtual hosts that has PHP enabled) and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

vi /var/www/html/info.php

<?php
phpinfo();
?>

Now we call that file in a browser (e.g. http://192.168.0.100/info.php):

As you see, our PHP version is 5.1.6, and Suhosin is not mentioned anywhere on that page which means it is not installed.

  • How To Harden PHP5 With Suhosin On CentOS 5.3 – Page 2

next How To Harden PHP5 With Suhosin On CentOS 5.3 – Page 2
Copyright © 2009 Falko Timme
All Rights Reserved.

The Perfect Server – CentOS 5.3 i386 [ISPConfig 2]

The Perfect Server – CentOS 5.3 i386 [ISPConfig 2]

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 04/04/2009

This tutorial shows how to set up a CentOS 5.3 server (i386) that offers all services needed by ISPs and web hosters: Apache web server (SSL-capable), Postfix mail server with SMTP-AUTH and TLS, BIND DNS server, Proftpd FTP server, MySQL server, Dovecot POP3/IMAP, Quota, Firewall, etc. This tutorial is written for the 32-bit version of CentOS 5.3, but should apply to the 64-bit version with very little modifications as well. In the end you should have a system that works reliably, and if you like you can install the free webhosting control panel ISPConfig (i.e., ISPConfig runs on it out of the box).

I will use the following software:

  • Web Server: Apache 2.2 with PHP 5.1.6
  • Database Server: MySQL 5.0
  • Mail Server: Postfix
  • DNS Server: BIND9 (chrooted)
  • FTP Server: Proftpd
  • POP3/IMAP server: Dovecot
  • Webalizer for web site statistics

Please note that this setup does not work for ISPConfig 3! It is valid for ISPConfig 2 only!

I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

 

1 Requirements

To install such a system you will need the following:

  • Download the CentOS 5.3 DVD or the six CentOS 5.3 CDs from a mirror next to you (the list of mirrors can be found here: http://isoredirect.centos.org/centos/5/isos/i386/).
  • a fast Internet connection.

 

2 Preliminary Note

In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100 and the gateway 192.168.0.1. These settings might differ for you, so you have to replace them where appropriate.

 

3 Install The Base System

Boot from your first CentOS 5.3 CD (CD 1) or the CentOS 5.3 DVD. Press <ENTER> at the boot prompt:

It can take a long time to test the installation media so we skip this test here:

The welcome screen of the CentOS installer appears. Click on Next:

Choose your language next:

Select your keyboard layout:

I’m installing CentOS 5.3 on a fresh system, so I answer Yes to the question Would you like to initialize this drive, erasing ALL DATA?

Now we must select a partitioning scheme for our installation. For simplicity’s sake I select Remove linux partitions on selected drives and create default layout. This will result in a small /boot and a large / partition as well as a swap partition. Of course, you’re free to partition your hard drive however you like it. Then I hit Next:

Answer the following question (Are you sure you want to do this?) with Yes:

On to the network settings. The default setting here is to configure the network interfaces with DHCP, but we are installing a server, so static IP addresses are not a bad idea… Click on the Edit button at the top right.

In the window that pops up uncheck Use dynamic IP configuration (DHCP) and Enable IPv6 support and give your network card a static IP address (in this tutorial I’m using the IP address 192.168.0.100 for demonstration purposes) and a suitable netmask (e.g. 255.255.255.0; if you are not sure about the right values, http://www.subnetmask.info might help you):

Set the hostname manually, e.g. server1.example.com, and enter a gateway (e.g. 192.168.0.1) and up to two DNS servers (e.g. 213.191.92.86 and 145.253.2.75):

Choose your time zone:

Give root a password:

  • The Perfect Server – CentOS 5.3 i386 [ISPConfig 2] – Page 2
  • The Perfect Server – CentOS 5.3 i386 [ISPConfig 2] – Page 3
  • The Perfect Server – CentOS 5.3 i386 [ISPConfig 2] – Page 4
  • The Perfect Server – CentOS 5.3 i386 [ISPConfig 2] – Page 5
  • The Perfect Server – CentOS 5.3 i386 [ISPConfig 2] – Page 6
  • The Perfect Server – CentOS 5.3 i386 [ISPConfig 2] – Page 7

next The Perfect Server – CentOS 5.3 i386 [ISPConfig 2] – Page 2
Copyright © 2009 Falko Timme
All Rights Reserved.

Related Tutorials

Installing PowerDNS (With MySQL Backend) And Poweradmin On CentOS 5.2

Installing PowerDNS (With MySQL Backend) And Poweradmin On CentOS 5.2

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 01/15/2009

This article shows how you can install the PowerDNS nameserver (with MySQL backend) and the Poweradmin control panel for PowerDNS on a CentOS 5.2 system. PowerDNS is a high-performance, authoritative-only nameserver – in the setup described here it will read the DNS records from a MySQL database (similar to MyDNS), although other backends such as PostgreSQL are supported as well. Poweradmin is a web-based control panel for PowerDNS.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

In this example I’m using a CentOS 5.2 host with the hostname server1.example.com and the IP address 192.168.0.100, set up according to the first 6 chapters of this tutorial: The Perfect Server – CentOS 5.2.

I will set up just one PowerDNS server in this example (a master); adding PowerDNS slave(s) can easily be achieved by using MySQL database replication from the master to the slave(s), therefore no zone transfers are needed (this again is similar to MyDNS). MySQL database replication can be set up according to this tutorial: How To Set Up Database Replication In MySQL (PowerDNS also supports native zone transfers (for scenarios where you cannot use MySQL replication) – see http://downloads.powerdns.com/documentation/html/replication.html).

 

2 Installing MySQL

To install MySQL, we do this:

yum install mysql mysql-server

Then we create the system startup links for MySQL (so that MySQL starts automatically whenever the system boots) and start the MySQL server:

chkconfig –levels 235 mysqld on
/etc/init.d/mysqld start

Now check that networking is enabled. Run

netstat -tap | grep mysql

It should show something like this (*:mysql means that MySQL is listening on all interfaces which is important for MySQL replication!):

[root@server1 ~]# netstat -tap | grep mysql
tcp        0      0 *:mysql                     *:*                         LISTEN      2439/mysqld
[root@server1 ~]#

If it does not, edit /etc/my.cnf and comment out the option skip-networking:

vi /etc/my.cnf

[...]
#skip-networking
[...]

and restart your MySQL server:

/etc/init.d/mysqld restart

Run

mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpassword

to set a password for the user root (otherwise anybody can access your MySQL database!).

 

3 Installing PowerDNS

To install PowerDNS, we run

yum install pdns pdns-backend-mysql

The PowerDNS configuration is located in the /etc/pdns directory – I’ll come to that in a moment.

Now we connect to MySQL:

mysql -u root -p

Type in your MySQL root password, and you should be on the MySQL shell. On the MySQL shell, we create a database for PowerDNS:

CREATE DATABASE powerdns;

Next we create a database user (powerdns) for PowerDNS:

GRANT ALL ON powerdns.* TO ‘power_admin’@’localhost’ IDENTIFIED BY ‘power_admin_password';
GRANT ALL ON powerdns.* TO ‘power_admin’@’localhost.localdomain’ IDENTIFIED BY ‘power_admin_password';
FLUSH PRIVILEGES;

(Replace power_admin_password with a password of your choice.)

Now we create the tables needed by PowerDNS…

USE powerdns;

CREATE TABLE domains (
id INT auto_increment,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type VARCHAR(6) NOT NULL,
notified_serial INT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
primary key (id)
);

CREATE UNIQUE INDEX name_index ON domains(name);

CREATE TABLE records (
id INT auto_increment,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(6) DEFAULT NULL,
content VARCHAR(255) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
change_date INT DEFAULT NULL,
primary key(id)
);

CREATE INDEX rec_name_index ON records(name);
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);

CREATE TABLE supermasters (
ip VARCHAR(25) NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) DEFAULT NULL
);

… and finally leave the MySQL shell:

quit;

Now we must configure PowerDNS so that it uses the MySQL backend:

vi /etc/pdns/pdns.conf

Add the following lines to pdns.conf:

[...]
#################################
# launch        Which backends to launch and order to query them in
#
# launch=
launch=gmysql
gmysql-host=127.0.0.1
gmysql-user=power_admin
gmysql-password=power_admin_password
gmysql-dbname=powerdns
[...]

Then create the system startup links for PowerDNS and start it:

chkconfig –levels 235 pdns on
/etc/init.d/pdns start

That’s it, PowerDNS is now ready to be used. To learn more about it, please refer to its documentation: http://downloads.powerdns.com/documentation/html/index.html

 

4 Installing Poweradmin

Now let’s install Poweradmin, a web-based control panel for PowerDNS. Poweradmin is written in PHP, so we must install a web server (I’m using Apache2 in this example) and PHP:

yum install httpd php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mhash gettext

Create the system startup links for Apache2 and start it:

chkconfig –levels 235 httpd on
/etc/init.d/httpd start

Poweradmin also requires the following two PEAR packages:

yum install php-pear-DB php-pear-MDB2-Driver-mysql

Now all prerequisites for Poweradmin are installed, and we can begin with the Poweradmin installation (I will install it in a subdirectory of /var/www/html/var/www/html is the document root of Apache’s default web site on CentOS; if you’ve created a vhost with a different document root, please adjust the paths).

Go to https://www.poweradmin.org/trac/wiki/GettingPoweradmin and download the latest Poweradmin package, e.g. as follows:

cd /tmp
wget https://www.poweradmin.org/download/poweradmin-2.1.2.tgz

Then install it to the /var/www/html/poweradmin directory as follows:

tar xvfz poweradmin-2.1.2.tgz
mv poweradmin-2.1.2 /var/www/html/poweradmin
touch /var/www/html/poweradmin/inc/config.inc.php
chown -R apache:apache /var/www/html/poweradmin/

Now open a browser and launch the web-based Poweradmin installer (http://server1.example.com/poweradmin/install or http://192.168.0.100/poweradmin/install).

Select your language (English or Dutch):

Click on the Go to step 3 button to proceed:

Now fill in your database details. It is important that you fill in the details for the MySQL root user, not the powerdns MySQL user we created earlier! Also provide a password for the admin user for the Poweradmin web interface (that’s the password that the user admin will use to log in to Poweradmin later on):

On the next page, fill in the details for the power_admin MySQL user that we created in chapter 3. Also fill in the two default nameservers that will be used in your zones unless you provide different nameservers when you create a zone (typically these are the names of the current system and of the slave server (for which you can set up MySQL replication, see my preliminary notes in chapter 1)):

  • Installing PowerDNS (With MySQL Backend) And Poweradmin On CentOS 5.2 – Page 2

next Installing PowerDNS (With MySQL Backend) And Poweradmin On CentOS 5.2 – Page 2
Copyright © 2009 Falko Timme
All Rights Reserved.

Related Tutorials

ZRM 2.1: Backing Up MySQL Partitioned Tables

ZRM 2.1: Backing Up MySQL Partitioned Tables

MySQL 5.1 is generally available for production use. One of the key features of MySQL 5.1 is partitioning. Table partitioning can help in improving performance and usability. Tables can be partitioned based on range (column values in a given range), list (column values matching a set of values), hash (user defined hash based on column values) or key (predefined hash function based on column values). Each partition can have different data directory.

Zmanda Recovery Manager for MySQL (ZRM) 2.1 release supports MySQL 5.1GA release. ZRM provides efficient backup and recovery of MySQL database. It can perform logical, raw as well as snapshot based backups. ZRM 2.1 supports storage snapshots (LVM and Solaris ZFS) as backup images and can be converted into regular backup image later.

This how to shows how to install and configure ZRM 2.1 to perform backup and recovery of MySQL partitioned tables.

This example uses MySQL 5.1.30 running on CentOS 4. The MySQL server has a myisamnetflix database that contains the MovieRatings partitioned table.

* Install MySQL 5.1.30 on the server. Download server and client images from the MySQL downloads site. The following rpms should be downloaded and installed:

MySQL-client-community-5.1.30-0.rhel4
MySQL-server-community-5.1.30-0.rhel4

* Follow the instructions to create default MySQL database and run MySQL server.

* Check to see if the MySQL partitioning is enabled

mysql> SHOW VARIABLES LIKE ‘%partition%';

+——————-+——-+
| Variable_name     | Value |
+——————-+——-+
| have_partitioning | YES   |
+——————-+——-+
1 row in set (0.00 sec)

* Create the table with key partitioning on MovieID column and populate the table with data.

mysql> CREATE TABLE `MovieRatings` (
  `MovieID` int(6) NOT NULL,
  `CustomerID` varchar(10) NOT NULL,
  `Rating` int(1) DEFAULT NULL,
  `Date` date NOT NULL
) ENGINE=MyISAM PARTITION BY KEY (MovieID) PARTITIONS 3;

* Download ZRM 2.1 rpm from the Zmanda downloads page.

* Create mysql-zrm.conf in the /etc/mysql-zrm/partition-test directory. partition-test is the backup set name.

host="localhost" 
databases="myisamnetflix" 
password="boot12" 
user="root" 
compress=1 
backup-mode=logical 

* Run a full backup of the backup set partition-set as mysql user. All ZRM operations should be performed as mysql user:

$ mysql-zrm-scheduler –now –backup-set partition-test –backup-level 0

schedule:INFO: ZRM for MySQL Community Edition – version 2.1
Logging to /var/log/mysql-zrm/mysql-zrm-scheduler.log
backup:INFO: ZRM for MySQL Community Edition – version 2.1
partition-test:backup:INFO: START OF BACKUP
partition-test:backup:INFO: PHASE START: Initialization
partition-test:backup:WARNING: Binary logging is off.
partition-test:backup:INFO: backup-set=partition-test
partition-test:backup:INFO: backup-date=20081125181119
partition-test:backup:INFO: mysql-server-os=Linux/Unix
partition-test:backup:INFO: backup-type=regular
partition-test:backup:INFO: host=localhost
partition-test:backup:INFO: backup-date-epoch=1227665479
partition-test:backup:INFO: mysql-zrm-version=ZRM for MySQL Community Edition – version 2.1
partition-test:backup:INFO: mysql-version=5.1.30-community
partition-test:backup:INFO: backup-directory=/var/lib/mysql-zrm/partition-test/20081125181119
partition-test:backup:INFO: backup-level=0
partition-test:backup:INFO: backup-mode=logical
partition-test:backup:INFO: PHASE END: Initialization
partition-test:backup:INFO: PHASE START: Running pre backup plugin
partition-test:backup:INFO: PHASE END: Running pre backup plugin
partition-test:backup:INFO: PHASE START: Flushing logs
partition-test:backup:INFO: PHASE END: Flushing logs
partition-test:backup:INFO: PHASE START: Creating logical backup
partition-test:backup:INFO: logical-databases=myisamnetflix
partition-test:backup:INFO: PHASE END: Creating logical backup
partition-test:backup:INFO: PHASE START: Calculating backup size & checksums
partition-test:backup:INFO: backup-size=160.44 MB
partition-test:backup:INFO: PHASE END: Calculating backup size & checksums
partition-test:backup:INFO: PHASE START: Compression/Encryption
partition-test:backup:INFO: compress=
partition-test:backup:INFO: backup-size-compressed=36.04 MB
partition-test:backup:INFO: PHASE END: Compression/Encryption
partition-test:backup:INFO: read-locks-time=00:01:27
partition-test:backup:INFO: flush-logs-time=00:00:00
partition-test:backup:INFO: compress-encrypt-time=01:23:07
partition-test:backup:INFO: backup-time=00:02:17
partition-test:backup:INFO: backup-status=Backup succeeded
partition-test:backup:INFO: Backup succeeded
partition-test:backup:INFO: PHASE START: Running post backup plugin
partition-test:backup:INFO: PHASE END: Running post backup plugin
partition-test:backup:INFO: PHASE START: Mailing backup report
partition-test:backup:INFO: PHASE END: Mailing backup report
partition-test:backup:INFO: PHASE START: Cleanup
partition-test:backup:INFO: PHASE END: Cleanup
partition-test:backup:INFO: END OF BACKUP
/usr/bin/mysql-zrm started successfully

* Use ZRM reporter to look at the status of the backups.

$ /usr/bin/mysql-zrm-reporter –where backup-set=partition-test –show backup-status-info

  REPORT TYPE : backup-status-info 
   
           backup_set  backup_date                  backup_level  backup_status         backup_type       comment 
 ----------------------------------------------------------------------------------------------------------------------------- 
       partition-test  Tue 25 Nov 2008 06:11:19                0  Backup succeeded      regular           ---- 
                       PM PST 
 
   * Delete a few rows from the MovieID database to test the recovery from the backup image. 

mysql> delete from MovieID where MovieTitle regexp ‘Sherlock Holmes*';

Query OK, 28 rows affected (0.15 sec)

* Run a report to identify the backup image to be restored and restore from the backup image.

$ /usr/bin/mysql-zrm-reporter –where backup-set=partition-test –show restore-info

  REPORT TYPE : restore-info 
   
           backup_set  backup_date                  backup_level  backup_directory                          backup_status         comment 
 ----------------------------------------------------------------------------------------------------------------------------------------------------- 
       partition-test  Tue 25 Nov 2008 06:11:19                0  /var/lib/mysql-zrm/partition-test/200811  Backup succeeded      ---- 
                       PM PST                                     25181119 

$ /usr/bin/mysql-zrm-restore –user=root –password=boot12 –source-directory=/var/lib/mysql-zrm/partition-test/20081125181119/

restore:INFO: ZRM for MySQL Community Edition – version 2.1
BackupSet1:restore:WARNING: Binary logging is off.
BackupSet1:restore:INFO: Restored database(s) from logical backup: myisamnetflix
BackupSet1:restore:INFO: Restore done in 163 seconds.

* Check to see if the deleted rows in the MovieID table have been restored.

mysql> select count(*) from MovieID where MovieTitle regexp ‘Sherlock Holmes*';

28 rows in set (0.23 sec)

The above example shows ZRM can be used to backup and recover partitioned tables in MySQL 5.1. A whitepaper on how to quickly configure ZRM 2.1 is available at http://www.zmanda.com/quick-mysql-backup.html.

Copyright © 2008 Paddy Sreenivasan
All Rights Reserved.

Related Tutorials