mysqlプライマリバックアップ

2761 ワード

1.1、マスターバックアップの原理.
プライマリ・プライマリ・バックアップは、実際には互いにプライマリ・セカンダリであり、主に書き込み圧力を緩和するためです.
1.2、環境準備
2台の機器ipはそれぞれ
100.100.100.105 ( 1)
100.100.100.106( 2)

mysqlのインストール
[root@centos ~]# yum install mysql-server mysql-client -y
[root@centos ~]# service mysqld start
[root@centos ~]# /usr/bin/mysqladmin -u root password '123456'

1.3、構成ファイルの変更
100.100.100.105
[root@centos ~]# vim /etc/my.cnf
log-bin=mysql-bin
server-id=105
#replicate-do-db=test #        
binlog-ignore-db=mysql #        
binlog-ignore-db=infogmation_schema
auto-increment-offset=1 #  id 1  
auto-increment-increment=2 #  id    2 
#    1,3,5

100.100.100.106
[root@centos ~]# vim /etc/my.cnf
log-bin=mysql-bin
server-id=106
#replicate-do-db=test #        
binlog-ignore-db=mysql #        
binlog-ignore-db=infogmation_schema
auto-increment-offset=2 #  id 2  
auto-increment-increment=2 #  id    2 
#    2,4,6

1.4、105機械を主とし、106は従
# 100.100.100.105
mysql> grant replication slave on *.* to slave@'100.100.100.106' identified by '123456';
mysql> show master status;
+------------------+----------+--------------+--------------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB         |
+------------------+----------+--------------+--------------------------+
| mysql-bin.000005 |      906 |              | mysql,infogmation_schema |
+------------------+----------+--------------+--------------------------+

#100.100.100.106
change master to
master_user='slave',
master_password='123456',
master_host='100.100.100.105',
master_log_file='mysql-bin.000005',
master_log_pos=906;

1.5、106機械を主とし、105は従
#100.100.100.106
mysql> grant replication slave on *.* to slave@'100.100.100.105' identified by '123456';
mysql> show master status;
+------------------+----------+--------------+--------------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB         |
+------------------+----------+--------------+--------------------------+
| mysql-bin.000002 |      266 |              | mysql,infogmation_schema |
+------------------+----------+--------------+--------------------------+

#100.100.100.105
change master to
master_user='slave',
master_password='123456',
master_host='100.100.100.106',
master_log_file='mysql-bin.000002',
master_log_pos=266;

1.6、mysqlから
mysql> start slave;

1.7、テスト成功
mysql> show slave status\G;   (     )
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes