To get the most consistent results with a raw data snapshot you should shut down the server during the process, as below:
Acquire a read lock and get the master's status.
-
In a separate session, shut down the MySQL server:
shell>
mysqladmin shutdown
-
Make a copy of the MySQL data files. Examples are shown below for common ways to do this - you need to choose only one of them:
shell>
tar cf
/tmp/db.tar
./data
shell>zip -r
/tmp/db.zip
./data
shell>rsync --recursive
./data
/tmp/dbdata
Start up the MySQL instance on the master.
If you are not using InnoDB
tables, you can get a snapshot of the system from a master without shutting down the server as described in the following steps:
Acquire a read lock and get the master's status.
-
Take a copy of the MySQL data files. Examples are shown below for common solutions - you need to choose only one of these solutions:
shell> tar cf
/tmp/db.tar
./data
shell> zip -r/tmp/db.zip
./data
shell> rsync --recursive./data
/tmp/dbdata
-
In the client where you acquired the read lock, free the lock:
mysql> UNLOCK TABLES;
Once you have created the archive or copy of the database, you will need to copy the files to each slave before starting the slave replication process.
Tidak ada komentar:
Posting Komentar