Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving binary logs in MySQL to a different hard disk

Tags:

mysql

This question is about MySQL binary logs.

We need to move a binary log to a different hard disk.

What is the configuration change required in MySQL?

Currently binary logs go into the same folder as the ibdata and there is a replication slave running which needs the binary logs.

like image 607
Darini Avatar asked Jun 06 '10 14:06

Darini


People also ask

Where are MySQL binary logs stored?

The MySQL binary logs and index files are saved in the C:\ProgramData\MySQL\MySQL Server 8.0 directory. We can change the default location of the binary logs.

How do I purge binary logs in MySQL?

To safely purge binary log files, follow this procedure: On each replica, use SHOW REPLICA STATUS to check which log file it is reading. Obtain a listing of the binary log files on the source with SHOW BINARY LOGS . Determine the earliest log file among all the replicas.

What are MySQL binary logs used for?

The binary log is a set of log files that contain information about data modifications made to an MySQL server instance. The binary log contains information such as the following: Events that describe database changes such as table creation or row modifications.

Do I need MySQL binary logs?

The MySQL BinLogs serve two important purposes: Replication: When working on a master server, the binary logs contain a record of the changes that have occurred. These records are sent to the slave servers to help them execute those events & make the same data changes that were made on the master server.


2 Answers

Changing the log-bin works. BUT you need to copy the log-bin files first to the new location and modify the index file. If you dont'do this you will break your remote slave with the error:

Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'

More info here: http://freebsd.down-to-details.com/sys-admin/relocating-moving-mysql-binlogs/

like image 187
Rodo Avatar answered Oct 14 '22 04:10

Rodo


From the way I read the doc, you can specify a path on the log-bin config.

To enable the binary log, start the server with the --log-bin[=base_name] option. If no base_name value is given, the default name is the value of the pid-file option (which by default is the name of host machine) followed by -bin. If the basename is given, the server writes the file in the data directory unless the basename is given with a leading absolute path name to specify a different directory. It is recommended that you specify a basename; see Section C.5.8, “Known Issues in MySQL”, for the reason.

like image 2
Alain Collins Avatar answered Oct 14 '22 05:10

Alain Collins