易截截图软件、单文件、免安装、纯绿色、仅160KB

遇到的一个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"


相关文档:

MYSQL数据库优化摘录

1、选取最适用的字段属性
  MySQL可以很好的支持大数据量的存取,但是一般说来,数据库中的表越小,在它上面执行的查询也就会越快。因此,在创建表的时候,为了获得更好的性能,我们可以将表中字段的宽度设得尽可能小。例如,在定义邮政编码这个字段时,如果将其设置为CHAR(255),显然给数据库增加了不必要的空间,甚至使 ......

Quick Test Setup of MySQL Cluster


To familiarize you with the basics, we will describe the simplest
possible configuration for a functional MySQL Cluster. After this,
you should be able to design your desired setup from the
information provided in the other relevant sections of this
chapter.
......

MySQL Cluster Configuration — Basic Example


To support MySQL Cluster, you will need to update
my.cnf
as shown in the following example.
You may also specify these parameters on the command line when
invoking the executables.

Note
The options shown here should not be confused with thos ......

MySQL Cluster配置step by step

MySQL Cluster配置step by step
来源:http://space.itpub.net/15415488/viewspace-620903
公司有个项目是测试distributed DB,其中一项是针对MySQL Cluster的测试。
于是花了两天时间装机器和配置MySQL Cluster。整个过程还是比较顺利的,当然如果对MySQL常用命令比较熟悉的话会更顺利。
留下step by step配 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号