Announcement

  •  » Website
  •  » New server, details

#1 2013-04-09 10:10:37

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13220

New server, details

Hi,

Yesterday I moved piwigo.org/piwigo.us to a new server.

* CPU before: Intel Core2 Quad Q8300@2.50GHz (benchmark 3066), after: Intel Xeon E3-1225 V2@3.20GHz (benchmark 6801)

* hard disks before: 750GB, after: 2x2TB RAID1

* memory before: 4GB, after: 16GB

+shorter delay on technical failures

First I moved all files with rsync. Then I moved all databases with a mysqldump + transfert + ssh call to import dump on remote server:

Code:

#!/bin/sh

root_dest_temp=/home/sys/tmp/databases
date_backup=$(date +"%Y%m%d_%H%M%S")
local_mysql_user=root
local_mysql_password=************************
remote_mysql_user=root
remote_mysql_password=***************************

for database in $(echo 'show databases;' | mysql --user=$local_mysql_user --password=$local_mysql_password | grep -v Database)
do
  dest_temp=$root_dest_temp"/"$database"/";
  filename=$dest_temp"/"$database"-"$date_backup".sql"

  if [ ! -e $dest_temp ]
  then
    mkdir -p $dest_temp
  fi

  echo "dumping "$database
  mysqldump --user=$local_mysql_user --password=$local_mysql_password --databases $database > $filename
  gzip $filename

  # send the dump
  rsync -av $root_dest_temp ns331371.ovh.net:/home/sys/tmp/

  # load the dump on the backup server
  ssh ns331371.ovh.net 'zcat /home/sys/tmp/databases/'$database'/'$database'-'$date_backup'.sql.gz | mysql --user='$remote_mysql_user' --password='$remote_mysql_password

done

Then I opened an SSH tunnel from the old server to the new server, mapping 127.0.0.1:3406 to port 3306 on the new server. I then modified forums connection settings (and many other services on the server) to 127.0.0.1:3406 so that everybody uses database on the new server.

Code:

autossh -T -L 3406:localhost:3306 root@ns331371.ovh.net

On the old server, I stopped SVN commits with a hooks/pre-commit (exit 1)

Eventually I changed the DNS zone to the new IP address and waited for everybody to go on the new server.

As far as I can see, piwigo.org didn't go down for a single second and no data was lost thanks to SSH tunnel. SSH tunnel rocks!

Offline

 

#2 2013-04-09 14:31:08

flop25
Piwigo Team
2006-07-06
6964

Re: New server, details

Interesting! thx for sharing


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#3 2013-04-21 02:26:09

romaint
Member
2013-04-21
1

Re: New server, details

Why did you use a SSH tunnel to connect to MySQL server ? Is it less secure to connect directly on port 3306 on new server ?

Offline

 

#4 2013-04-21 09:09:55

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13220

Re: New server, details

romaint wrote:

Why did you use a SSH tunnel to connect to MySQL server ? Is it less secure to connect directly on port 3306 on new server ?

SSH tunnel is of course more secure than opening remote connections on MySQL. Moreover, opening remote connections requires a restart of MySQL, not the SSH tunnel.

Offline

 

#5 2013-05-01 22:40:49

Greybrow
Translation Team
1970-01-01
12

Re: New server, details

Good job, and nice read :)

Offline

 
  •  » Website
  •  » New server, details

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2019 · Contact