g2data strangeness

mea2214

Joined: 2005-03-03
Posts: 6
Posted: Tue, 2010-11-30 03:02

I just recently upgraded from Gallery1 to the latest Gallery2 and for all intents and purposes it went perfectly and my gallery looks and works great. I've been a user of gallery for many many years and have resisted upgrading since my original server was so old it couldn't meet many of the requirements of the modern gallery installations.

Anyway, I decided to share my gallery with a bunch of different domains that I host. I have two physical servers which I'll call server1 and server2. Server1 hosts three domains (virtual hosts using different web home directories) and server2 hosta 1 domain. Server2 points to the MySQL database of server1 but they each use a local copy of g2data where the album is stored. I could have used NFS to have server1 export g2data to server2 but my galleries don't change much so I thought I'd just use rsync between the two whenever a change happens (maybe that's not a good idea -- I don't know).

So today I make some major reorg to my albums by grouping many top level albums under a common parent just to clean things up and added a new top level album (I didn't add any photos). I meant to make server1 the master and do the reorg and just rsync the g2data directories and all would be fine. Unfortunately I accidently did the reorg on server2 so the g2data directories changed on server2 and not on server1 yet the common database that both use changed to reflect the new reorg.

So here's my conundrum. I expected the server1 gallery to be all screwed up since it was using an updated database that I assumed would have reflected a different taxonomy so I didn't think gallery would be able to find the files in its g2data/albums directory. Yet both galleries are working perfectly for reading. The only thing I couldn't do is add photos to the new albums that I added where there wasn't even a directory for in the old (server1's) g2data/albums directory.

I realize not many posts complain about things working but I'm just wondering how this is possible since I'm new to using this backend database for gallery and I don't really understand everything in the g2data directory (other than the albums directory).

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2010-11-30 14:04
Quote:
I could have used NFS

not reliably, so it's good you didn't :)

Quote:
but my galleries don't change much so I thought I'd just use rsync between the two whenever a change happens (maybe that's not a good idea -- I don't know).

Hold on, what are you trying to do? Do you have 2 separate installs of G2 pointing to the same DB using the same tables? I smell a recipe for disaster, not disaster recovery, but disaster :)

Quote:
So here's my conundrum. I expected the server1 gallery to be all screwed up since it was using an updated database that I assumed would have reflected a different taxonomy so I didn't think gallery would be able to find the files in its g2data/albums directory. Yet both galleries are working perfectly for reading.

Probably Gallery's cache on server1. I bet if you cleared it, then you'd see the issues.

Why are you doing this? If you want a backup, backup g2data AND the DB, not just g2data and share a DB.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
mea2214

Joined: 2005-03-03
Posts: 6
Posted: Wed, 2010-12-01 04:16
Quote:
Hold on, what are you trying to do? Do you have 2 separate installs of G2 pointing to the same DB using the same tables? I smell a recipe for disaster, not disaster recovery, but disaster

Actually I have four separate installs, one for each domain I host, that all point to the same DB and g2data. It seemed like I needed separate installs because I wanted the galleries to reflect their domain name and config.php seems to only allow for one domain name. Apache points the virtual hosts to their own directories which is a wordpress install so the gallery is a directory under that.

I did decide to rsync two g2data directories as a defacto way of having the albums backed up. I'm not quite sure if this is the right thing to do because I don't know what goes on with the cache, smarty, and tmp directories. I'm only worried about the album .jpg files however. And I backup the entire mysql DB periodically which has a lot more DBs than just the gallery info.

Quote:
Probably Gallery's cache on server1. I bet if you cleared it, then you'd see the issues.

Why are you doing this? If you want a backup, backup g2data AND the DB, not just g2data and share a DB.

Hmmm. I spent awhile yesterday trying to break this but couldn't. :-) After looking at the mysql tables the only thing I can think of is that the it appears the photos and albums are associated with a filename and directory name respectively in one of the tables. I assume that gallery must not care about the unix directory structure (except for uploading) and can find the file no matter where it is in the albums like one could using the unix find command. This would make sense and make things more robust

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Wed, 2010-12-01 04:53
Quote:
Actually I have four separate installs, one for each domain I host, that all point to the same DB and g2data.

Why? As far as I can tell you have a mess on your hands. They are all the same install, but you are really confusing this and making things harder for yourself.

Quote:
I assume that gallery must not care about the unix directory structure (except for uploading) and can find the file no matter where it is in the albums like one could using the unix find command. This would make sense and make things more robust

No it doesn't make any sense at all to me and I don't see how it would make things more robust. Gallery cares very much where it's files are, they must be under g2data and the DB contains all the pointer info to where the files are located.

I still don't understand what you are trying to do or what your actual problem is.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
mea2214

Joined: 2005-03-03
Posts: 6
Posted: Wed, 2010-12-08 22:36
Quote:
I still don't understand what you are trying to do or what your actual problem is.

I don't really have a problem. I'm just trying to understand what's going on in the g2data directory and encountered an unexpected behavior. When something unexpected happens, I get curious and need to understand. I did understand what went on in the albums directory in the old G1 installation and with the G2 installation with a backend DB that data directory is different. After perusing the code and the database I now have a pretty good idea how everything works.

There may be a better way of doing what I'm doing. I'm basically running a multi-site installation (I saw comments referring to this in the PHP code), all pointing to the same data set (g2data) and back end database. Each domain has its own installation with its own config.php. If there was a single installation then when someone clicked yyy.com and pointed to an installation with a config.php that had this entry:

$gallery->setConfig('baseUri', 'http://xyz.com/gallery2/main.php');

Then xyz.com would get written into their browser navigation bar. I don't want people going to yyy.com to know about xyz.com and vica versa so they each need (as far as I know) their own separate gallery installation with their own config.php -- even though they both point to the same g2data directory.

If there's a better way to have multiple sites share the same albums then I'd like to know. So far everything is working the way I have it set up.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2010-12-10 02:33
Quote:
Then xyz.com would get written into their browser navigation bar. I don't want people going to yyy.com to know about xyz.com and vica versa so they each need (as far as I know) their own separate gallery installation with their own config.php -- even though they both point to the same g2data directory.

Nope, that's not going to work. You absolutely can't have two installations share the same g2data directory. G2's architecture will not allow that.

Quote:
If there's a better way to have multiple sites share the same albums then I'd like to know. So far everything is working the way I have it set up.

The only way to have (what looks like) multiple sites share the same albums is to have one install and one set of albums, but two themes (so they look different, including different page templates, graphics etc) and then do some tweaking/hacking so that the theme for each page load is dependent on the base url through which that page is accessed.

What you have now is basically "dead gallery serving". If you get what I mean.

EDIT: stop the clock - I see what you're doing now. If both your "installs" share both the same db and the same g2data directory then they're actually the same install. Yes, you can have two codebases, and two config.php's, as long as they both have the same db and same g2data directory. But make very sure that they're running exactly the same version of code.

This is the bit of your original post that will lead to disaster:

Quote:
erver2 points to the MySQL database of server1 but they each use a local copy of g2data where the album is stored.

- Can you follow why?