Quantcast
Channel: Hosting Controller – System Network Programming Solution
Viewing all articles
Browse latest Browse all 187

Migrate a DirectAdmin Server to a new DirectAdmin Server

$
0
0

One day my client asked me to migrate a Direct Admin Server to NEW server with improved hardware. He wants this migration with minimum down time.

Below are the steps which I did for this migration.

01. Check the current versions of Apache, PHP and MySQL and then number of IPs on current running server.

In my case versions are as following:

Apache/2.2.13
PHP 5.2.17
MySQL 5.0

IP details:
174.XXX.XX.XX1
174.XXX.XX.XX2
174.XXX.XX.XX3

02. Install directadmin in custom mode on NEW server.

On NEW server I installed the following versions:

Apache 2.2 [it is the latest version available via DA's custombuild]
PHP 5.2 [It is the latest version of PHP available via DA's custombuild]
MySQL 5.1 [It is the latest version of MySQL available via DA and also this version supports "TRIGGER"(5.0 does not support "TRIGGER" in each mysql user level)]

Make DA and all other services down on NEW server:

/etc/init.d/named stop && \
/etc/init.d/exim stop && \
/etc/init.d/proftpd stop && \
/etc/init.d/dovecot stop && \
/etc/init.d/httpd stop && \
/etc/init.d/mysqld stop && \
/etc/init.d/directadmin stop  && \
/etc/init.d/crond stop

 

03. Upgrade MySQL on OLD server to 5.1

For upgrading MySQL do:

a. Change CWD to /usr/local/directadmin/custombuild/

b. Change mysql options in options.conf. So it should be like following.

mysql=5.1
mysql_inst=yes
mysql_backup=yes

c. Update build script

./build update_script

d. Update mysql

./build mysql d

04. Rsync all needed configuration files, /home and /var/lib/mysql from OLD server to NEW server.

My rsync script for DA to DA migration:

rsync -avz --stats --progress --delete -e ssh /var/lib/mysql/ XX.XXX.XX.XXX:/var/lib/mysql
rsync -avz --stats --progress --delete -e ssh /home/ XX.XXX.XX.XXX:/home
rsync -avz --stats --progress -e ssh /etc/passwd XX.XXX.XX.XXX:/etc
rsync -avz --stats --progress -e ssh /etc/shadow XX.XXX.XX.XXX:/etc
rsync -avz --stats --progress -e ssh /etc/group XX.XXX.XX.XXX:/etc
rsync -avz --stats --progress -e ssh /etc/exim.conf XX.XXX.XX.XXX:/etc
rsync -avz --stats --progress -e ssh /etc/exim.pl XX.XXX.XX.XXX:/etc
rsync -avz --stats --progress -e ssh /etc/system_filter.exim XX.XXX.XX.XXX:/etc
rsync -avz --stats --progress -e ssh /etc/exim.crt XX.XXX.XX.XXX:/etc
rsync -avz --stats --progress -e ssh /etc/exim.key XX.XXX.XX.XXX:/etc
rsync -avz --stats --progress -e ssh /etc/proftpd.conf XX.XXX.XX.XXX:/etc
rsync -avz --stats --progress -e ssh /etc/proftpd.vhosts.conf XX.XXX.XX.XXX:/etc
rsync -avz --stats --progress -e ssh /etc/proftpd.passwd XX.XXX.XX.XXX:/etc
rsync -avz --stats --progress -e ssh /etc/named.conf XX.XXX.XX.XXX:/etc
rsync -avz --stats --progress -e ssh /root/.my.cnf XX.XXX.XX.XXX:/root
rsync -avz --stats --progress --delete -e ssh /etc/virtual/  XX.XXX.XX.XXX:/etc/virtual
rsync -avz --stats --progress --delete -e ssh /etc/httpd/conf/ XX.XXX.XX.XXX:/etc/httpd/conf
rsync -avz --stats --progress --delete -e ssh /var/named/ XX.XXX.XX.XXX:/var/named
rsync -avz --stats --progress --delete -e ssh /var/spool/virtual/ XX.XXX.XX.XXX:/var/spool/virtual
rsync -avz --stats --progress --delete -e ssh /var/spool/mail/ XX.XXX.XX.XXX:/var/spool/mail
rsync -avz --stats --progress --delete -e ssh /var/spool/cron/ XX.XXX.XX.XXX:/var/spool/cron
rsync -avz --stats --progress --delete -e ssh /var/www/ XX.XXX.XX.XXX:/var/www
rsync -avz --stats --progress --delete -e ssh /var/log/ XX.XXX.XX.XXX:/var/log
rsync -avz --stats --exclude 'custombuild* --progress --delete -e ssh /usr/local/directadmin/ XX.XXX.XX.XXX:/usr/local/directadmin

 

Note: For more details about DA’s paths goto this link[http://directadmin.com/paths.html]

05. After rsync, IPs in the various configuration files will be the OLD one, so swap it with IPs of NEW server.

Configuration files which have IPs are following:

/etc/httpd/conf/httpd.conf
/etc/httpd/conf/extra/httpd-vhosts.conf
/etc/httpd/conf/ips.conf
/etc/proftpd.conf
/etc/proftpd.vhosts.conf
/usr/local/directadmin/scripts/setup.txt
/usr/local/directadmin/data/admin/ip.list
/usr/local/directadmin/data/admin/show_all_users.cache
/usr/local/directadmin/data/users/*/user.conf
/usr/local/directadmin/data/users/*/httpd.conf
/usr/local/directadmin/data/users/*/user_ip.list
/usr/local/directadmin/data/users/*/domains/*.conf
/usr/local/directadmin/data/users/*/domains/*.ftp
/usr/local/directadmin/data/users/*/domains/*.ip_list
/var/named/*.db

For editing these files, DA have a script named ipswap.sh.

Path of the ipswap.sh script:

/usr/local/directadmin/scripts/ipswap.sh

Use ipswap.sh to swap OLD IP with NEW one:

sh /usr/local/directadmin/scripts/ipswap.sh 174.XXX.XX.XX1 135.XX.XX.XX3
sh /usr/local/directadmin/scripts/ipswap.sh 174.XXX.XX.XX2 135.XX.XX.XX5
sh /usr/local/directadmin/scripts/ipswap.sh 174.XXX.XX.XX3 135.XX.XX.XX4

 

06. Go to /usr/local/directadmin/custombuild

Perform a

./build all y

This is for data and configuration integrity

07. Start all services in NEW server.

/etc/init.d/named start && \
/etc/init.d/exim start && \
/etc/init.d/proftpd start && \
/etc/init.d/dovecot start && \
/etc/init.d/httpd start && \
/etc/init.d/mysqld start  && \
/etc/init.d/directadmin start  && \
/etc/init.d/crond start

 

08. re-rsync /home and /var/lib/mysql

rsync -avz --stats --progress --delete -e ssh /var/lib/mysql/ XX.XXX.XX.XXX:/var/lib/mysql
rsync -avz --stats --progress --delete -e ssh /home/ XX.XXX.XX.XXX:/home

 

09. Go to OLD server and stop all services and make IP chnages in each zone files in order to point domains to NEW server.

For that do:

a. Stop all services

/etc/init.d/named stop && \
/etc/init.d/exim stop && \
/etc/init.d/proftpd stop && \
/etc/init.d/dovecot stop && \
/etc/init.d/httpd stop && \
/etc/init.d/mysqld stop && \
/etc/init.d/directadmin stop  && \
/etc/init.d/crond stop

 

b. Change IPs in each zone files

sed -i 's/174.XXX.XX.XX1/135.XX.XX.XX3/g' *.db
sed -i 's/174.XXX.XX.XX2/135.XX.XX.XX5/g' *.db
sed -i 's/174.XXX.XX.XX3/135.XX.XX.XX4/g' *.db

 

c. Start named service

/etc/init.d/named start

10. Update DirectAdmin License and restart Direct Admin on NEW server

sh /usr/local/directadmin/scripts/getLicense.sh UID LID
service directadmin restart

 

11. Ask the customers to change all the doamin’s nameserver to NEW server’s nameserver


Viewing all articles
Browse latest Browse all 187

Trending Articles