數(shù)據(jù)庫遷移到auroramysql的方式介紹

本篇內(nèi)容主要講解“數(shù)據(jù)庫遷移到aurora MySQL的方式介紹”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“數(shù)據(jù)庫遷移到aurora mysql的方式介紹”吧!

我們提供的服務(wù)有:成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、衛(wèi)輝ssl等。為上千多家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的衛(wèi)輝網(wǎng)站制作公司

前言

數(shù)據(jù)庫遷移到aurora mysql的方式有以下幾種:

1 )Rds mysql遷移到aurora mysql

  • 使用rds mysql快照遷移

  • 使用rds mysql只讀副本遷移

上述兩種遷移方式非常簡單,只需在aws rds 控制臺操作即可,本片就不再進(jìn)行具體演練,具體可參考文檔

快照遷移:https://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Migrating.RDSMySQL.Import.html

只讀副本遷移:https://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Migrating.RDSMySQL.Replica.html

2)外部mysql數(shù)據(jù)庫前喲a(bǔ)urora mysql

使用mysqldump實(shí)用程序創(chuàng)建數(shù)據(jù)的轉(zhuǎn)儲,然后將該數(shù)據(jù)導(dǎo)入現(xiàn)有的aurora mysql數(shù)據(jù)庫集群。 將完整備份文件和增量文件從數(shù)據(jù)庫復(fù)制到S3存儲桶,然后從這些文件還原aurora mysql數(shù)據(jù)庫集群,速度可能比使用mysqldump遷移數(shù)據(jù)要快。

1 使用mysqldump實(shí)用程序創(chuàng)建數(shù)據(jù)庫的轉(zhuǎn)儲,然后將該數(shù)據(jù)導(dǎo)入現(xiàn)有aurora mysql數(shù)據(jù)庫集群

因?yàn)閍urora mysql與mysql兼容,所以該過程與將mysql數(shù)據(jù)導(dǎo)入rds mysql的過程類似,可參考文檔 https://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/UserGuide/MySQL.Procedural.Importing.NonRDSRepl.html。

其整體架構(gòu)如下圖所示:

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

1.1 安裝并配置好mysql數(shù)據(jù)庫

我在光環(huán)云裸金屬服務(wù)器上部署了mysql數(shù)據(jù)庫,具體部署過程略,可以百度。

1.2 創(chuàng)建mysql數(shù)據(jù)庫的副本
1.2.1 設(shè)置復(fù)制選項(xiàng)

編輯文件/etc/my.cnf sudo vi /etc/my.cnf

更新[mysqld]字段如下:

[mysqld] log-bin=mysql-bin server-id=1

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

重啟mysql服務(wù) service mysqld restart

1.2.2 創(chuàng)建現(xiàn)有數(shù)據(jù)庫的備份副本

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

上圖中新建了一個數(shù)據(jù)庫schema_xuyi,現(xiàn)在將schema_xuyi進(jìn)行備份,執(zhí)行如下命令:

mysqldump \
--databases  schema_xuyi \
--master-data=2  \
--single-transaction \
--order-by-primary \
-r backup.sql \
-u  local_user \
-p

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

圖中可見生成了備份文件backup_xuyi.sql

1.3 創(chuàng)建aurora mysql數(shù)據(jù)庫

具體創(chuàng)建過程省略,注意與此前的mysql數(shù)據(jù)庫版本盡量一致。

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

遠(yuǎn)程連接到aurora mysql數(shù)據(jù)庫,其初始狀態(tài)如下圖:

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

1.4 使用mysql命令遠(yuǎn)程連接到aurora mysql數(shù)據(jù)庫并導(dǎo)入此前的sql文件

執(zhí)行命令:

mysql -h aurora-1-instance-1.cbgpcbkn8knw.us-east-1.rds.amazonaws.com -P 3306 -u admin -p

其中aurora-1-instance-1.cbgpcbkn8knw.us-east-1.rds.amazonaws.com部分是aurora mysql數(shù)據(jù)庫的終端節(jié)點(diǎn),連接成功

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

執(zhí)行命令 source backup_xuyi.sql;

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

Workbench的刷新操作沒找到,重新連接了一下aurora mysql數(shù)據(jù)庫,可見其狀態(tài)如下:

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

其中已經(jīng)有了schema_xuyi的庫,說明mysqldump導(dǎo)入成功,本次測試只是為了驗(yàn)證從外部mysql導(dǎo)入到aurora的過程,至此本次操作完成。

2 將完整備份文件和增量文件從數(shù)據(jù)庫復(fù)制到S3存儲桶,然后從這些文件還原aurora mysql數(shù)據(jù)庫集群

參考文檔:https://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Migrating.ExtMySQL.html#AuroraMySQL.Migrating.ExtMySQL.S3

