程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> Keepalived+MySQL雙主架構,keepalivedmysql

Keepalived+MySQL雙主架構,keepalivedmysql

編輯:MySQL綜合教程

Keepalived+MySQL雙主架構,keepalivedmysql


l  架構准備

Node1

192.168.15.3

Node2

192.168.15.4

VIP

192.168.15.254

 

l  軟件

MySQL 5.6 Keepalive

yum install gcc python-devel

easy_install mysql-python

 

l  MySQL配置

node1:

server-id = 033306

log-bin = mysql-bin

binlog-format = row

log-slave-updates = true

gtid-mode = on

enforce-gtid-consistency = true

auto-increment-increment = 2

auto-increment-offset = 1

relay-log = /var/lib/mysql/relay-log-3306

node2:

server-id = 043306

log-bin = mysql-bin

binlog-format = row

log-slave-updates = true

gtid-mode = on

enforce-gtid-consistency = true

auto-increment-increment = 2

auto-increment-offset = 2

relay-log = /var/lib/mysql/relay-log-3306

查看兩個UUID

Node1

e05b8b73-fa94-11e4-aa31-000c29b0dac1

show global variables like '%uuid%';

Node2

2e619521-9eb4-11e5-9868-000c295b6358

賦權(node1和node2)

mysql> grant replication slave,replication client on *.* to repluser@'192.168.15.%' identified by 'replpass';

mysql> flush privileges;

 

備份:

 

mysqldump -uroot   --opt --default-character-set=utf8 --triggers -R --master-data=2 --hex-blob --single-transaction --no-autocommit --all-databases > all.sql

注(會有一個警告):

Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events.

將導出的數據放到node2中(用免秘鑰傳輸過去):

[root@node1 ~]# yum -y install openssh-clients

[root@node2 mysql]# yum -y install openssh-clients

在node1上

[root@node1 ~]# ssh-keygen

[root@node1 ~]# ssh-copy-id 192.168.15.4

傳送文件

[root@node1 ~]# scp -rv all.sql 192.168.15.4:/tmp

=================================================

在node2上

[root@node2 mysql]# mysql </tmp/all.sql

 

在node2上配置連接

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved