SQL Statements for Controlling Master Servers
1126
3. Determine the earliest log file among all the slaves. This is the target file. If all the slaves are up to
date, this is the last log file on the list.
4. Make a backup of all the log files you are about to delete. (This step is optional, but always
advisable.)
5. Purge all log files up to but not including the target file.
You can also set the
expire_logs_days
[450]
system variable to expire binary log files automatically
after a given number of days (see
Section 5.1.4, “Server System Variables”
). If you are using
replication, you should set the variable no lower than the maximum number of days your slaves might
lag behind the master.
Prior to MySQL 5.0.60,
PURGE BINARY LOGS TO
and
PURGE BINARY LOGS BEFORE
did not
behave in the same way (and neither one behaved correctly) when binary log files listed in the
.index
file had been removed from the system by some other means (such as using
rm
on Linux). Beginning
with MySQL 5.0.60, both variants of the statement fail with an error in such cases. (Bug #18199, Bug
#18453) To handle such errors, edit the
.index
file (which is a simple text file) manually to ensure
that it lists only the binary log files that are actually present, then run again the
PURGE BINARY LOGS
statement that failed.
13.4.1.2.
RESET MASTER
Syntax
RESET MASTER
Deletes all binary log files listed in the index file, resets the binary log index file to be empty, and
creates a new binary log file. This statement is intended to be used only when the master is started for
the first time.
Important
The effects of
RESET MASTER
differ from those of
PURGE BINARY LOGS
in 2
key ways:
1.
RESET MASTER
removes all binary log files that are listed in the index file,
leaving only a single, empty binary log file with a numeric suffix of
.000001
,
whereas the numbering is not reset by
PURGE BINARY LOGS
.
2.
RESET MASTER
is not intended to be used while any replication slaves
are running. The behavior of
RESET MASTER
when used while slaves are
running is undefined (and thus unsupported), whereas
PURGE BINARY
LOGS
may be safely used while replication slaves are running.
See also
Section 13.4.1.1, “
PURGE BINARY LOGS
Syntax”
.
RESET MASTER
can prove useful when you first set up the master and the slave, so that you can verify
the setup as follows:
1. Start the master and slave, and start replication (see
Section 16.1.1, “How to Set Up Replication”
).
2. Execute a few test queries on the master.
3. Check that the queries were replicated to the slave.
4. When replication is running correctly, issue
STOP SLAVE
followed by
RESET SLAVE
on the slave,
then verify that any unwanted data no longer exists on the slave.
5. Issue
RESET MASTER
on the master to clean up the test queries.
After verifying the setup and getting rid of any unwanted and log files generated by testing, you can
start the slave and begin replicating.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...