In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Reference implementation:
Https://www.percona.com/doc/percona-xtrabackup/LATEST/innobackupex/innobackupex_script.htmlRestoring Individual Tables#5.6 was not previously supported; In server versions prior to 5.6, it is not possible to copy tables between servers by copying the files, even with innodb_file_per_table.However, with the Percona XtraBackup, you can export individual tables from any InnoDB database, and import them into Percona Server with XtraDB or MySQL 5.6 (The source doesn't have to be XtraDB or or MySQL 5.6 but the destination does). This only works on individual .ibd files, and cannot export a table that is not contained in its own .ibd file.
Data backup:
[root@centos7x ~] $systemctl start mariadb [root@centos7x ~] $mysql
< hellodb_InnoDB.sql 默认的每个表一个文件;[root@centos7x ~]$ll /var/lib/mysql/total 122936-rw-rw---- 1 mysql mysql 16384 Feb 25 16:11 aria_log.00000001-rw-rw---- 1 mysql mysql 52 Feb 25 16:11 aria_log_control-rw-rw---- 1 mysql mysql 5 Feb 25 16:18 centos7x.piddrwx------ 2 mysql mysql 272 Feb 25 16:18 hellodb-rw-rw---- 1 mysql mysql 2795 Feb 25 16:11 ib_buffer_pool-rw-rw---- 1 mysql mysql 12582912 Feb 25 16:18 ibdata1-rw-rw---- 1 mysql mysql 50331648 Feb 25 16:18 ib_logfile0-rw-rw---- 1 mysql mysql 50331648 Feb 25 16:11 ib_logfile1-rw-rw---- 1 mysql mysql 12582912 Feb 25 16:18 ibtmp1-rw-rw---- 1 mysql mysql 0 Feb 25 16:18 multi-master.infodrwx--x--x 2 mysql mysql 4096 Feb 25 16:11 mysqlsrwxrwxrwx 1 mysql mysql 0 Feb 25 16:18 mysql.sockdrwx------ 2 mysql mysql 20 Feb 25 16:11 performance_schema-rw-rw---- 1 mysql mysql 24576 Feb 25 16:18 tc.logdrwxr-xr-x 2 mysql mysql 6 Feb 25 16:11 test[root@centos7x ~]$ll /var/lib/mysql/hellodb/total 704-rw-rw---- 1 mysql mysql 1277 Feb 25 16:18 classes.frm-rw-rw---- 1 mysql mysql 98304 Feb 25 16:18 classes.ibd-rw-rw---- 1 mysql mysql 976 Feb 25 16:18 coc.frm-rw-rw---- 1 mysql mysql 98304 Feb 25 16:18 coc.ibd-rw-rw---- 1 mysql mysql 1251 Feb 25 16:18 courses.frm-rw-rw---- 1 mysql mysql 98304 Feb 25 16:18 courses.ibd-rw-rw---- 1 mysql mysql 61 Feb 25 16:18 db.opt-rw-rw---- 1 mysql mysql 1001 Feb 25 16:18 scores.frm-rw-rw---- 1 mysql mysql 98304 Feb 25 16:18 scores.ibd-rw-rw---- 1 mysql mysql 1208 Feb 25 16:18 students.frm-rw-rw---- 1 mysql mysql 98304 Feb 25 16:18 students.ibd-rw-rw---- 1 mysql mysql 1298 Feb 25 16:18 teachers.frm-rw-rw---- 1 mysql mysql 98304 Feb 25 16:18 teachers.ibd-rw-rw---- 1 mysql mysql 973 Feb 25 16:18 toc.frm-rw-rw---- 1 mysql mysql 98304 Feb 25 16:18 toc.ibd[root@centos7x ~]$mkdir -pv /backupsmkdir: created directory '/backups'[root@centos7x ~]$innobackupex --include='hellodb.students' /backups/这只是备份了数据了;[root@centos7x ~]$ll /backups/2018-02-25_16-23-08/hellodb/total 100-rw-r----- 1 root root 1208 Feb 25 16:23 students.frm-rw-r----- 1 root root 98304 Feb 25 16:23 students.ibd 备份表定义: 所以需要将表定义也导出来;否则将来的恢复过程是需要创建表定义的;[root@centos7x ~]$mysql -e 'show create table hellodb.students\G;'*************************** 1. row *************************** Table: studentsCreate Table: CREATE TABLE `students` ( `StuID` int(10) unsigned NOT NULL AUTO_INCREMENT, `Name` varchar(50) NOT NULL, `Age` tinyint(3) unsigned NOT NULL, `Gender` enum('F','M') NOT NULL, `ClassID` tinyint(3) unsigned DEFAULT NULL, `TeacherID` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`StuID`)) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8 表破坏操作: 进行表的破坏;[root@centos7x ~]$mysql -e 'drop table hellodb.students;' MariaDB [hellodb]>Show tables +-+ | Tables_in_hellodb | +-+ | classes | | coc | | courses | | scores | | teachers | | toc | +- -+ 6 rows in set (0.00 sec)
Data and table definition restore operations:
Restore operation: tidy up first; [root@centos7x ~] $innobackupex-- apply-log-- export / backups/2018-02-25 records 16-23-08 / changes before and after collating and exporting data [root@centos7x ~] $ll / backups/2018-02-25mm 16-23-08Universe hellodb Melco r-1 root root 1208 Feb 25 16:23 students.frm-rw-r- 1 root root 98304 Feb 25 16:23 students.ibd [root@centos7x ~] $ll / backups/2018-02-25mm 16-23-08/hellodb/total 120Muk RWUR Murray-1 root root 640 Feb 25 16:49 students.cfg-rw-r-- -1 root root 16384 Feb 25 16:49 students.exp-rw-r- 1 root root 1208 Feb 25 16:23 students.frm-rw-r- 1 root root 98304 Feb 25 16:23 before students.ibd resumes the table Create the table structure first MariaDB [(none)] > use hellodb Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with-ADatabase changedMariaDB [hellodb] > CREATE TABLE `students` (- > `Name` uID` int (10) unsigned NOT NULL AUTO_INCREMENT,-> `Name` varchar (50) NOT NULL,-> `Age` tinyint (3) unsigned NOT NULL,-> `Gender` enum ('Flying Magazine M') NOT NULL,-> `ClassID` tinyint (3) unsigned DEFAULT NULL,-> `TeacherID` int (10) -> PRIMARY KEY (`StuID`)->) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8 Query OK, 0 rows affected (0.01 sec) MariaDB [hellodb] > select * from students;Empty set (0.00 sec) MariaDB [hellodb] > desc students +-+ | Field | Type | Null | Key | Default | Extra | +-+- -+ | StuID | int (10) unsigned | NO | PRI | NULL | auto_increment | | Name | varchar (50) | NO | | NULL | | Age | tinyint (3) unsigned | NO | | NULL | Gender | enum ('F') | 'M') | NO | | NULL | | ClassID | tinyint (3) unsigned | YES | | NULL | | TeacherID | int (10) unsigned | YES | | NULL | | + -+ 6 rows in set (0.00 sec) although there are table structures and data files at this time But there's no data. [root@centos7x ~] $ll / var/lib/mysql/hellodb/-htotal 704K mysql mysql RW Feb 704K Feb RW Mustang Melco-1 mysql mysql 1.3K Feb 25 16:18 classes.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 classes.ibd-rw-rw---- 1 mysql mysql 976 Feb 25 16:18 coc.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 coc.ibd-rw-rw---- 1 mysql mysql 1.3K Feb 25 16: 18 courses.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 courses.ibd-rw-rw---- 1 mysql mysql 61 Feb 25 16:18 db.opt-rw-rw---- 1 mysql mysql 1001 Feb 25 16:18 scores.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 scores.ibd-rw-rw---- 1 mysql mysql 1.2K Feb 25 16:53 students.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:53 students.ibd-rw-rw---- 1 mysql mysql 1.3K Feb 25 16:18 teachers.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 teachers.ibd-rw-rw---- 1 mysql mysql 973 Feb 25 16:18 toc.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 toc.ibd so delete this tablespace file Namely the data file But don't use rm to delete, use the command to delete MariaDB [hellodb] > alter table students discard tablespace Query OK 0 rows affected (0.00 sec) [root@centos7x ~] $ll / var/lib/mysql/hellodb/-htotal 608K classes.ibd-rw-rw-----1 mysql mysql 1.3K Feb 25 16:18 classes.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 classes.ibd-rw-rw---- 1 mysql mysql 976 Feb 25 16:18 coc.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 coc.ibd-rw-rw---- 1 Mysql mysql 1.3K Feb 25 16:18 courses.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 courses.ibd-rw-rw---- 1 mysql mysql 61 Feb 25 16:18 db.opt-rw-rw---- 1 mysql mysql 1001 Feb 25 16:18 scores.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 scores.ibd-rw-rw---- 1 mysql mysql 1.2K Feb 25 16:53 students.frm-rw-rw -1 mysql mysql 1.3K Feb 25 16:18 teachers.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 teachers.ibd-rw-rw---- 1 mysql mysql 973 Feb 25 16:18 toc.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 toc.ibd [root@centos7x] $cp / backups/2018-02-25mm 16-23-08/hellodb/students. {cfg Ibd Exp} / var/lib/mysql/hellodb/ [root@centos7x ~] $ll / var/lib/mysql/hellodb/-htotal 724K coc.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 coc.ibd-rw-rw---1 mysql mysql 1.3K Feb 25 16:18 classes.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 classes.ibd-rw-rw---- 1 mysql mysql 976 Feb 25 16:18 coc.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 -- 1 mysql mysql 1.3K Feb 25 16:18 courses.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 courses.ibd-rw-rw---- 1 mysql mysql 61 Feb 25 16:18 db.opt-rw-rw---- 1 mysql mysql 1001 Feb 25 16:18 scores.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 scores.ibd-rw-r--r-- 1 root root 640 Feb 25 16:59 students.cfg- Rw-r- 1 root root 16K Feb 25 16:59 students.exp-rw-rw---- 1 mysql mysql 1.2K Feb 25 16:53 students.frm-rw-r- 1 root root 96K Feb 25 16:59 students.ibd-rw-rw---- 1 mysql mysql 1.3K Feb 25 16:18 teachers.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 teachers.ibd-rw-rw---- 1 mysql mysql 973 Feb 25 16:18 toc.frm-rw-rw---- 1 mysql mysql 96K Feb 25 16:18 toc.ibd [root@centos7x ~] $chown-R mysql.mysql / var/lib/mysql/hellodb/ followed by importing tablespaces Although the files are placed in the data directory, the tablespaces are not associated MariaDB [hellodb] > alter table students import tablespace;Query OK, 0 rows affected (0.02 sec)
Data and table structure validation operations:
Validate MariaDB [hellodb] > select * from students +-+ | StuID | Name | Age | Gender | ClassID | TeacherID | + -+-+ | 1 | Shi Zhongyu | 22 | M | 2 | 3 | 2 | Shi Potian | 22 | M | 1 | 7 | 3 | Xie Yanke | 53 | M | 2 | 16 | 4 | Ding Dian | 32 | M | 4 | 4 |
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.