xtrabackup8备份Mysql8.0.18的过程是怎么样的
这篇文章给大家介绍xtrabackup 8备份MySQL 8.0.18的过程是怎么样的,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
创新互联一直在为企业提供服务,多年的磨炼,使我们在创意设计,成都全网营销推广到技术研发拥有了开发经验。我们擅长倾听企业需求,挖掘用户对产品需求服务价值,为企业制作有用的创意设计体验。核心团队拥有超过十载以上行业经验,涵盖创意,策化,开发等专业领域,公司涉及领域有基础互联网服务服务器托管、成都app软件开发公司、手机移动建站、网页设计、网络整合营销。
1、首先 在mysql8里先建了一个稍微大一点的测试表,脚本:
CREATE TABLE user100w( id INT NOT NULL AUTO_INCREMENT, first_name VARCHAR(10) NOT NULL, last_name VARCHAR(10) NOT NULL, sex VARCHAR(5) NOT NULL, score INT NOT NULL, copy_id INT NOT NULL, PRIMARY KEY (`id`)); DROP PROCEDURE IF EXISTS add_user; DELIMITER // create PROCEDURE add_user(in num INT) BEGIN DECLARE rowid INT DEFAULT 0; DECLARE firstname CHAR(1); DECLARE name1 CHAR(1); DECLARE name2 CHAR(1); DECLARE lastname VARCHAR(3) DEFAULT ''; DECLARE sex CHAR(1); DECLARE score CHAR(2); WHILE rowid < num DO SET firstname = SUBSTRING('赵钱孙李周吴郑王林杨柳刘孙陈江阮侯邹高彭徐',FLOOR(1+21*RAND()),1); SET name1 = SUBSTRING('一二三四五六七八九十甲乙丙丁静景京晶名明铭敏闵民军君俊骏天田甜兲恬益依成城诚立莉力黎励',ROUND(1+43*RAND()),1); SET name2 = SUBSTRING('一二三四五六七八九十甲乙丙丁静景京晶名明铭敏闵民军君俊骏天田甜兲恬益依成城诚立莉力黎励',ROUND(1+43*RAND()),1); SET sex=FLOOR(0 + (RAND() * 2)); SET score= FLOOR(40 + (RAND() *60)); SET rowid = rowid + 1; IF ROUND(RAND())=0 THEN SET lastname =name1; END IF; IF ROUND(RAND())=1 THEN SET lastname = CONCAT(name1,name2); END IF; insert INTO user100w (first_name,last_name,sex,score,copy_id) VALUES (firstname,lastname,sex,score,rowid); END WHILE; END //DELIMITER ; call add_user(10000);
2、yum安装依赖
[root@centos1 ~]# yum install libev
3、下载xtrabackup后,直接用yum安装
[root@centos1 opt]# wget https://www.percona.com/downloads/Percona-XtraBackup-LATEST/Percona-XtraBackup-8.0-7/binary/redhat/7/x86_64/percona-xtrabackup-80-8.0.7-1.el7.x86_64.rpm
Saving to: ‘percona-xtrabackup-80-8.0.7-1.el7.x86_64.rpm’ 100%[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=======================>] 12,177,712 22.2KB/s in 2m 20s 2019-11-08 17:39:37 (21.5 KB/s) - ‘percona-xtrabackup-80-8.0.7-1.el7.x86_64.rpm’ saved [12177712/12177712] [root@centos1 opt]# yum localinstall percona-xtrabackup-80-8.0.7-1.el7.x86_64.rpm Installed: percona-xtrabackup-80.x86_64 0:8.0.7-1.el7 Dependency Installed: perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBD-MySQL.x86_64 0:4.023-6.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-Digest.noarch 0:1.17-245.el7 perl-Digest-MD5.x86_64 0:2.52-3.el7 perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 Complete! [root@centos1 opt]# xtrabackup -vxtrabackup: recognized server arguments: --datadir=/var/lib/mysql xtrabackup version 8.0.7 based on MySQL server 8.0.16 Linux (x86_64) (revision id: 069e0e6)
问题来了 我的mysql是8.0.18的(装好之后发现并没有什么问题)
4、开始备份
一些参数:
According to your system, you may need to specify one or more of the following options to connect to the server:
Option | Description |
---|---|
–port | The port to use when connecting to the database server with TCP/IP. |
–socket | The socket to use when connecting to the local database. |
–host | The host to use when connecting to the database server with TCP/IP. |
备份(如果不是localhost的远程备份的话,mysql需要更新User表可以远程登录):
[mysql@centos1 ~]$ xtrabackup --defaults-file=/data/mysql/my.cnf --host=localhost --user=root --password=mysqlWAI --port=3306 --socket=/data/mysql/run/mysql.sock --backup --target-dir=/home/mysql/xbackup/
备份时插入一条数据做测试
mysql> select * from test1 ;+------+------+| id | code |+------+------+| 1 | 3009 || 2 | 3010 || 3 | 3011 |+------+------+3 rows in set (0.00 sec) mysql> insert into test1 values(4,3099);
备份完成会提示:
191111 18:09:24 All tables unlocked 191111 18:09:24 Backup created in directory '/home/mysql/xbackup/' MySQL binlog position: filename 'mysql-bin.000004', position '155' 191111 18:09:24 [00] Writing /home/mysql/xbackup/backup-my.cnf 191111 18:09:24 [00] ...done 191111 18:09:24 [00] Writing /home/mysql/xbackup/xtrabackup_info 191111 18:09:24 [00] ...done xtrabackup: Transaction log of lsn (23556373) to (23556739) was copied. 191111 18:09:24 completed OK!
查看一下备份的情况
[mysql@centos1 xbackup]$ ll total 2142252 -rw-r----- 1 mysql mysql 499 Nov 11 18:09 backup-my.cnf -rw-r----- 1 mysql mysql 2147483648 Nov 11 18:09 ibdata1 drwxr-x--- 2 mysql mysql 157 Nov 11 18:09 mysql -rw-r----- 1 mysql mysql 155 Nov 11 18:09 mysql-bin.000004 -rw-r----- 1 mysql mysql 36 Nov 11 18:09 mysql-bin.index -rw-r----- 1 mysql mysql 25165824 Nov 11 18:09 mysql.ibd drwxr-x--- 2 mysql mysql 8192 Nov 11 18:09 performance_schema drwxr-x--- 2 mysql mysql 43 Nov 11 18:09 srlg drwxr-x--- 2 mysql mysql 28 Nov 11 18:09 sys -rw-r----- 1 mysql mysql 10485760 Nov 11 18:09 undo_001 -rw-r----- 1 mysql mysql 10485760 Nov 11 18:09 undo_002 -rw-r----- 1 mysql mysql 21 Nov 11 18:09 xtrabackup_binlog_info -rw-r----- 1 mysql mysql 95 Nov 11 18:09 xtrabackup_checkpoints -rw-r----- 1 mysql mysql 581 Nov 11 18:09 xtrabackup_info -rw-r----- 1 mysql mysql 3072 Nov 11 18:09 xtrabackup_logfile -rw-r----- 1 mysql mysql 264 Nov 11 18:09 xtrabackup_tablespaces
[mysql@centos1 xbackup]$ cat xtrabackup_checkpoints backup_type = full-backuped from_lsn = 0 to_lsn = 23556719 last_lsn = 23556729 flushed_lsn = 0
[mysql@centos1 xbackup]$ cat xtrabackup_info uuid = 562944f7-046b-11ea-984b-10e7c62c3e49 name = tool_name = xtrabackup tool_command = --defaults-file=/data/mysql/my.cnf --host=localhost --user=root --password=... --port=3306 --socket=/data/mysql/run/mysql.sock --backup --target-dir=/home/mysql/xbackup/ tool_version = 8.0.7 ibbackup_version = 8.0.7 server_version = 8.0.18 start_time = 2019-11-11 18:08:43 end_time = 2019-11-11 18:09:24 lock_time = 0 binlog_pos = filename 'mysql-bin.000004', position '155' innodb_from_lsn = 0 innodb_to_lsn = 23556719 partial = N incremental = N format = file compressed = N encrypted = N
此时删掉mysql一个表作测试
mysql> show tables -> ;+----------------+| Tables_in_srlg |+----------------+| test1 || user100w |+----------------+2 rows in set (0.00 sec) mysql> drop table user100w;Query OK, 0 rows affected (0.10 sec)
创建备份用户根据官方:
An SQL example of creating a database user with the minimum privileges required to full backups would be:
mysql> CREATE USER 'bkpuser'@'localhost' IDENTIFIED BY 's3cr%T'; mysql> GRANT BACKUP_ADMIN, PROCESS, RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'bkpuser'@'localhost' ; mysql> GRANT SELECT ON performance_schema.log_status TO 'bkpuser'@'localhost' ; mysql> FLUSH PRIVILEGES;
准备恢复
[mysql@centos1 ~]$ xtrabackup --defaults-file=/data/mysql/my.cnf --user=root --prepare --target-dir=/home/mysql/xbackup/ Created 128 and tracked 128 new rollback segment(s) in the temporary tablespace. 128 are now active.Page cleaner took 23005ms to flush 0 and evict 0 pages8.0.16 started; log sequence number 23557132xtrabackup: starting shutdown with innodb_fast_shutdown = 1FTS optimize thread exiting.Starting shutdown...Log background threads are being closed...Shutdown completed; log sequence number 23557132191111 18:32:11 completed OK![mysql@centos1 ~]$ [mysql@centos1 ~]$ xtrabackup --defaults-file=/data/mysql/my.cnf--user=root --copy-back --target-dir=/home/mysql/xbackup/
报错
[mysql@centos1 ~]$ xtrabackup --defaults-file=/data/mysql/my.cnf--user=root --copy-back --target-dir=/home/mysql/xbackup/ xtrabackup: [ERROR] Failed to open required defaults file: /data/mysql/my.cnf--user=root xtrabackup: [ERROR] Fatal error in defaults handling. Program aborted!
修改权限
[root@centos1 mysql]# chmod 755 /data/mysql/my.cnf
[mysql@centos1 ~]$ xtrabackup --defaults-file=/data/mysql/my.cnf --user=mysql --copy-back --target-dir=/home/mysql/xbackup/ xtrabackup: recognized server arguments: --datadir=/data/mysql/data --tmpdir=/data/mysql/tmp --open_files_limit=65535 --server-id=1 --log_bin=/data/mysql/binlog/mysql-bin --innodb_buffer_pool_size=4096M --innodb_file_per_table=1 --innodb_data_home_dir=/data/mysql/innodb_ts --innodb_data_file_path=ibdata1:2048M:autoextend --innodb_log_buffer_size=67108864 --innodb_log_file_size=1048576000 --innodb_log_files_in_group=4 --innodb_undo_directory=/data/mysql/undo_space --innodb_log_group_home_dir=/data/mysql/innodb_log --innodb_flush_log_at_trx_commit=2 --innodb_max_dirty_pages_pct=60 --innodb_open_files=60000 --innodb_read_io_threads=4 --innodb_flush_method=O_DIRECT xtrabackup: recognized client arguments: --port=3306 --socket=/data/mysql/run/mysql.sock --user=mysql --copy-back=1 --target-dir=/home/mysql/xbackup/ xtrabackup version 8.0.7 based on MySQL server 8.0.16 Linux (x86_64) (revision id: 069e0e6) Original data directory /data/mysql/data is not empty!
oh 对了恢复的话 相关文件目录/data/mysql/data要删掉。。。 重来吧
看看备份目录内容 多了一些日志:
[mysql@centos1 data]$ cd /home/mysql/xbackup [mysql@centos1 xbackup]$ ll total 6258732 -rw-r----- 1 mysql mysql 499 Nov 11 18:09 backup-my.cnf -rw-r----- 1 mysql mysql 2147483648 Nov 11 18:32 ibdata1 -rw-r----- 1 mysql mysql 1048576000 Nov 11 18:32 ib_logfile0 -rw-r----- 1 mysql mysql 1048576000 Nov 11 18:31 ib_logfile1 -rw-r----- 1 mysql mysql 1048576000 Nov 11 18:31 ib_logfile2 -rw-r----- 1 mysql mysql 1048576000 Nov 11 18:32 ib_logfile3 -rw-r----- 1 mysql mysql 12582912 Nov 11 18:32 ibtmp1 drwxrwx--- 2 mysql mysql 6 Nov 11 18:32 #innodb_temp drwxr-x--- 2 mysql mysql 157 Nov 11 18:09 mysql -rw-r----- 1 mysql mysql 155 Nov 11 18:09 mysql-bin.000004 -rw-r----- 1 mysql mysql 36 Nov 11 18:09 mysql-bin.index -rw-r----- 1 mysql mysql 25165824 Nov 11 18:09 mysql.ibd drwxr-x--- 2 mysql mysql 8192 Nov 11 18:09 performance_schema drwxr-x--- 2 mysql mysql 43 Nov 11 18:09 srlg drwxr-x--- 2 mysql mysql 28 Nov 11 18:09 sys -rw-r----- 1 mysql mysql 10485760 Nov 11 18:09 undo_001 -rw-r----- 1 mysql mysql 10485760 Nov 11 18:09 undo_002 -rw-r----- 1 mysql mysql 21 Nov 11 18:09 xtrabackup_binlog_info -rw-r----- 1 mysql mysql 95 Nov 11 18:31 xtrabackup_checkpoints -rw-r----- 1 mysql mysql 581 Nov 11 18:09 xtrabackup_info -rw-r----- 1 mysql mysql 8388608 Nov 11 18:31 xtrabackup_logfile -rw-rw-r-- 1 mysql mysql 1 Nov 11 18:31 xtrabackup_master_key_id -rw-r----- 1 mysql mysql 264 Nov 11 18:32 xtrabackup_tablespaces
[mysql@centos1 xbackup]$ cd /data/mysql [mysql@centos1 mysql]$ ll total 36 drwxrwxr-x 2 mysql mysql 6 Oct 30 15:31 backup drwxrwxr-x 2 mysql mysql 125 Nov 11 18:09 binlog drwxr-xr-x 7 mysql mysql 288 Nov 8 11:25 data drwxrwxr-x 2 mysql mysql 82 Oct 31 11:29 innodb_log drwxrwxr-x 2 mysql mysql 57 Nov 8 11:25 innodb_ts drwxr-xr-x 2 mysql mysql 6 Oct 25 16:29 log -rwxr-xr-x 1 mysql mysql 2690 Oct 31 12:02 my.cnf -rw-r----- 1 mysql mysql 6 Nov 8 11:25 mysqld.pid -rw-r----- 1 mysql mysql 24410 Nov 11 18:08 mysql-error.log drwxr-xr-x 2 mysql mysql 90 Nov 8 11:25 run drwxrwxr-x 2 mysql mysql 6 Oct 30 15:31 scripts -rw-r----- 1 mysql mysql 744 Nov 8 13:23 slow_statement.log drwxr-xr-x 3 mysql mysql 53 Oct 29 17:26 tmp drwxr-x--- 2 mysql mysql 38 Oct 31 11:29 undo_space [mysql@centos1 mysql]$ mv data data_bk [mysql@centos1 mysql]$ mv binlog binlog_bk [mysql@centos1 mysql]$ mv innodb_log innodb_log_bk [mysql@centos1 mysql]$ cd innodb_ts/ [mysql@centos1 innodb_ts]$ ll total 2109448 -rw-r----- 1 mysql mysql 4509 Oct 31 17:34 ib_buffer_pool -rw-r----- 1 mysql mysql 2147483648 Nov 11 18:34 ibdata1 -rw-r----- 1 mysql mysql 12582912 Nov 8 11:26 ibtmp1 [mysql@centos1 innodb_ts]$ cd .. [mysql@centos1 mysql]$ mv innodb_ts innodb_ts_bk [mysql@centos1 mysql]$ cd log [mysql@centos1 log]$ ll total 0 [mysql@centos1 log]$ cd .. [mysql@centos1 mysql]$ cd tmp [mysql@centos1 tmp]$ ll total 113284 drwxr-xr-x 8 root root 319 Apr 10 2019 boost_1_70_0 -rw-r--r-- 1 root root 116000903 Oct 29 17:26 boost_1_70_0.tar.gz [mysql@centos1 tmp]$ cd .. [mysql@centos1 mysql]$ cd undo_space/ [mysql@centos1 undo_space]$ ll total 20480 -rw-r----- 1 mysql mysql 10485760 Nov 11 18:34 undo_001 -rw-r----- 1 mysql mysql 10485760 Nov 11 18:33 undo_002 [mysql@centos1 undo_space]$ cd .. [mysql@centos1 mysql]$ mv undo_space undo_space_bk [mysql@centos1 mysql]$ ll total 36 drwxrwxr-x 2 mysql mysql 6 Oct 30 15:31 backup drwxrwxr-x 2 mysql mysql 125 Nov 11 18:09 binlog_bk drwxr-xr-x 7 mysql mysql 288 Nov 8 11:25 data_bk drwxrwxr-x 2 mysql mysql 82 Oct 31 11:29 innodb_log_bk drwxrwxr-x 2 mysql mysql 57 Nov 8 11:25 innodb_ts_bk drwxr-xr-x 2 mysql mysql 6 Oct 25 16:29 log -rwxr-xr-x 1 mysql mysql 2690 Oct 31 12:02 my.cnf -rw-r----- 1 mysql mysql 6 Nov 8 11:25 mysqld.pid -rw-r----- 1 mysql mysql 24410 Nov 11 18:08 mysql-error.log drwxr-xr-x 2 mysql mysql 90 Nov 8 11:25 run drwxrwxr-x 2 mysql mysql 6 Oct 30 15:31 scripts -rw-r----- 1 mysql mysql 744 Nov 8 13:23 slow_statement.log drwxr-xr-x 3 mysql mysql 53 Oct 29 17:26 tmp drwxr-x--- 2 mysql mysql 38 Oct 31 11:29 undo_space_bk
这样很多很麻烦啊。。对了我直接删掉整个目录就好了吧。。。
[mysql@centos1 mysql]$ cd .. [mysql@centos1 data]$ ll total 0 drwxr-xr-x 12 mysql mysql 243 Nov 12 11:00 mysql [mysql@centos1 data]$ mv mysql mysql_bk mv: cannot move ‘mysql’ to ‘mysql_bk’: Permission denied [mysql@centos1 data]$ ll total 0 drwxr-xr-x 12 mysql mysql 243 Nov 12 11:00 mysql [mysql@centos1 data]$ su - root Password: su: Authentication failure [mysql@centos1 data]$ su - root Password: Last login: Tue Nov 12 10:40:42 CST 2019 from desktop-v9u5026 on pts/1 Last failed login: Tue Nov 12 11:04:08 CST 2019 on pts/1 There was 1 failed login attempt since the last successful login. [root@centos1 ~]# chmod 755 /data/mysql [root@centos1 ~]# cd /data [root@centos1 data]# ll total 0 drwxr-xr-x 12 mysql mysql 243 Nov 12 11:00 mysql
[root@centos1 data]# chmod 777 /data/mysql [root@centos1 data]# ll total 0 drwxrwxrwx 12 mysql mysql 243 Nov 12 11:00 mysql [root@centos1 data]# su - mysql Last login: Tue Nov 12 10:45:32 CST 2019 on pts/1 [mysql@centos1 ~]$ cd /data [mysql@centos1 data]$ ll total 0 drwxrwxrwx 12 mysql mysql 243 Nov 12 11:00 mysql [mysql@centos1 data]$ mv mysql mysql_bk mv: cannot move ‘mysql’ to ‘mysql_bk’: Permission denied [mysql@centos1 data]$ ll total 0 drwxrwxrwx 12 mysql mysql 243 Nov 12 11:00 mysql [mysql@centos1 data]$ cd [mysql@centos1 ~]$ pwd /home/mysql
好吧 不行mv不了 还是按刚刚那样吧
重新做恢复的过程,先看看进程吧
[mysql@centos1 mysql]$ ps -ef|grep mysql root 8867 8496 0 10:45 pts/1 00:00:00 su - mysql mysql 8868 8867 0 10:45 pts/1 00:00:00 -bash mysql 9850 1 0 Nov08 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/my.cnf --user=mysql root 10468 10216 0 11:07 pts/1 00:00:00 su - mysql mysql 10469 10468 0 11:07 pts/1 00:00:00 -bash mysql 10738 9850 0 Nov08 ? 00:48:01 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/my.cnf --basedir=/usr/localmysql --datadir=/data/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/data/mysql/mysql-error.log --open-files-limit=65535 --pid-file=/data/mysql/mysqld.pid --socket=/data/mysql/run/mysql.sock --port=3306 mysql 11009 10469 0 11:14 pts/1 00:00:00 ps -ef mysql 11010 10469 0 11:14 pts/1 00:00:00 grep --color=auto mysql
什么鬼?我记得我停掉mysql了啊 竟然忘了? 那当然不能mv mysql了啊 晕。。。
停掉mysql
[mysql@centos1 bin]$ /usr/local/mysql/bin/mysqladmin -h 127.0.0.1 -uroot -pmysqlWAI -P3306 -S /data/mysql/run/mysql.sock shutdown mysqladmin: [Warning] Using a password on the command line interface can be insecure. [mysql@centos1 bin]$ ps -ef|grep mysql root 8867 8496 0 10:45 pts/1 00:00:00 su - mysql mysql 8868 8867 0 10:45 pts/1 00:00:00 -bash root 10468 10216 0 11:07 pts/1 00:00:00 su - mysql mysql 10469 10468 0 11:07 pts/1 00:00:00 -bash mysql 11341 10469 0 11:19 pts/1 00:00:00 ps -ef mysql 11342 10469 0 11:19 pts/1 00:00:00 grep --color=auto mysql
重新创建空目录
[mysql@centos1 mysql]$ mkdir data [mysql@centos1 mysql]$ mkdir binlog [mysql@centos1 mysql]$ mkdir innodb_log [mysql@centos1 mysql]$ mkdir innodb_ts [mysql@centos1 mysql]$ mkdir undo_space [mysql@centos1 mysql]$ mv tmp tmp_bk [mysql@centos1 mysql]$ mkdir tmp
准备恢复 --prepare (这个好像是将备份集备份后MySQL运行产生的日志合并之类的)
[mysql@centos1 mysql]$ xtrabackup --defaults-file=/data/mysql/my.cnf --user=root --prepare --target-dir=/home/mysql/xbackup/ Creating shared tablespace for temporary tables Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... File './ibtmp1' size is now 12 MB. Scanning temp tablespace dir:'./#innodb_temp/' Created 128 and tracked 128 new rollback segment(s) in the temporary tablespace. 128 are now active. 8.0.16 started; log sequence number 23557132 xtrabackup: starting shutdown with innodb_fast_shutdown = 1 FTS optimize thread exiting. Starting shutdown... Log background threads are being closed... Shutdown completed; log sequence number 23557132 191112 11:30:58 completed OK!
跟上次的序列号是一样的 大概是因为没有产生过数据变更
--copy-back:
[mysql@centos1 ~]$ xtrabackup --defaults-file=/data/mysql/my.cnf --user=mysql --copy-back --target-dir=/home/mysql/xbackup/ 191112 11:38:32 [01] Copying ./xtrabackup_info to /data/mysql/data/xtrabackup_info 191112 11:38:32 [01] ...done 191112 11:38:32 [01] Copying ./xtrabackup_master_key_id to /data/mysql/data/xtrabackup_master_key_id 191112 11:38:32 [01] ...done 191112 11:38:32 [01] Copying ./ibtmp1 to /data/mysql/data/ibtmp1 191112 11:38:32 [01] ...done 191112 11:38:32 [01] Creating directory ./#innodb_temp 191112 11:38:32 [01] ...done. 191112 11:38:32 completed OK!
查看恢复后的文件,新建的文件夹有数据了:
[mysql@centos1 ~]$ cd /data/mysql [mysql@centos1 mysql]$ ll total 36 drwxrwxr-x 2 mysql mysql 6 Oct 30 15:31 backup drwxrwxr-x 2 mysql mysql 53 Nov 12 11:38 binlog drwxrwxr-x 2 mysql mysql 125 Nov 11 18:09 binlog_bk drwxrwxr-x 6 mysql mysql 154 Nov 12 11:38 data drwxr-xr-x 7 mysql mysql 288 Nov 8 11:25 data_bk drwxrwxr-x 2 mysql mysql 82 Nov 12 11:37 innodb_log drwxrwxr-x 2 mysql mysql 82 Oct 31 11:29 innodb_log_bk drwxrwxr-x 2 mysql mysql 21 Nov 12 11:37 innodb_ts drwxrwxr-x 2 mysql mysql 57 Nov 8 11:25 innodb_ts_bk drwxr-xr-x 2 mysql mysql 6 Oct 25 16:29 log -rwxr-xr-x 1 mysql mysql 2690 Oct 31 12:02 my.cnf -rw-r----- 1 mysql mysql 25145 Nov 12 11:18 mysql-error.log drwxr-xr-x 2 mysql mysql 6 Nov 12 11:18 run drwxrwxr-x 2 mysql mysql 6 Oct 30 15:31 scripts -rw-r----- 1 mysql mysql 744 Nov 8 13:23 slow_statement.log drwxrwxr-x 2 mysql mysql 6 Nov 12 11:25 tmp drwxr-xr-x 3 mysql mysql 53 Oct 29 17:26 tmp_bk drwxrwxr-x 2 mysql mysql 38 Nov 12 11:37 undo_space drwxr-x--- 2 mysql mysql 38 Oct 31 11:29 undo_space_bk [mysql@centos1 mysql]$ cd data [mysql@centos1 data]$ ll total 36884 -rw-r----- 1 mysql mysql 12582912 Nov 12 11:38 ibtmp1 drwxr-x--- 2 mysql mysql 157 Nov 12 11:38 mysql -rw-r----- 1 mysql mysql 25165824 Nov 12 11:38 mysql.ibd drwxr-x--- 2 mysql mysql 8192 Nov 12 11:38 performance_schema drwxr-x--- 2 mysql mysql 43 Nov 12 11:38 srlg drwxr-x--- 2 mysql mysql 28 Nov 12 11:38 sys -rw-r----- 1 mysql mysql 581 Nov 12 11:38 xtrabackup_info -rw-r----- 1 mysql mysql 1 Nov 12 11:38 xtrabackup_master_key_id [mysql@centos1 data]$ cd .. [mysql@centos1 mysql]$ cd binlog [mysql@centos1 binlog]$ ll total 8 -rw-r----- 1 mysql mysql 155 Nov 12 11:38 mysql-bin.000004 -rw-r----- 1 mysql mysql 36 Nov 12 11:38 mysql-bin.index
启动mysql:
[mysql@centos1 ~]$ /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/my.cnf --user=mysql & [1] 13666 [mysql@centos1 ~]$ 2019-11-12T03:51:22.072187Z mysqld_safe Logging to '/data/mysql/mysql-error.log'. 2019-11-12T03:51:22.147329Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/data
[mysql@centos1 ~]$ ps -ef |grep mysql root 8867 8496 0 10:45 pts/1 00:00:00 su - mysql mysql 8868 8867 0 10:45 pts/1 00:00:00 -bash root 10468 10216 0 11:07 pts/1 00:00:00 su - mysql mysql 10469 10468 0 11:07 pts/1 00:00:00 -bash root 12670 12624 0 11:37 pts/0 00:00:00 su - mysql mysql 12671 12670 0 11:37 pts/0 00:00:00 -bash mysql 13666 12671 0 11:51 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/my.cnf --user=mysql mysql 14555 13666 5 11:51 pts/0 00:00:01 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/my.cnf --basedir=/usr/localmysql --datadir=/data/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/data/mysql/mysql-error.log --open-files-limit=65535 --pid-file=/data/mysql/mysqld.pid --socket=/data/mysql/run/mysql.sock --port=3306 root 14666 14621 0 11:51 pts/2 00:00:00 su - mysql mysql 14667 14666 0 11:51 pts/2 00:00:00 -bash mysql 14713 14667 0 11:51 pts/2 00:00:00 ps -ef mysql 14714 14667 0 11:51 pts/2 00:00:00 grep --color=auto mysql
登录
[mysql@centos1 ~]$ mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 8Server version: 8.0.18 nancy edition Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use srlgDatabase changedmysql> show tables;+----------------+| Tables_in_srlg |+----------------+| test1 || user100w |+----------------+2 rows in set (0.02 sec) mysql> select * from test1;+------+------+| id | code |+------+------+| 1 | 3009 || 2 | 3010 || 3 | 3011 || 4 | 3099 |+------+------+4 rows in set (0.02 sec) mysql> select count(*) from user100w;+----------+| count(*) |+----------+| 10000 |+----------+1 row in set (0.02 sec)
查看备份时候插入的数据,以及备份之后删除的表都存在。
关于xtrabackup 8备份Mysql 8.0.18的过程是怎么样的就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
当前名称:xtrabackup8备份Mysql8.0.18的过程是怎么样的
网页链接:http://scyanting.com/article/gogesp.html