Hackish HOWTO: migrating a (larger) running OpenX installation to a new machine +

Disclaimer: It’s a hack, but it worked :) You’re doing this at your own risk! Copying raw Mysql database files may corrupt your data to the point of no return!

First, a little background information: we’ve been using OpenAds / OpenX even back in the days when it was called phpAdsNew.

Last fall (septmeber to be exact) we’ve launched a new website, that ran OpenAds, a Vbulletin forum, and a custom CMS / application for other parts of the site.

At the beginning a single server was able to handle it all. Recently, however, the site usage grew, and the OpenX database grew to around 1.5GB in size, serving around 7 million ad impressions per month.

A new server appeared and it was decided we’re gonna move OpenX to its own dedicated machine.

Trying to dump the database contents to .sql files was proven to not be doable (without taking the server down for maintenance, which we felt was not good for our users). We wanted to migrate it without taking the server down and users noticing anything (if possible).

So, another solution was to be found, and here’s how we hacked it, in case someone else finds themselves in a similar situation:

  • create a new empty database on the new server
  • scp the raw *.frm, *.myd and *.myi files from your old server’s mysql data dir to the newly created db’s data dir on the new server
  • chown the newly copied files to the appropriate user/group under which mysql is running on the new server (if different from the old one)
  • run mysqlrepair –database new_server_db_name –repair (see http://dev.mysql.com/doc/refman/5.1/en/mysqlcheck.html for more info and options)
  • scp the OpenX files over to the new server and chown/chmod appropriately
  • modify the OpenX config file in var/ if you’re changing the server’s public address and stuff like that

And that’s it. Everything worked after that.

After seeing that it all works, we upgraded to the latest OpenX release (2.4.7 at the time of writing) by just following the upgrade docs from the manual.

Once again, keep in mind that copying raw db files might cause MAJOR PROBLEMS, incompatibility issues, data inconsistencies etc.

You’re doing this at your own risk. Make sure that the Mysql versions are the same on both servers.

9 Responses to “Hackish HOWTO: migrating a (larger) running OpenX installation to a new machine”

  1. Oh my, sounds like fun. I’ve used this technique so many times – I consider it to be 100% legit. :) I’ve lost mysql users and roles few times when I copied data between different mysql versions, but yes in situation like yours it’s acceptable risk.

  2. Hey. I know this post is really old but i find myself in a situation where my tinkering has left openx all messed up. The permissions on files are off although it is still serving ads.
    Do you think i should just move everything to a new database?

  3. Yo. Permissions on database files or the permissions on openx web-served files? Fixing either of the permission based issues should be a breeze — just chown and chmod the appropriate files.

    Moving to a new database might not fix your issue anyway. Fix the permissions first, since it should be a really simple, non-disruptive thing to do, and only then asses if you really need to move to a new db or not.

    Yes, you can mess up ad-serving if you assign the wrong owner and wrong permissions on any of the files, but you can always do a backup before you do anything. Or just have someone experienced in those things take a look and see what’s really going on.

  4. Hey again. Thanks for answering. A two year old post yielded a faster response than the godaddy support… go figure!
    Well, its the web served files that are messed up. I cant chmod them though cause the permission on them is 0000 and im on godaddy (not sure which) so chmod is giving out a permission error. i filed a ticket at godaddy though.

    Here’s my backup plan though maybe you can tell me what you think:
    I install another instance of openx, i put the old config file in it, copy the banners, and thats about it:)
    What do you think?

  5. If you don’t care for existing stats, users, campaigns and whatnot, sure. Give it a go while waiting for your ticket to be resolved :))

  6. i did and well its not good:P i do care:(
    Whats the alternative?

  7. actually here’s what im doing right now. Im copying everything from my old admin directory to the new one. I dont beleive it’ll work but its worth a shot:)

  8. If the db is fine, just install a fresh openx copy in a new folder. Verify that it works in the new location (use same db prefix for tables, just different database name while installing the new copy). If it seems ok, you should probably be able to change the db name in the config file of the new install to point it to the old database that has all the data already. After just copy over the banners (if they’re stored on the filesystem and not in the db).
    It could work, gl :)

  9. well that works!
    Only problem though its all buggy but that can be sorted out.
    Thanks a bunch sir!