日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

INNODB表快速迁移

發布時間:2025/3/15 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 INNODB表快速迁移 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本實驗在一臺server上啟動了2個mysql實例端口分別是3307?? 3308,目的是將3307的表aaa遷移到3308中去,并打開3308的slave

?

1.在3308上

mysql> drop table aaa;?? 干表
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE `aaa` (
??? ->?? `id` int(2) DEFAULT NULL
??? -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;?? 創建和3307上結構一樣的空表
Query OK, 0 rows affected (0.00 sec)

在操作系統層面看下數據文件

[root@canal3 leochentest]# ll
total 112
-rw-rw---- 1 mysql mysql? 8556 Feb 23 11:50 aaa.frm
-rw-rw---- 1 mysql mysql 98304 Feb 23 11:50 aaa.ibd
-rw-rw---- 1 mysql mysql??? 61 Feb? 8 14:17 db.opt


mysql> alter table aaa discard tablespace;???? 干掉ibd數據文件
Query OK, 0 rows affected (0.00 sec)

[root@canal3 leochentest]# ll
total 16
-rw-rw---- 1 mysql mysql 8556 Feb 23 11:50 aaa.frm
-rw-rw---- 1 mysql mysql?? 61 Feb? 8 14:17 db.opt

?

2 在3307上

mysql> use leochentest;
Database changed
mysql>
mysql>
mysql>
mysql> flush tables aaa for export;????? 鎖表,并產生一個tablename.cfg的文件
Query OK, 0 rows affected (0.00 sec)

3. 在3307上將數據aaa.cfg和aaa.ibd文件拷貝到3308的對應目錄下

[root@canal3 leochentest]# cp aaa.{cfg,ibd} /data/mysql/3308/data/leochentest

3307上解鎖表
mysql> unlock tables;
Query OK, 0 rows affected (0.00 sec)

?

4.3308上執行導入表空間的文件,并打開slave

mysql> Alter table aaa import tablespace;
Query OK, 0 rows affected (0.01 sec)

mysql> select * from aaa;
+------+
| id?? |
+------+
|??? 1 |
+------+
1 row in set (0.00 sec)

mysql> start slave ;
Query OK, 0 rows affected (0.01 sec)

mysql> show slave status\G;
*************************** 1. row ***************************
?????????????? Slave_IO_State: Waiting for master to send event
????????????????? Master_Host: 10.40.20.44
????????????????? Master_User: repl
????????????????? Master_Port: 3307
??????????????? Connect_Retry: 60
????????????? Master_Log_File: canal3-bin.000002
????????? Read_Master_Log_Pos: 19705
?????????????? Relay_Log_File: canal3-relay-bin.000010
??????????????? Relay_Log_Pos: 284
??????? Relay_Master_Log_File: canal3-bin.000002
???????????? Slave_IO_Running: Yes
??????????? Slave_SQL_Running: Yes
????????????? Replicate_Do_DB:
????????? Replicate_Ignore_DB:
?????????? Replicate_Do_Table:
?????? Replicate_Ignore_Table:
????? Replicate_Wild_Do_Table:
? Replicate_Wild_Ignore_Table:
?????????????????? Last_Errno: 0
?????????????????? Last_Error:
???????????????? Skip_Counter: 0
????????? Exec_Master_Log_Pos: 19705
????????????? Relay_Log_Space: 622
????????????? Until_Condition: None
?????????????? Until_Log_File:
??????????????? Until_Log_Pos: 0
?????????? Master_SSL_Allowed: No
?????????? Master_SSL_CA_File:
?????????? Master_SSL_CA_Path:
????????????? Master_SSL_Cert:
??????????? Master_SSL_Cipher:
?????????????? Master_SSL_Key:
??????? Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
??????????????? Last_IO_Errno: 0
??????????????? Last_IO_Error:
?????????????? Last_SQL_Errno: 0
?????????????? Last_SQL_Error:
? Replicate_Ignore_Server_Ids:
???????????? Master_Server_Id: 3307
????????????????? Master_UUID: bbbe1742-0a4b-11e8-b0c0-00000a28142c
???????????? Master_Info_File: /data/mysql/3308/data/master.info
??????????????????? SQL_Delay: 0
????????? SQL_Remaining_Delay: NULL
????? Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
?????????? Master_Retry_Count: 86400
????????????????? Master_Bind:
????? Last_IO_Error_Timestamp:
???? Last_SQL_Error_Timestamp:
?????????????? Master_SSL_Crl:
?????????? Master_SSL_Crlpath:
?????????? Retrieved_Gtid_Set:
??????????? Executed_Gtid_Set:
??????????????? Auto_Position: 0
1 row in set (0.00 sec)

ERROR:
No query specified

轉載于:https://www.cnblogs.com/leochenliang/p/8461844.html

總結

以上是生活随笔為你收集整理的INNODB表快速迁移的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。