(3)测试主从数据同步:在主服务器(192.168.1.110)上操作:
[root@Andy ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:5E:6F:A7
inet addr:192.168.1.110 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe5e:6fa7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:142562 errors:0 dropped:0 overruns:0 frame:0
TX packets:141697 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:142192520 (135.6 MiB) TX bytes:17915582 (17.0 MiB)
Interrupt:193 Base address:0x2000
[root@Andy ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.44-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database Andy ;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| Andy |
| mysql |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> use Andy ;
Database changed
mysql> create table Andy (id int(3),name char(10));
Query OK, 0 rows affected (0.01 sec)
mysql> insert into Andy values (001,'imysql');
Query OK, 1 row affected (0.00 sec)
(提示:我刚刚在主服务器上创建了一个Andy 数据库和表,我现在在从服务器上查看结果,是否有Andy数据库和表?)
在从服务器(192.168.1.120)上操作:
[root@Andy ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:2B:8E:D2
inet addr:192.168.1.120 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe2b:8ed2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:180884 errors:0 dropped:0 overruns:0 frame:0
TX packets:146585 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:223461833 (213.1 MiB) TX bytes:15555296 (14.8 MiB)
Interrupt:193 Base address:0x2000
[root@Andy ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.44 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| Andy |
| mysql |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> use Andy ;
Database changed
mysql> select * from Andy ;
+------+--------+
| id | name |
+------+--------+
| 1 | imysql |
+------+--------+
1 row in set (0.00 sec)
(我擦,结果正确了,主从复制,同步成功。)