Migrate Joomla! Linux Server with multi-instance installation and local DB



	There are some options to migrate the database.
	* mysqldump	http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
	* mysqlhotcopy	http://dev.mysql.com/doc/refman/5.1/en/mysqlhotcopy.html
	* rsync		http://samba.anu.edu.au/rsync/
	* replication	http://dev.mysql.com/doc/refman/5.1/en/replication.html
	* ...
	The server hosts many Joomla! instances and there should be no downtime!
	So the chosen method is mysql replication

	1) Install a new Server, configure networking, firewall, selinux,... , install software
		yum update
		yum install httpd mysql-server mysql php-mysql php-gd php-common php-pdo php-mbstring php-cli php pure-ftpd php-ldap php-domxml
		yum remove sendmail
		yum install postfix

	2) Prepare Systems for SSH RSA authenticaion
		ssh-keygen
		cat .ssh/id_rsa.pub >> new server: .ssh/authorized_keys

	3) Sync data
		rsync -avp JOOMLA_DATA_DIR_OLD -e ssh root@NEW_SEVER _IP:JOOMLA_ DATA_ DIR_NEW

	4) Install FTP Service
		# pure-ftpd
		scp root@OLD_SEVER _IP:/etc/pure-ftpd/pureftpd.passwd /etc/pure-ftpd/pureftpd.passwd
		pure-pw mkdb			# generate ftp user db
		/etc/init.d/pure-ftpd start	# start service
		chkconfig pure-ftpd on		# autostart
	4) MySQL
		MASTER:
			/etc/init.d/mysqld start
			chkconfig mysqld on
			mysqladmin -u root password 'tEmp#pass2011'
			GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY 'tEmp#pass2011';
			FLUSH PRIVILEGES;

		        /etc/my.cnf
		        #security
		        #bind-address = 127.0.0.1
		        # replication
		        log-bin=mysql-bin
		        server-id=1

		        mysql> GRANT REPLICATION SLAVE ON *.* TO 'root'@'%' IDENTIFIED BY 'tEmp#pass2011';
		        mysql> SET GLOBAL WAIT_TIMEOUT=600000; SET WAIT_TIMEOUT = 600000; FLUSH TABLES WITH READ LOCK;

		        cd /var/lib/mysql
		        tar -cvf /tmp/mysql-snapshot.tar ./ &

		        mysql> SHOW MASTER STATUS;     # remeber File and Position 
		        mysql> UNLOCK TABLES;

		SLAVE:  
		        cd /var/lib/mysql
		        scp root@OLD_SEVER _IP:/tmp/mysql-snapshot.tar .
		        tar xf mysql-snapshot

		        vi /etc/my.cnf
		        [mysqld]
		        server-id=2
		        master-host     =   OLD_SERVER_IP
		        master-user     =   root
		        master-password =   tEmp#pass2011
		        master-port     =   3306

		        mysql> CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin';
		        mysql> CHANGE MASTER TO MASTER_LOG_POS=000001;
		        mysql> start slave;
		        mysql> show slave status\G;

	5) go live
		* Lock tables at master
		mysql> FLUSH TABLES WITH READ LOCK;
		
		* check slave status
		mysql> show slave status\G;

		* sync data dir again
		rsync -avp JOOMLA_DATA_DIR_OLD -e ssh root@NEW_SEVER _IP:JOOMLA_ DATA_ DIR_NEW

		* break mysql replication
		- delete server-id, master-* lines from /etc/my.cnf
		/etc/init.d/mysqld restart

		change IP-Address (this can also done by DNS)

	*) other suff
		copy backup scripts
		copy admin scripts
		install backup exec client
		install nagios client
 


by Markus Sesser