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

The process of msyql master-slave backup

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the "msyql master-slave backup process", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "msyql master-slave backup process"!

Installation environment:

Rhel6.5:server1 master

Rhel6.5:server2 slave

Install the database:

[root@server1 mysql] # yum install-y mysql-community-client-5.7.17-1.el6.x86_64.rpm mysql-community-common-5.7.17-1.el6.x86_64.rpm mysql-community-libs-5.7.17-1.el6.x86_64.rpm mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm mysql-community-server-5.7.17-1.el6.x86_64.rpm

[root@server1 ~] # vim / etc/my.cnf

Server-id = n assign a unique ID number to the server

[root@server1 ~] # / etc/init.d/mysqld start

Initialize MySQL database: [OK]

Installing validate password plugin: [OK]

Starting mysqld: [OK]

[root@server1 ~] # cd / var/lib/mysql

[root@server1 mysql] # cd / var/lib/mysql

[root@server1 mysql] # ls

Auto.cnf ibdata1 mysql-bin.000002 performance_schema

Ca-key.pem ib_logfile0 mysql-bin.000003 private_key.pem

Ca.pem ib_logfile1 mysql-bin.index public_key.pem

Client-cert.pem ibtmp1 mysqld_safe.pid server-cert.pem

Client-key.pem mysql mysql.sock server-key.pem

Ib_bufferpool mysql-bin.000001 mysql.sock.lock sys

[root@server1 mysql] # cat mysql-bin.000001

5.7.17-log [8

* * 4 / 4 / [root@server1 mysql] # ll mysql-bin.000001

-rw-r- 1 mysql mysql 177.28 14:40 mysql-bin.000001

Modify slave configuration file

Server-id = n assign a unique ID number to the server

[root@server1 mysql] # grep password / var/log/mysqld.log

View password

[root@server1 ~] # mysql_secure_installation

Initialization

Server2 ditto

Authorization on server1:

Mysql > grant replication slave on. To cara@'172.25.35.2' identified by 'Caonimei@478'

Query OK, 0 rows affected, 1 warning (0.02 sec)

Mysql > flush privileges; refresh

Query OK, 0 rows affected (0.02 sec)

After master authorization, slave can log in remotely

[root@server2] # mysql-ucara-p-h 172.25.35.1

Mysql > show databases

+-+

| | Database |

+-+

| | information_schema |

+-+

1 row in set (0.00 sec)

View the following on master:

Mysql > show master status

+-+

| | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | |

+-+

| | mysql-bin.000004 | 843 |

+-+

1 row in set (0.00 sec)

Establish a connection between slave and master to synchronize:

Mysql > change master to master_host='172.25.35.1',master_user='cara',master_password='Caonimei@478',master_log_file='mysql-bin.000004',master_log_pos=843

View the following on slave:

Mysql > show databases

->

+-+

| | Database |

+-+

| | information_schema |

| | mysql |

| | performance_schema |

| | sys |

+-+

Mysql > change master to master_host='172.25.35.1',master_user='cara',master_password='Caonimei@478',master_log_file='mysql-bin.000004',master_log_pos=843

[root@server2 mysql] # cd / var/lib/mysql

[root@server2 mysql] # cat master.info

25mysql-bin.000004

eight hundred and forty three

172.25.35.1

Cara

Caonimei@478

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