Relocate binary logs and relay logs in MySQL server manually

Objective: Relocating binary logs and relay logs in MySQL slave database to another location.

Environment:

Operating System: Ubuntu 12.10

Database : MySQL 5.6.

First of all, let’s check if the replication is active or not.

20160924

Identify current location of binary logs and relay logs

20160923_10
20160923_11

Since we haven’t specified a location for relay logs and relay log index file, the data directory path will be chosen by default. In this case we have to determine datadir path as well.

20160923_12

Let’s create a new directory to store binary logs and relay logs.

20160923_13

Next step is to stop MySQL and copy binlogs and relay logs to the new location.

20160923_14

Copy binary  logs to the new location; along with the index file.

20160923_15

Copy relay logs to new location along with the index file.

20160923_16

Next step is to modify relay-log.info file which is located in datadir and specify the absolute path to the relay logs.

20160923_17

Also modify binary log index file and slave log index files so that those contain absolute path to the logs(New path)

20160923_26

Add new location variables to my.cnf file

20160923_19

Grant necessary permission to mysql user to the new location.

20160923_20

Modify apparmor configurations so that mysql user has necessary permission

20160923_21
20160923_22

Restart apparmor

20160923_24

Start mysql

20160923_27

And finally we can check if the status of the replication

20160923_28

Leave us a Comment