Distributed File of MySQL

Distributed file using InnoDB for a storage engine is set up.
In my case, since the table etc. was already created, it worked including data shift.

As a flow of work, it is as in general follows.
1.Export of data.
2.Back up data directory of MySQL data.
3.Change of my.cnf
4.Import of data.

1.mysqldump is used and it is export of a database (a definition is included).
[root@c1 mysql]# mysqldump --user=root --password={PASSWORD} --socket=/tmp/mysql.sock --single-transaction --master-data --flush-logs --hex-blob --default-character-set=utf8 --all-databases --result-file=/tmp/all-backup.dmp

2.The existing data storage directory is saved by an alias.

[root@c1 mysql]#mv mysql mysql.bak

3.A data storage directory is created newly.

[root@c1 mysql]# mkdir ./mysql/archive ./mysql/data ./mysql/data1 ./mysql/data2 ./mysql/logdir
[root@c1 mysql]# chown -R mysql:mysql archive data data1 data2 logdir

4.Change of my.cnf.

The following is added.

innodb_data_home_dir =
innodb_data_file_path = /home/mysql/data1/ibdata1:300M;/home/mysql/data2/ibdata2:300M
innodb_file_per_table

When distributing a data file, innodb_data_home_dir is emptied, and a data file is specified by innodb_data_file_path.
The above-mentioned example creates mysql/data1/ibdata1 and mysql/data2/ibdata2 by 300M, respectively.

5.Import of data.

Starting of MySQL

The following option is attached and MySQL is started.
[root@c1 mysql]# mysqld_safe --defaults-file=/etc/my.cnf --skip-networking --skip-grant-tables &

Import of data.

[root@c1 mysql]# mysql --user=root --password={PASSWORD} --socket=/tmp/mysql.sock < /home/share/dev/mysql/archive/all-20080216.dmp

Stop of MySQL

[root@c1 mysql]# /etc/rc.d/init.d/mysql stop
Shutting down MySQL. [ OK ]

Deletion of a log

Since it is unnecessary that some logs for a relay are created when it imports, it deletes.
[root@c1 data]# cd /home/mysql/data
[root@c1 data]# rm -rf c1-relay-bin.000001 c1-relay-bin.index master.info relay-log.info

Starting of MySQL

[root@c1 mysql]# /etc/rc.d/init.d/mysql start
Starting MySQL. [ OK ]

MySQLによる最速RDBMS構築ガイドMySQLによる最速RDBMS構築ガイド
(2005/09/17)
鶴長 鎮一、MCEA DB研究会 他

商品詳細を見る