Java learning MySQL database migration (data file direct migration)

Reprinted: https://blog.csdn.net/haiross/article/details/51282377#comments,

MySQL database migration (data file direct migration)

In late October this year, the company's servers needed to be migrated, which involved MySQL database migration. Checked the MySQL data file size, close to 60G size (the actual data is not used that much). Due to business needs on the server, the loss during server migration should be minimized. Therefore, the migration time is selected to start at 0:00 in the evening, and the time used for migration should be minimized as much as possible.

There are three options before migration:

  1. Export the database directly, copy the file to the new server, and import it on the new server.
  2. Use MySQLMigrationTool in [MySQL GUI Tools].
  3. Data files and library table structure files are directly copied to the new server and mounted to the same configured MySQL service.

After testing with a virtual machine on my computer, I chose the third option that took up the least time. Here's a comparison of the three options:

 

    The advantage of the first solution: the data file will be rebuilt and the space occupied by the data file will be reduced.
    Disadvantage of the first solution: it takes a long time. (It takes a long time to import and export, and the exported files have to be transmitted over the network, which also takes a certain amount of time.)

    Advantages of the second scheme: unattended transmission after the setting is complete
    Disadvantages of the second scheme:

  1. Setup is cumbersome.
  2. If there is an abnormality in the network during transmission, it cannot be found in time, and it will stay in the state of data transmission and cannot be stopped. 
  3. The transmission time is relatively long compared to other fangs. 
  4. After an exception, it is difficult to continue the transmission from the position of the exception.

    The advantages of the third scheme: the time occupation is short, and the file can be transferred at breakpoints. Fewer steps are required. (Most of the time is in the network transmission of files) 
    Disadvantage of the third scheme: It may cause unknown problems, which have not been found for the time being.

The following describes the migration steps of the third option d :

  1. Ensure that the Mysql version is the same, and the installation configuration is basically the same (note: the data files and library table structure files here are specified in the same directory data)
  2. Stop the Mysql service on both sides (A server – migration –> B server)
  3. Delete all files in the data directory of server B Mysql
  4. Copy the files except ib_logfile and .err in the data directory of the A server Mysql to the B server data
  5. Start the Mysql service of server B to detect whether an exception occurs

After the migration is complete, the service starts normally, and no other abnormal problems are found.

The list of files in the data folder is as follows:

 

 

Note: After testing, the installation directory and data file directory of the source MySQL may be inconsistent with the installation directory and data file directory of the target MySQL.

At this point, you only need to copy the dbnames you need to move (as above: pa, testdb) and 'mysql' and 'ibdata1'.

 refer to:



MySQL database migration (data file direct migration)

In late October this year, the company's servers needed to be migrated, which involved MySQL database migration. Checked the MySQL data file size, close to 60G size (the actual data is not used that much). Due to business needs on the server, the loss during server migration should be minimized. Therefore, the migration time is selected to start at 0:00 in the evening, and the time used for migration should be minimized as much as possible.

There are three options before migration:

  1. Export the database directly, copy the file to the new server, and import it on the new server.
  2. Use MySQLMigrationTool in [MySQL GUI Tools].
  3. Data files and library table structure files are directly copied to the new server and mounted to the same configured MySQL service.

After testing with a virtual machine on my computer, I chose the third option that took up the least time. Here's a comparison of the three options:

 

    The advantage of the first solution: the data file will be rebuilt and the space occupied by the data file will be reduced.
    Disadvantage of the first solution: it takes a long time. (It takes a long time to import and export, and the exported files have to be transmitted over the network, which also takes a certain amount of time.)

    Advantages of the second scheme: unattended transmission after the setting is complete
    Disadvantages of the second scheme:

  1. Setup is cumbersome.
  2. If there is an abnormality in the network during transmission, it cannot be found in time, and it will stay in the state of data transmission and cannot be stopped. 
  3. The transmission time is relatively long compared to other fangs. 
  4. After an exception, it is difficult to continue the transmission from the position of the exception.

    The advantages of the third scheme: the time occupation is short, and the file can be transferred at breakpoints. Fewer steps are required. (Most of the time is in the network transmission of files) 
    Disadvantage of the third scheme: It may cause unknown problems, which have not been found for the time being.

The following describes the migration steps of the third option d :

  1. Ensure that the Mysql version is the same, and the installation configuration is basically the same (note: the data files and library table structure files here are specified in the same directory data)
  2. Stop the Mysql service on both sides (A server – migration –> B server)
  3. Delete all files in the data directory of server B Mysql
  4. Copy the files except ib_logfile and .err in the data directory of the A server Mysql to the B server data
  5. Start the Mysql service of server B to detect whether an exception occurs

After the migration is complete, the service starts normally, and no other abnormal problems are found.

The list of files in the data folder is as follows:

 

 

Note: After testing, the installation directory and data file directory of the source MySQL may be inconsistent with the installation directory and data file directory of the target MySQL.

At this point, you only need to copy the dbnames you need to move (as above: pa, testdb) and 'mysql' and 'ibdata1'.

 refer to:



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325591069&siteId=291194637