Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos7 mysql5.7 master-slave data migration

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Description

Master and slave are installed in rpm package, and the version is mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar.

Configure / data/mysql_data for data storage directory

The master-slave configuration file is as follows:

Primary server:

# egrep-v "^ $| ^ #" / etc/my.cnf

[mysqld]

Socket=/var/lib/mysql/mysql.sock

Datadir=/data/mysql_data

Character_set_server=utf8

Sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

Symbolic-links=0

Log-error=/var/log/mysqld.log

Pid-file=/var/run/mysqld/mysqld.pid

Server-id=1

Log-bin=mysql-bin

Binlog_format=mixed

Innodb_flush_log_at_trx_commit=1

Sync_binlog=1

Expire_logs_days=15

Relay_log=mysql-realy-bin

From the server:

# egrep-v "^ $| ^ #" / etc/my.cnf

[mysqld]

Socket=/var/lib/mysql/mysql.sock

Datadir=/data/mysql_data

Character_set_server=utf8

Sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

Symbolic-links=0

Log-error=/var/log/mysqld.log

Pid-file=/var/run/mysqld/mysqld.pid

Server-id=2

Log_bin=mysql-bin

Relay_log=mysql-relay-bin

Log-slave-updates=on

Expire_logs_days=15

Replicate-ignore-db=sys

Replicate-ignore-db=mysql

Replicate-ignore-db=information_schema

Replicate-ignore-db=performance_schema

2. Change steps

First shut down the master-slave database service

Modify the configuration file / etc/my.cnf, I will only modify the following line here

Datadir=/data/mysql_data

> >

Datadir=data / opt/tmp/mysql_data

Then copy the database data directory to the target directory, and here migrate to the / opt/tmp directory

# cp-a / data/mysql_data / opt/tmp/

Finally, start the master-slave mysql service and verify it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report