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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql udb_将Uhost上的MySQL迁移到UDB

發布時間:2023/12/31 数据库 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql udb_将Uhost上的MySQL迁移到UDB 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

不導出指定表,如果有多個表不需要導出,需要使用多個--ignore-table 參數

--master-data=[1|2] 如果設置--master-data=1將會顯示如下信息:

--

-- Position to start replication or point-in-time recovery from

--

CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000003', MASTER_LOG_POS=3018292;

--

這樣如果設置SLAVE的時候就不需要再單獨指定MASTER_LOG_FILE和MASTER_LOG_POS

如何設置--master-data=2,CHANGE MASTER TO 這一行將被注釋掉,當設置SLAVE的同步需要按照這里的提示設置MASTER_LOG_FILE和MASTER_LOG_POS

設置--master-data參數,配合--single-transaction參數可以不鎖表。

--single-transaction 保證備份數據的一致性,目前支持InnoDB

--quick Don't buffer query, dump directly to stdout.

-R 導出函數和存儲過程

--event Dump events

2.導入數據到UDB

如果數據量太大,導入的時間會很長,可以使用screen開一個窗口,可以隨時查看進度

mysql -h10.4.21.160 -uroot -p

mysql> source mysql_data20150203.sql

這里導入數據的時候有幾個小故障,由于UDB默認設置為Master,開啟了binlog,所以導入數據的時候UDB的binlog增長太快,把500G磁盤寫滿后,導入失敗。

可以設置導入的時候不寫入binlog

SET sql_log_bin=0

由于使用mysqldump導出的時候使用了 -A 參數,沒有過濾掉mysql庫,所以如果Uhost的MySQL里面沒有設置除了root賬號外具有合適權限登錄的賬號,那么在以下設置Slave的時候就會出錯。

這種情況下,可以使用--skip-grant-tables參數重新啟動UDB,然后再重新設置root賬號密碼。

3.設置UDB為MySQL Slave,從Uhost上的MySQL同步數據

CHANGE MASTER TO MASTER_HOST='10.4.3.149',MASTER_PORT=3306,MASTER_USER='repl_user',MASTER_PASSWORD='xyzzy',MASTER_LOG_FILE='mysql-bin.000003', MASTER_LOG_POS=3018292;

同步過程中,查看Slave的狀態信息,主要觀察以下幾個參數

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Seconds_Behind_Master: 0

在同步過程中,Seconds_Behind_Master 數值會越來越小,如果同步出錯,會有報錯信息顯示

mysql> show slave status\G

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 10.4.3.149

Master_User: repl_user

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000005

Read_Master_Log_Pos: 925459151

Relay_Log_File: mysql-relay.000012

Relay_Log_Pos: 294731160

Relay_Master_Log_File: mysql-bin.000005

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: 925459151

Relay_Log_Space: 294731312

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: 1

1 row in set (0.00 sec)

mysql>

4.停掉Uhost上的MySQL

5.更改程序里面的MySQL連接信息

6.取消UDB的Slave設置

先使用STOP SLAVE;命令停掉UDB上的SLAVE設置mysql> stop slave;

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show slave status\G

*************************** 1. row ***************************

Slave_IO_State:

Master_Host: 10.4.3.149

Master_User: repl_user

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000006

Read_Master_Log_Pos: 351201559

Relay_Log_File: mysql-relay.000016

Relay_Log_Pos: 15191656

Relay_Master_Log_File: mysql-bin.000006

Slave_IO_Running: No

Slave_SQL_Running: No

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: 351201559

Relay_Log_Space: 15191808

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: NULL

Master_SSL_Verify_Server_Cert: No

Last_IO_Errno: 2003

Last_IO_Error: error reconnecting to master 'repl_user@10.4.3.149:3306' - retry-time: 60 retries: 86400

Last_SQL_Errno: 0

Last_SQL_Error:

Replicate_Ignore_Server_Ids:

Master_Server_Id: 1

1 row in set (0.00 sec)

mysql>mysql> reset slave all;

Query OK, 0 rows affected (0.02 sec)

mysql> show slave status\G

Empty set (0.00 sec)

然后使用RESET SLAVE ALL;命令清楚UDB上的SLAVE設置。

本條技術文章來源于互聯網,如果無意侵犯您的權益請點擊此處反饋版權投訴

本文系統來源:php中文網

本站所有資源全部來源于網絡,若本站發布的內容侵害到您的隱私或者利益,請聯系我們刪除!

合作方式

Copyright ? 2004-2018 https://www.gxlcms.com/. All Rights Reserved.

豫ICP備19030742號

總結

以上是生活随笔為你收集整理的mysql udb_将Uhost上的MySQL迁移到UDB的全部內容,希望文章能夠幫你解決所遇到的問題。

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