首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

如何应对超大数据库在线迁移、归档和超大数据备份?

1、超大数据库的在线迁移问题和归档问题

随着信息的大爆炸,互联网各种业务的发展,超大、超级大的数据库都已经出现,先说一下迁移问题,oracle的迁移有很多种方案,迁移T级数据目前有XTTS等官方推荐的一些方案,PB级数据那就需要专业团队来根据实际情况来做一个完善的迁移方案。目前我也没接触过这种数据库的迁移,希望能和大家共同学习。再来说一下mysql超大的数据库,T级以上的单数据库在生产环境中不是很多,所以迁移的难点可能就是在于分库分表,数据库一致等问题,在这里分享几个可用方案:

方案1

In this case, normally, the best solution is a mysqldump using the --tab option like this:

mysqldump --tab=/path/to/serverlocaldir --single-transaction table_a

tab option produce 2 file, one file -table_a.sql- that contains only the table create statement and the oher file -table_a.txt- contains tab-separated data.

Now you can create your new table

create table table_b like table_a;

Then you simply load data in your new table via LOAD DATA without care for the table's name.

LOAD DATA INFILE '/path/to/serverlocaldir/table_a.txt'

INTO TABLE table_b FIELDS TERMINATED BY '' ...

LOAD DATA is usually 20 times faster than using INSERT statements.

LOAD DATA速度比INSERT语句要快,这里其实倒入也可以使用mysqlimport命令

方案2

I recently moved a 30GB database with the following stragegy:

Old Server

Stop mysql server

Copy contents of datadir to another location on disk (~/mysqldata/*)

Start mysql server again (downtime was 10-15 minutes)

copy the compressed file to new server

New Server

install mysql (don't start)

move contents of mysqldata to the datadir

Make sure your innodb_log_file_size is same on new server, or if it's not, don't copy the old log files (mysql will generate these)

Start mysql

这种方法就是直接复制数据库的文件结构,要求必须相同的mysql版本,和相同的配置才可以用这种方法

方案3

If you are considering migrating to another DB Server with the exact same version of MySQL, you may want torsync the datadir from the old server to the new server.

This will work regardless of InnoDB file layout or even the presence of MyISAM tables.

install the same version of mysql on ServerB that ServerA has

On ServerA, run RESET MASTER; to erase all binary logs before the rsycn process. If binary logging is not enabled, you can skip this step.

On ServerA, run SET GLOBAL innodb_max_dirty_pages_pct = 0; from mysql and about 10 minutes (This purges dirty pages from the InnoDB Buffer Pool. It also helps perform a mysql shutdown faster) If your database is all MyISAM, you can skip this step.

rsync /var/lib/mysql of ServerA to /var/lib/mysql on ServerB

Repeat Step 3 until an rsync takes less than 1 minute

service mysql stop on ServerA

Perform one more rsync

scp ServerA:/etc/my.cnf to ServerB:/etc/.

service mysql start on ServerB

service mysql start on ServerA (optional)

Essentially, here is what such a script would like this

其实这个跟方案2是一样的。只是操作方法不同而已,当然要求也是一样的。

2、超大数据备份问题

超大数据备份其实和迁移归档都能放在一起说,这里单独拿出来总结一下就是因为备份和迁移毕竟是两个概念,大家关注的也比较多。

数据备份是容灾的基础,有了备份不等于万事大吉。因为备份的数据可以还会有其他因素造成的数据损坏,如地震、火灾等,对于这些企业应该在数据容灾方面提升能力,来进一步应对数据抵抗潜在不安全因素的能力。当然,数据备份还是最基础的形式,没有数据备份,任何容灾都没有现实意义。目前来看,主要的数据备份方式如下:

定期磁带备份:包括远程磁带库、光盘库备份和远程关键数据+磁带备份。

数据库备份:就是在与主数据库所在生产机相分离的备份机上建立主数据库的一个拷贝。

网络数据:这种方式是对生产系统的数据库数据和所需跟踪的重要目标文件的更新进行监控与跟踪,并将更新日志实时通过网络传送到备份系统,备份系统则根据日志对磁盘进行更新。

远程镜像:通过高速光纤通道线路和磁盘控制技术将镜像磁盘延伸到远离生产机的地方,镜像磁盘数据与主磁盘数据完全一致,更新方式为同步或异步。

这些措施能够在系统发生故障后进行系统恢复。但是这些措施一般只能处理计算机单点故障,对区域性、毁灭性灾难则束手无策,也不具备灾难恢复能力。所以我们就需要建立异地容灾中心,做数据的远程备份,在灾难发生之后要确保原有的数据不会丢失或者遭到破坏。建立的异地容灾中心可以简单地把它理解成一个远程的数据备份中心。数据容灾的恢复时间比较长,但是相比其他容灾级别来讲它的费用比较低,而且构建实施也相对简单。主要的实施方法如下:

实时复制:当主中心的数据库内容被修改时,备份中心的数据库内容实时地被修改,此种复制方式对网络可靠性要求高。

定时复制:当主中心的数据库内容被修改时,备份中心的数据库内容会按照时间间隔,周期性地按照主中心的更新情况进行刷新,时间间隔可长(几天或几个月)可短(几分钟或几秒钟)。

存储转发复制:当主中心的数据库内容被修改时,主中心的数据库服务器会先将修改操作Log存储于本地,待时机成熟再转发给备份中心。

由社区会员岳彩波分享

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20190212B04GE000?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券
http://www.vxiaotou.com