Re: MySQLDump and master/slave Behavior
| From: | Jon Anderson | Date: | Tue, 03 Oct 2006 17:23:42 +0000 |
| Subject: | Re: MySQLDump and master/slave Behavior | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-242547@lists.php.net to get a copy of this message | ||
David Giragosian wrote:
So, Question 1 is: does mysqldump's connection to the slave db exist for the entire script execution time, or just for the length of time of its own execution? I imagine if I used mysql_connect() in the script that it would be for the entire length of the script execution, but mysqldump makes its own connection, so I'm just not sure about this. Running mysqldump (an external program), the connection will only exist while mysqldump is running. PHP's connections and that of external programs are mostly unrelated. Besides, your problem isn't the connection, it's the locking that you're worried about. You can pass options to mysqldump to tell it to do as little locking as possible. That's what I do, considering that running mysqldump on a live database doesn't give you a totally up-to-date snapshot anyway. (I.e. as soon as you take a snapshot with mysqldump, it's out of date the instant there's another insert/update.)
Question 2: Should I, just to be on the safe side, break out the mysqldump code into its own scipt, and run it, say, 30 minutes before the tar script? I don't think it matters. See above. I put my sql dump scripts into simple bash scripts that run from cron, but if you're more comfortable with PHP, I don't see any reason to switch nor to break it out.jon