Considering migrating your server from Debian to CentOS? This article provides information on key differences between the two operating systems, along with instructions on moving your applications and configuration files.
Without a doubt, Debian is an excellent and popular Linux distribution, but it may not be your best choice for a server operating system. Even if you're more familiar with Debian, you may want to migrate to CentOS, which many people consider the de facto corporate Linux distribution. CentOS has a few undeniable advantages:
All of these facts make CentOS preferred over other open source operating system for corporate use. If you have decided to migrate your servers, let's learn some best practices for how it can be done.
First, plan the migration by making starting with an inventory of your current Debian environment. This inventory should include all services and installed applications which will be migrated.
If you're compiling software from source, the process is the same for CentOS as it is for any other Linux distribution. However, binary software packages are not portable between Debian and CentOS. CentOS uses binary packages in RPM (RPM Package Manager) format. You can use utilities such as yum and rpm to install applications from binary packages and repositories. Here are a few examples of ways to use them oriented toward sysadmins with expertise in Debian:
yum search packagename
apt-cache search packagename
rpm -qa |grep packagename
rpm -qi packagename
rpm -ql packagename
rpm -qf packagename
apt-cache update && apt-get upgrade
yum update packagename
apt-get --only-upgrade install packagename
yum install packagename
apt-get install packagename
rpm -i packagename.rpm
dpkg -i packagename.deb
yum remove packagename
apt-get remove packagename
Knowing these commands can save you time and headaches as you're getting used to CentOS during and after the migration process.
CentOS differs from Debian in another way when it comes to managing software. When you need to install a package in CentOS you may not find it in the default CentOS repository, which contains significantly fewer packages than Debian's. To address this deficiency you can add additional CentOS repositories. One of the first to consider is EPEL (Extra Packages for Enterprise Linux), which contains thousands of additional packages for use with yum. To add the EPEL repository, run the command rpm -ivh http://ftp-stud.hs-esslingen.de/pub/epel/6/i386/epel-release-6-8.noarch.rpm.
rpm -ivh http://ftp-stud.hs-esslingen.de/pub/epel/6/i386/epel-release-6-8.noarch.rpm
One important rule to observe when installing software is to make sure that the CentOS software versions are equal to or higher than the corresponding ones you were using in Debian. That's because older versions may not support features and specifics of newer versions. This is especially critical if you are going to support dynamic, server-side languages such as PHP or databases such as MySQL. Many PHP scripts depend on a particular PHP version and will not work on older release, and sometimes even on newer, so your only choice is to install the same version. The situation with MySQL is similar. If you need a newer version of an application than CentOS supports by default, you should install the version you need from source or from available binaries.
Once you have everything you need in place to migrate your services and applications, it's time to transfer the corresponding configurations. Even though most software configuration directives are not distribution-specific, it's better to migrate the configuration manually and not just copy over the files, because often hardcoded paths in the files differ among distributions. To make things easier, migrate only essential and critical settings and leave the rest as the defaults. For the settings you decide to preserve, make sure to adapt any hardcoded paths to files, directories, modules, and binaries. This is especially important for Apache and its virtual hosts, where the paths will certainly change, at least for the DocumentRoot of the vhosts.
CentOS keeps its configuration files to a minimum number, which means that sometimes they become large and hard to navigate through. In contrast, Debian spreads most configuration over multiple files. Here is some information on how the configuration of the most popular services is distributed and what you have to do for the migration:
If this uniting of configuration files in CentOS seems confusing to you, there is a way to split the configuration into multiple files. Most software configuration files can be instructed to include external files. To do so in Apache, use the directive Include, and in MySQL use the option !includedir.
Sometimes there is a good reason to split configuration files. PHP in both CentOS and Debian uses multiple files for security reasons. PHP processes the configuration directives in the following order: main php.ini file (/etc/php.ini in CentOS), local php.ini files (found in vhost webroots), and finally php.ini files from the global include directory (/etc/php.d/ in CentOS). This ensures that administrators can override any insecure, incorrect configurations that could be found in the webroot of a vhost.
Once you think you have everything migrated properly, start your services for the first time and make sure they start and stop with the system. CentOS startup scripts are in the directory /etc/init.d/, just like in Debian. And, just as in Debian, in CentOS the command /sbin/service is the preferred method for managing the state of a service. Both the /etc/init.d/ scripts and the service command accept the usual start, stop, restart, and reload arguments.
However, the two distributions differ in default runlevels. The default runlevel in CentOS is 3; in Debian it's 2. This matters when you install a service and you want it to start automatically with the system and thus have to add it to the default runlevel. The runlevel start and stop scripts, as in Debian, are in the directories /etc/rcX.d/ where X is the number of the runlevel.
In Debian you manage runlevel scripts with the update-rc.d command. In CentOS it's chkconfig. To make sure a service starts and stops automatically with the system, run the command chkconfig example on. This ensures the example service is added to the proper runlevels and you don't have to edit any files manually.
chkconfig example on
Once all your services are installed and configured you just have to migrate your content, which should be as straightforward as copying files between the old Debian server and the new CentOS server. You should export databases on the old server and import them on the new one.
That's all it takes for a complete Debian-to-CentOS migration!
Allowed tags: <a> link, <b> bold, <i> italics