技能分享
recruitment
以后地位: » »

MySQL主主互备联合keepalived完成高可用

公布>###00:40  泉源:  作者:

实验情况:

master###CentOS6.5

slave###CentOS6.5

VIP###

 

MySQL主主互备形式设置装备摆设

step1Master办事的/etc/my.cnf设置装备摆设

1

2

3

4

5

6

7

8

9

10

11

12

[mysqld]

basedir = /usr/local/mysql

datadir = /var/lib/mysql

port = 3306

socket = /var/lib/mysql/mysql.sock

 

server_id = 1

log-bin = mysql-bin

relay-log = mysql-relay-bin

replicate-wild-ignore-table=mysql.%   #指定不必要复制的库,mysql.%表现mysql库下的一切工具

replicate-wild-ignore-table=test.%

replicate-wild-ignore-table=information_schema.%

step2Slave办事的/etc/my.cnf设置装备摆设

1

2

3

4

5

6

7

8

9

10

11

12

[mysqld]

basedir = /usr/local/mysql

datadir = /var/lib/mysql

port = 3306

socket = /var/lib/mysql/mysql.sock

 

server_id = 2

log-bin = mysql-bin

relay-log = mysql-relay-bin

replicate-wild-ignore-table=mysql.%

replicate-wild-ignore-table=test.%

replicate-wild-ignore-table=information_schema.%

step3:重启两台主从mysql办事

1

2

3

4

5

6

[>###;~]# service mysqld restart

Shutting down MySQL..                                      [  OK  ]

Starting MySQL.                                            [  OK  ]

[>###;~]# service mysqld restart

Shutting down MySQL..                                      [  OK  ]

Starting MySQL.                                            [  OK  ]

 

step4:检察主从的log-bin日记形态

记载FilePosition的值

1

2

3

4

5

6

7

[>###;~]# mysql -uroot -ppasswd -e 'show master status'

Warning: Using a password on the command line interface can be insecure.

###-----+----------+--------------+------------------+-------------------+

| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

###-----+----------+--------------+------------------+-------------------+

| mysql-bin.000001 |      414 |              |                  |                   |

###-----+----------+--------------+------------------+-------------------+

1

2

3

4

5

6

7

[>###;~]# mysql -uroot -ppasswd -e 'show master status'

Warning: Using a password on the command line interface can be insecure.

###-----+----------+--------------+------------------+-------------------+

| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

###-----+----------+--------------+------------------+-------------------+

| mysql-bin.000001 |      414 |              |                  |                   |

###-----+----------+--------------+------------------+-------------------+

 

step5:创立主从同步replication用户

1master

1

2

3

4

5

6

7

8

9

10

mysql> grant replication slave on *.* to 'replication'@'192.168.1.%' identified by 'replication';

mysql> flush privileges;

mysql> change master to

    -> master_host='192.168.1.211',

    -> master_user='replication',

    -> master_password='replication',

    -> master_port=3306,

    -> master_log_file='mysql-bin.000001',

    -> master_log_pos=414;

mysql> start slave;

2slave

1

2

3

4

5

6

7

8

9

10

mysql> grant replication slave on *.* to 'replication'@'192.168.1.%' identified by 'replication';<

  • 上一篇: 没有材料了
  • 下一篇:

公司简介
company profile

办理方案
solution

客户案例
Customer case

>###029-88272226
在线QQ:1623634940
>###032
e-mail:>###
>###369号万达广场3号甲写1401室

官方微信

Copyright © 2019 陕西米乐体系信息技能有限公司.