遇到的一个mysql备份恢复的问题
数据库特点
--使用partition,存在上百个分区
--建表时指定了data_dir和index_dir,数据不是存储在默认位置,而是在mysqld的数据目录下link到真正的数据文件
备份恢复要求
--备份出来的数据恢复时要恢复成不同的表名
--恢复出来的数据实际存储位置也要存储在与原表不同的位置
问题
如果直接mysqldump-source恢复-change table name,则新表的存储位置无法满足要求,link到的位置必然是错误的,需要修改mysqld数据目录下的数百个软链接
备份过程
mysqldump -uroot -p$dbpassword -h$srcip $dbname $tablename > $tablename.data
信息修改过程
sed -e "s/$origname/$newname/g" $tablename.data > $tablename.data.tmp1
rm -f $tablename.data
sed -e "s/$origloc/$newloc/g" $tablename.data.tmp1 > $tablename.data.tmp2
rm -f $tablename.data.tmp1
mv $tablename.data.tmp2 $tablename.data
恢复过程
mysql -u$dbuser -p$dbpassword -h$destip -e"$createdbsql"
mysql -u$dbuser -p$dbpassword -h$destip $dbname -e"source $tablename.data"
相关文档:
NDBCLUSTER
(also known as NDB
) is an in-memory
storage engine offering high-availability and data-persistence
features.
The NDBCLUSTER
storage engine can be
configured with a range of failover and load-balancing options,
but it is easiest t ......
This section is a “How-To
” that describes the basics
for how to plan, install, configure, and run a MySQL Cluster.
Whereas the examples in
Chapter 3, MySQL Cluster Configuration
provide more in-depth
information on a variety of clustering options and co ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using MySql.Data.MySqlClient;
namespace i_salesDAL
{
public class DBHelper
{
//引导数据库连接数据库调用Web.Config文件
private static MySqlConnection connection;
//创建 ......
导出整个数据库:mysqldump -u用户名 -p密码 需要导出的数据库名 > 导出文件名.sql
其他参数:
-d 不包含数据,只有数据库表结构
--add-drop-table 在每个create语句之前增加一个drop
--skip-opt 每条记录只对应一个insert语句 ......