8.查看一下端口号
[root@node2 ~]# netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:610 0.0.0.0:* LISTEN 2548/rpc.statd
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 8507/MySQLd
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2509/portmap
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2842/cupsd
tcp 0 0 0.0.0.0:36600 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:5560 0.0.0.0:* LISTEN 3157/mgmtd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2933/sendmail: acce
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 6706/1
tcp 0 0 :::22 :::* LISTEN 2829/sshd
tcp 0 0 ::1:6011 :::* LISTEN 6706/1
udp 0 0 0.0.0.0:40975 0.0.0.0:* 2918/heartbeat: wri
udp 0 0 0.0.0.0:33809 0.0.0.0:* -
udp 0 0 0.0.0.0:57110 0.0.0.0:* 3062/avahi-daemon:
udp 0 0 0.0.0.0:694 0.0.0.0:* 2918/heartbeat: wri
udp 0 0 0.0.0.0:604 0.0.0.0:* 2548/rpc.statd
udp 0 0 0.0.0.0:607 0.0.0.0:* 2548/rpc.statd
udp 0 0 0.0.0.0:5353 0.0.0.0:* 3062/avahi-daemon:
udp 0 0 0.0.0.0:111 0.0.0.0:* 2509/portmap
udp 0 0 0.0.0.0:631 0.0.0.0:* 2842/cupsd
udp 0 0 :::46858 :::* 3062/avahi-daemon:
udp 0 0 :::5353 :::* 3062/avahi-daemon:
9.查看一下接口IP
[root@node2 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:EA:CE:79
inet addr:192.168.18.202 Bcast:192.168.18.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feea:ce79/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:133635 errors:0 dropped:0 overruns:0 frame:0
TX packets:46597 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:46103367 (43.9 MiB) TX bytes:9677373 (9.2 MiB)
eth0:0 Link encap:Ethernet HWaddr 00:0C:29:EA:CE:79
inet addr:192.168.18.200 Bcast:192.168.18.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:287 errors:0 dropped:0 overruns:0 frame:0
TX packets:287 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:27967 (27.3 KiB) TX bytes:27967 (27.3 KiB)
10.查看一下资源状态
说明:从图中可以看出,所有资源全部运行在node2上,现在我们就去访问一下mysql服务
11.node2上测试连接mysql
[root@node2 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.33-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydb |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.03 sec)
12.mysql授权
12 mysql> grant all on *.* to root@"192.168.18.%" identified by "123456";
mysql> flush privileges;
13.测试一下集群效果,直接访问192.168.18.200
[root@nfs ~]# /usr/local/mysql/bin/mysql -uroot -p123456 -h 192.168.18.200
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.33-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydb |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.01 sec)
14.模拟故障
(1).将node2节点,设置为standby,大家可以看,所有资源全部切换到node1上
(2).node1上查看一下端口
[root@node1 ~]# netstat -ntulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:616 0.0.0.0:* LISTEN 2554/rpc.statd
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 22825/mysqld
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2515/portmap
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2850/cupsd
tcp 0 0 0.0.0.0:5560 0.0.0.0:* LISTEN 3170/mgmtd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2940/sendmail: acce
tcp 0 0 0.0.0.0:58330 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 20469/1
tcp 0 0 :::22 :::* LISTEN 2837/sshd
tcp 0 0 ::1:6011 :::* LISTEN 20469/1
udp 0 0 0.0.0.0:50185 0.0.0.0:* 2925/heartbeat: wri
udp 0 0 0.0.0.0:47376 0.0.0.0:* 3069/avahi-daemon:
udp 0 0 0.0.0.0:694 0.0.0.0:* 2925/heartbeat: wri
udp 0 0 0.0.0.0:41302 0.0.0.0:* -
udp 0 0 0.0.0.0:610 0.0.0.0:* 2554/rpc.statd
udp 0 0 0.0.0.0:613 0.0.0.0:* 2554/rpc.statd
udp 0 0 0.0.0.0:5353 0.0.0.0:* 3069/avahi-daemon:
udp 0 0 0.0.0.0:111 0.0.0.0:* 2515/portmap
udp 0 0 0.0.0.0:631 0.0.0.0:* 2850/cupsd
udp 0 0 :::5353 :::* 3069/avahi-daemon:
udp 0 0 :::46332 :::* 3069/avahi-daemon:
(3).node1上查看一下IP
[root@node1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:23:76:4D
inet addr:192.168.18.201 Bcast:192.168.18.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe23:764d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:285092 errors:0 dropped:0 overruns:0 frame:0
TX packets:319282 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:155185716 (147.9 MiB) TX bytes:297534308 (283.7 MiB)
eth0:0 Link encap:Ethernet HWaddr 00:0C:29:23:76:4D
inet addr:192.168.18.200 Bcast:192.168.18.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:63015 errors:0 dropped:0 overruns:0 frame:0
TX packets:63015 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:46067195 (43.9 MiB) TX bytes:46067195 (43.9 MiB)
(4).node1上测试访问一下mysql
[root@node1 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.33-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydb |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.02 sec)
(5).远程测试连接一下mysql
[root@nfs ~]# /usr/local/mysql/bin/mysql -uroot -p123456 -h 192.168.18.200
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.33-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydb |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.01 sec)
注:高可用的mysql集群,演示全部完成,最后粘一下cib配置文件,供大家参考!