2. MariaDB activates binary logs.

Source: Internet
Author: User

Translated by: Tie

Time: December 25, 2013

Original article address: Activating the Binary Log
Reference: building a robust data center with high-availability MySQL

To enable the binary log feature, you can use" -- Log-bin [= name]"Option to start the server.
If the file name contains a suffix (for example" -- Log-bin [= master-bin.log]"), Then the suffix (" . Log") Will be ignored.
If no file name is specified Datadir/log-basename-bin, Datadir/mysql-binOr Datadir/mariadb-bin(If neither -- Log-basenameOption, one of the last two will be used according to different server versions );
Datadir is a directory for storing data. DatadirDefinition. (startup parameters -- Datadir = pathOr -H path);
Strongly recommended: -- Log-basenameOr specify the file name of the binary log so that the server's hostname does not affect replication after it is changed );
The directory for storing binary logs. It is used to store independent binary log files and binary log indexes (Files) for these files ).
The extension of a binary log file is a sequence of numbers. each time a log file is added, the extension number is increased. Therefore, the extension number of older logs is smaller, and the extension number of recent logs is the largest.
Each time the server is started, a new binary log is enabled. Of course, the extension is also new. When the server is started or stopped, the log is forcibly written into the physical file (usually stored in the memory cache, the operating system determines when to write data ). you can also define Max_binlog_sizeVariable to specify a number. When the log is accumulated to this value, it is forcibly written to the hard disk.
Binary log index files store the indexes of all binary log files in sequence.
DatadirFile List Example:
shell> ls -l total 100...-rw-rw---- 1 mysql adm 2098 Apr 19 00:46 mariadb-bin.000079-rw-rw---- 1 mysql adm  332 Apr 19 00:56 mariadb-bin.000080-rw-rw---- 1 mysql adm  347 Apr 19 07:36 mariadb-bin.000081-rw-rw---- 1 mysql adm  306 Apr 20 07:15 mariadb-bin.000082-rw-rw---- 1 mysql adm  332 Apr 20 07:41 mariadb-bin.000083-rw-rw---- 1 mysql adm  373 Apr 21 07:56 mariadb-bin.000084-rw-rw---- 1 mysql adm  347 Apr 21 09:09 mariadb-bin.000085-rw-rw---- 1 mysql adm  398 Apr 21 21:24 mariadb-bin.000086-rw-rw---- 1 mysql adm  816 Apr 21 17:05 mariadb-bin.index

The name of the binary log index file is the same as that of other binary log files by default, and the extension uses" . Index", Of course, the index file name can also be passed" -- Log-bin-index [= filename]"Option to be specified separately.
With SUPERPermission client, you can set SQL _log_binTo disable or enable binary logs for this session;
( SQL _log_binIs SessionVariable. The default value is 1. Only the client with SUPER permission can be set. If it is set to 0, operations on this client will not be recorded in the binary log ;)
Example:
MariaDB [test]> SET sql_log_bin = 0;MariaDB [test]> SET sql_log_bin = 1;

Binary log format
Binary logs have three formats:
Statement-based logs ( Statement-based);
Row-basedIs a line-based log;
MixYes, the format of the preceding two logs can be mixed;
For details, see Binary Log Formats.
For all configuration Options of the MariaDB server, see mysqld Options (full list)
For MariaDB Server System Variables, see Server System Variables.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.