根据资料上说,mysqlbackup备份数据库的语法如下:
mysqlbackup -u<user> -p<password>
--backup_dir=<backup-dir>
backup-and-apply-log
具体我执行的时候,老是报错:
[root@sztech1 ~]# mysqlbackup -u root -p --backup_dir=/backup backup-and-apply-log
MySQL Enterprise Backup version 3.11.0 Linux-3.8.13-16.2.1.el6uek.x86_64-x86_64 [2014/08/26]
Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved.
mysqlbackup: INFO: Starting with following command line ...
mysqlbackup -u root -p --backup_dir=/backup backup-and-apply-log
mysqlbackup: INFO:
Enter password:
141206 01:55:16 mysqlbackup: WARNING: Can not establish connection to mysql server.
Connection open fails with error "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"
mysqlbackup: ERROR: Connection initialization error.
mysqlbackup failed with errors!
经过查看文档,原来必须要带上 --host选项才能成功 :
[root@sztech1 ~]# mysqlbackup -u root -p --host 127.0.0.1 --backup_dir=/backup backup-and-apply-log
MySQL Enterprise Backup version 3.11.0 Linux-3.8.13-16.2.1.el6uek.x86_64-x86_64 [2014/08/26]
Copyright (c) 2003, 2014, Oracle and/or its affiliates. All Rights Reserved.
mysqlbackup: INFO: Starting with following command line ...
mysqlbackup -u root -p --host 127.0.0.1 --backup_dir=/backup
backup-and-apply-log
mysqlbackup: INFO:
Enter password:
mysqlbackup: INFO: MySQL server version is '5.6.21-enterprise-commercial-advanced-log'.
mysqlbackup: INFO: Got some server configuration information from running server.
IMPORTANT: Please check that mysqlbackup run completes successfully.
At the end of a successful 'backup-and-apply-log' run mysqlbackup
prints "mysqlbackup completed OK!".
141206 01:50:59 mysqlbackup: INFO: MEB logfile created at /backup/meta/MEB_2014-12-06.01-50-59_backup_apply_log.log
--------------------------------------------------------------------
Server Repository Options:
--------------------------------------------------------------------
datadir = /var/lib/mysql/
innodb_data_home_dir =
innodb_data_file_path = ibdata1:12M:autoextend
innodb_log_group_home_dir = /var/lib/mysql/
innodb_log_files_in_group = 2
innodb_log_file_size = 50331648
innodb_page_size = 16384
innodb_checksum_algorithm = innodb
innodb_undo_directory = /var/lib/mysql/
innodb_undo_tablespaces = 0
innodb_undo_logs = 128
--------------------------------------------------------------------
Backup Config Options:
--------------------------------------------------------------------
datadir = /backup/datadir
innodb_data_home_dir = /backup/datadir
innodb_data_file_path = ibdata1:12M:autoextend
innodb_log_group_home_dir = /backup/datadir
innodb_log_files_in_group = 2
innodb_log_file_size = 50331648
innodb_page_size = 16384
innodb_checksum_algorithm = innodb
innodb_undo_directory = /backup/datadir
innodb_undo_tablespaces = 0
innodb_undo_logs = 128
mysqlbackup: INFO: Unique generated backup id for this is 14178018590019963
mysqlbackup: INFO: Creating 14 buffers each of size 16777216.
141206 01:51:01 mysqlbackup: INFO: Full Backup operation starts with following threads
1 read-threads 6 process-threads 1 write-threads
141206 01:51:01 mysqlbackup: INFO: System tablespace file format is Antelope.
141206 01:51:01 mysqlbackup: INFO: Starting to copy all innodb files...
141206 01:51:01 mysqlbackup: INFO: Found checkpoint at lsn 487232589.
141206 01:51:01 mysqlbackup: INFO: Copying /var/lib/mysql/ibdata1 (Antelope file format).
141206 01:51:01 mysqlbackup: INFO: Starting log scan from lsn 487232512.
141206 01:51:01 mysqlbackup: INFO: Copying log...
141206 01:51:02 mysqlbackup: INFO: Log copied, lsn 487232589.
141206 01:51:02 mysqlbackup: INFO: Copying /var/lib/mysql/employees/departments.ibd (Antelope file format).
141206 01:51:02 mysqlbackup: INFO: Copying /var/lib/mysql/employees/dept_emp.ibd (Antelope file format).
141206 01:51:03 mysqlbackup: INFO: Copying /var/lib/mysql/employees/dept_manager.ibd (Antelope file format).
141206 01:51:03 mysqlbackup: INFO: Copying /var/lib/mysql/employees/emp.ibd (Antelope file format).
141206 01:51:04 mysqlbackup: INFO: Copying /var/lib/mysql/employees/employees.ibd (Antelope file format).
141206 01:51:04 mysqlbackup: INFO: Copying /var/lib/mysql/employees/salaries.ibd (Antelope file format).
mysqlbackup: Progress in MB: 200
141206 01:51:08 mysqlbackup: INFO: Copying /var/lib/mysql/employees/sz.ibd (Antelope file format).
141206 01:51:08 mysqlbackup: INFO: Copying /var/lib/mysql/employees/titles.ibd (Antelope file format).
141206 01:51:09 mysqlbackup: INFO: Copying /var/lib/mysql/test/emp.ibd (Antelope file format).
141206 01:51:09 mysqlbackup: INFO: Copying /var/lib/mysql/test/emp1.ibd (Antelope file format).
141206 01:51:09 mysqlbackup: INFO: Copying /var/lib/mysql/test/orders_range#P#p0.ibd (Antelope file format).
141206 01:51:09 mysqlbackup: INFO: Copying /var/lib/mysql/test/orders_range#P#p1.ibd (Antelope file format).
141206 01:51:09 mysqlbackup: INFO: Copying /var/lib/mysql/test/orders_range#P#p2.ibd (Antelope file format).
141206 01:51:09 mysqlbackup: INFO: Copying /var/lib/mysql/test/orders_range#P#p3.ibd (Antelope file format).
141206 01:51:09 mysqlbackup: INFO: Copying /var/lib/mysql/test/orders_range#P#p4.ibd (Antelope file format).
141206 01:51:09 mysqlbackup: INFO: Copying /var/lib/mysql/test/test.ibd (Antelope file format).
141206 01:51:10 mysqlbackup: INFO: Copying /var/lib/mysql/world/City.ibd (Antelope file format).
141206 01:51:10 mysqlbackup: INFO: Copying /var/lib/mysql/world/Country.ibd (Antelope file format).
141206 01:51:10 mysqlbackup: INFO: Copying /var/lib/mysql/world/CountryLanguage.ibd (Antelope file format).
141206 01:51:10 mysqlbackup: INFO: Copying /var/lib/mysql/world/DeletedCity.ibd (Antelope file format).
141206 01:51:10 mysqlbackup: INFO: Completing the copy of innodb files.
141206 01:51:11 mysqlbackup: INFO: Starting to copy Binlog files...
141206 01:51:12 mysqlbackup: INFO: Preparing to lock tables: Connected to mysqld server.
141206 01:51:12 mysqlbackup: INFO: Starting to lock all the tables...
141206 01:51:12 mysqlbackup: INFO: All tables are locked and flushed to disk
141206 01:51:12 mysqlbackup: INFO: Opening backup source directory '/var/lib/mysql/'
141206 01:51:12 mysqlbackup: INFO: Starting to backup all non-innodb files in
subdirectories of '/var/lib/mysql/'
141206 01:51:12 mysqlbackup: INFO: Copying the database directory 'employees'
141206 01:51:12 mysqlbackup: INFO: Copying the database directory 'newcerts'
141206 01:51:12 mysqlbackup: INFO: Copying the database directory 'sys'
141206 01:51:12 mysqlbackup: INFO: Copying the database directory 'test'
141206 01:51:12 mysqlbackup: INFO: Copying the database directory 'world'
141206 01:51:13 mysqlbackup: INFO: Completing the copy of all non-innodb files.
141206 01:51:13 mysqlbackup: INFO: Completed the copy of binlog files...
141206 01:51:13 mysqlbackup: INFO: A copied database page was modified at 487232589.
(This is the highest lsn found on page)
Scanned log up to lsn 487232589.
Was able to parse the log up to lsn 487232589.
Maximum page number for a log record 0
141206 01:51:13 mysqlbackup: INFO: All tables unlocked
141206 01:51:13 mysqlbackup: INFO: All MySQL tables were locked for 0.926 seconds.
141206 01:51:13 mysqlbackup: INFO: Reading all global variables from the server.
141206 01:51:13 mysqlbackup: INFO: Completed reading of all global variables from the server.
141206 01:51:13 mysqlbackup: INFO: Creating server config files server-my.cnf and server-all.cnf in /backup
141206 01:51:13 mysqlbackup: INFO: Full Backup operation completed successfully.
141206 01:51:13 mysqlbackup: INFO: Backup created in directory '/backup'
141206 01:51:13 mysqlbackup: INFO: MySQL binlog position: filename sztech1-bin.000003, position 120
-------------------------------------------------------------
Parameters Summary
-------------------------------------------------------------
Start LSN : 487232512
End LSN : 487232589
-------------------------------------------------------------
mysqlbackup: INFO: Creating 14 buffers each of size 65536.
141206 01:51:13 mysqlbackup: INFO: Apply-log operation starts with following threads
1 read-threads 1 process-threads
mysqlbackup: INFO: Using up to 100 MB of memory.
141206 01:51:13 mysqlbackup: INFO: ibbackup_logfile's creation parameters:
start lsn 487232512, end lsn 487232589,
start checkpoint 487232589.
mysqlbackup: INFO: InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
mysqlbackup: INFO: InnoDB: Setting log file size to 50331648
mysqlbackup: INFO: InnoDB: Setting log file size to 50331648
141206 01:51:14 mysqlbackup: INFO: We were able to parse ibbackup_logfile up to
lsn 487232589.
mysqlbackup: INFO: Last MySQL binlog file position 0 120, file name sztech1-bin.000003:120
141206 01:51:14 mysqlbackup: INFO: The first data file is '/backup/datadir/ibdata1'
and the new created log files are at '/backup/datadir'
141206 01:51:14 mysqlbackup: INFO: Apply-log operation completed successfully.
141206 01:51:14 mysqlbackup: INFO: Full backup prepared for recovery successfully.
mysqlbackup completed OK!
欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) | Powered by Discuz! X3.2 |