2.1 準(zhǔn)備工作
2.1.1 在本地服務(wù)器上安裝percona

本地?cái)?shù)據(jù)庫版本是mysql5.7,建議percona版本為Percona XtraBackup 2.4

執(zhí)行以下命令:

yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
yum install -y percona-xtrabackup-24.x86_64

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

從上圖可見Percona-xtrabackup安裝成功。

2.1.2 準(zhǔn)許aurora mysql訪問S3存儲桶

在跟aurora mysql數(shù)據(jù)庫相同的區(qū)域中創(chuàng)建一個存儲桶

過程比較簡單,省略。

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

創(chuàng)建IAM策略以訪問S3資源

可以通過IAM控制臺來創(chuàng)建相應(yīng)的策略,具體過程省略,可以授予aurora 訪問S3的所有權(quán)限。

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

創(chuàng)建IAM角色以允許aurora mysql訪問AWS服務(wù)

具體創(chuàng)建角色的過程省略,可以參考文檔: https://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Integrating.Authorizing.IAM.CreateRole.html

如下圖所示,創(chuàng)建了一個角色role_aurora_to_s3,并將上一步的策略附加到了該角色上。

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

將角色與aurora mysql數(shù)據(jù)庫關(guān)聯(lián)

具體操作過程見文檔 https://docs.aws.amazon.com/zh_cn/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Integrating.Authorizing.IAM.AddRoleToDBCluster.html

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

如上圖所示,已經(jīng)將角色與aurora mysql數(shù)據(jù)庫相關(guān)聯(lián)。為了讓角色生效還需要修改參數(shù)組,我們選擇新建一個參數(shù)組

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

其中參數(shù)“aurora_load_from_s3_role”的值更新為前面所創(chuàng)建角色的ARN。

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

再修改數(shù)據(jù)庫實(shí)例的數(shù)據(jù)庫選項(xiàng)

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

應(yīng)用修改,立即重啟數(shù)據(jù)庫。

2.2 備份要還原為aurora mysql的數(shù)據(jù)庫的文件
2.2.1 準(zhǔn)備工作

為了跟之前的數(shù)據(jù)庫內(nèi)容區(qū)別開來,特意新建了庫schema_test,并在其中新建了一張表table_test,如下圖所示:

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

2.2.2 使用percona xtrabackup創(chuàng)建備份

全量備份

xtrabackup --user=root --password=XY-zte110 --backup --target-dir=/root/backupfiles

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

可見在當(dāng)前目錄下生成了一個backupfiles目錄,該類目下的內(nèi)容如上圖所示。

通過aws CLI將備份文件夾整個上傳到s3存儲桶(具體上傳的過程省略),登錄s3控制臺可見

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

2.3 從S3存儲桶還原aurora mysql數(shù)據(jù)庫

登錄aurora控制臺,進(jìn)入數(shù)據(jù)庫頁面

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

在數(shù)據(jù)庫頁面點(diǎn)擊“從S3還原”, 引擎選項(xiàng)->aurora 版本->我們選擇的是mysql5.7

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

點(diǎn)擊“下一步”

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

下一步,進(jìn)入數(shù)據(jù)庫詳細(xì)信息頁面進(jìn)行設(shè)置,具體內(nèi)容與新建aurora實(shí)例的過程相似

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

下一步,配置高級設(shè)置

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

從這個配置的過程來看,跟創(chuàng)建一個新的aurora實(shí)例完全相同,由此可以斷定aurora從s3還原實(shí)際上是重新起了一個aurora實(shí)例。最后點(diǎn)擊“創(chuàng)建數(shù)據(jù)庫”

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

確實(shí)是新生成一個數(shù)據(jù)庫實(shí)例,耐心等待吧。

切換到數(shù)據(jù)庫頁面,可以看到有兩個aurora實(shí)例

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

上圖中的實(shí)例aurora-instance-xuyi-copy就是從s3還原出來的新的aurora實(shí)例,已經(jīng)成功創(chuàng)建。現(xiàn)在遠(yuǎn)程到該實(shí)例查看數(shù)據(jù)庫狀況

數(shù)據(jù)庫遷移到aurora mysql的方式介紹

可見全量復(fù)制成功。 至此通過S3還原aurora數(shù)據(jù)庫完成。

到此,相信大家對“數(shù)據(jù)庫遷移到aurora mysql的方式介紹”有了更深的了解,不妨來實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

網(wǎng)站標(biāo)題:數(shù)據(jù)庫遷移到auroramysql的方式介紹
文章路徑:http://muchs.cn/article26/gecicg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、Google虛擬主機(jī)、服務(wù)器托管、品牌網(wǎng)站設(shè)計(jì)、ChatGPT

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都seo排名網(wǎng)站優(yōu)化