mysqldump

mysqldump -uroot -phonjia@mariadb –single-transaction –master-data=2 –flush-logs -R -E lottery | gzip > /backupmyql/lottery_date '+%m-%d-%Y'.sql.gz

参数解析:
–single-transaction:
This option sends a START TRANSACTION SQL statement to the server before dumping data.It is useful only with transaction tables such as InnoDB, because then it dumps the consistent state of the database at the time when BEGIN was issued without blocking any applications.

When using this option,you should keep in mind that only InnoDB tables are dumped in a consistent state. The single-transaction feature depends not only on the engine being transactional and capable of repeatable-read,but also on start transaction with consistent snapshot. The dump is not guaranteed to be consistent for other storage engines.For example, any TokuDB,MyISAM or MEMORY tables dumped while using this option may still change state.
While a –single-transaction dump is in process,to ensure a valid dump file(correct table contents and binary log coordinates),no other connection should use the following statements:ALTER TABLE,CREATE TABLE,DROP TABLE,RENAME TABLE,OR TRUNCATE TABLE.

While a –single-transaction dump is in process,to ensure a valid dump file(correct table contents and binary log coordinates),no other connection should use the following statements:ALTER TABLE,CREATE TABLE,DROP TABLE,RENAME TABLE,or TRUNCATE TABLE. A consistent read is not isolated from those statement,so use of them on a table to be dumped can cause the SELECT (performed by mysqldump to retrieve the table contents) to obtain incorrect contents or fail.

The –single-transaction option and the –lock-tables option are mutually exclusive because automatically turns off –lock-tables
TO dump large tables,you should combine the –single-transaction option with –quick

–master-data[=#]:
Causes the binary log position and filename to be appended to the output,useful dumping a master replication server to produce a dump file that can be used to set up another server as slave of the master.These are the master server coordinates from which the slave should start replicating after you load the dump file into the slave. If the option is set to 1(the default),will print it as a change mastercommand;if set to 2,that command will be prefixed with a comment symbol.This –master-data option will turn –lock-all-tables on, unless –single-transaction is specified too.Before MariaDB 5.3 this would tabke a global read lock for a short time at the beginning of the dump –see Enhancements for start transaction with consistent snapshot and the –single-transaction *option below. In all cases,any action on logs will happen at the exact moment of the dump. This option automatically turns *–lock-tables off

In all cases,any action on logs happens at the exact moment of the dump.

it is also possible to set up a slave by dumping an existing slave of the master.To do this,use the following procedure on the existing slave:

1.Stop the slave’s SQL thread and get its current status:
mysql> STOP SLAVE SQL_THREAD;
mysql> SHOW SLAVE STATUS;

2.From the output of the SHOW SLAVE STATUS statement,the binary log coordinates of the master server from which the new slave should start replicating are the values of the Relay_Master_Log_File and Exec_Master_Log_Pos fields.Denote those values as file_name and file_pos.

3 Restart the slave:
mysql> START SLAVE;

4 On the new slave,load the dump file:
shell>mysql<dumpfile

5 On the new slave,set the replication coordinates to those of the master server obtained earlier:
mysql> CHANGE MASTER TO MASTER_LOG_FILE = ‘file_name’, MASTER_LOG_POS = file_pos;
The *CHANGE MASTER * TO statement might also need other parameters,such as MASTER_HOST to point the slave to the correct master server host.Add any such parameters necessary.

-F, –flush-logs:
Flush the MariaDB server log files before starting the dump.This option requires the RELOAD privilege.If you use this option in combination with the –databases= or –all-databases option,the logs are flushed for each database dumped.The exception is when using –lock-all-tables or –master-data In this case,the logs are flushed only once,corresponding to the moment all tables are locked. If you want your dump and the log flush to happen at the same exact moment,you should use –flush-logs together with either –lock-all-tables or –master-data.


文章作者: 阿培
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 阿培 !
 上一篇
csrf csrf
Django 的CSRF保护机制什么是CSRFCSRF(Cross Site Request Forgery),跨站点请求伪造。也被称为one-click-attack或者session riding,通常缩写为CSRF或者XSRF,是一种
2018-12-03
下一篇 
gevent简明教程 gevent简明教程
转载于: 进程 线程 协程 异步并发编程(不是并行)目前有四种方式:多进程、多线程、协程、和异步 多进程编程在python中有类似C的os.fork,更高层封装的有multiprocessing标准库 多线程编程python中有Thre
2018-08-01
  目录