crm(live)# status
Stack: corosync
Current DC: node1 (version 1.1.16-12.el7_4.4-94ff4df) - partition with quorum
Last updated: Wed Oct 25 08:38:22 2017
Last change: Wed Oct 25 08:38:14 2017 by root via crm_attribute on node2
2 nodes configured
5 resources configured
Online: [ node1 node2 ]
Full list of resources:
Master/Slave Set: ms_mysqldrbd [mysqldrbd]
Masters: [ node1 ]
Slaves: [ node2 ]
mystore(ocf::heartbeat:Filesystem):Started node1
mysqld(systemd:mariadb):Started node1
myvip(ocf::heartbeat:IPaddr):Started node1
三、测试
先访问数据库,并新建一个用户,供远程访问使用
1
2
MariaDB[(none)]> GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
QueryOK, 0 rows affected (0.00 sec)
使用VIP访问数据库
[iyunv@node1 ~]# mysql -uroot -p123456 -h 192.168.163.100
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+---------------------+
| Database |
+---------------------+
| information_schema |
| #mysql50#lost+found |
| mysql |
| mysqld |
| performance_schema |
| xhk |
| xhk777 |
+---------------------+
7 rows in set (0.06 sec)
接下来,将node停掉,服务自行转到node2
1
crm(live)# node standby
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
crm(live)# status
Stack: corosync
Current DC: node1 (version 1.1.16-12.el7_4.4-94ff4df) - partition with quorum
Last updated: Wed Oct 25 08:43:46 2017
Last change: Wed Oct 25 08:43:41 2017 by root via crm_attribute on node1
crm(live)# status
Stack: corosync
Current DC: node1 (version 1.1.16-12.el7_4.4-94ff4df) - partition with quorum
Last updated: Wed Oct 25 08:43:46 2017
Last change: Wed Oct 25 08:43:41 2017 by root via crm_attribute on node1
2 nodes configured
5 resources configured
Node node1: standby
Online: [ node2 ]
Full list of resources:
Master/Slave Set: ms_mysqldrbd [mysqldrbd]
Slaves: [ node2 ]
Stopped: [ node1 ]
mystore(ocf::heartbeat:Filesystem):Stopped
mysqld(systemd:mariadb):Stopped
myvip(ocf::heartbeat:IPaddr):Started node2
继续使用VIP访问数据库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[iyunv@node1 ~]# mysql -uroot -p123456 -h 192.168.163.100
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+---------------------+
| Database |
+---------------------+
| information_schema |
| #mysql50#lost+found |
| mysql |
| mysqld |
| performance_schema |
| xhk |
| xhk777 |
+---------------------+
7 rows in set (0.06 sec)