mysql> grant all on *.* to 'root'@'10.24.24.%'> Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from mysql.user; DB2上授权
mysql> grant all on *.* to 'root'@'10.24.24.%'> Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from mysql.user; 1.在远程客户端通过VIP登录测试
[root@mysql01 ~]# mysql -uroot -p -h 10.24.24.110
Enter password:
mysql> show variables like "%hostname%";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| hostname | DB1 |
+---------------+-------+
1 row in set (0.00 sec)
mysql> show variables like "%server_id%";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id | 1 |
+---------------+-------+
1 row in set (0.00 sec)
从SQL输出结果看,可以通过VIP登录,并且登录到了DB1服务器 2.数据复制功能测试
[root@mysql01 ~]# mysql -uroot -p -h 10.24.24.110
Enter password:
mysql> create database repldb;
Query OK, 1 row affected (0.00 sec)
mysql> use repldb;
Database changed
mysql> create table repl_table(id int,email varchar(86),password varchar(40) not null);
Query OK, 0 rows affected (0.00 sec)
mysql> show tables;
+------------------+
| Tables_in_repldb |
+------------------+
| repl_table |
+------------------+
1 row in set (0.00 sec)
mysql> insert into repl_table (id,email,password) values(1,"ywliyq@163.com","qwessd");
Query OK, 1 row affected (0.00 sec)
mysql> select * from repl_table;
+------+----------------+----------+
|> +------+----------------+----------+
| 1 | ywliyq@163.com | qwessd |
+------+----------------+----------+
1 row in set (0.00 sec)
在DB2数据库中查询数据是否已经同步
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| db01 |
| db02 |
| mysql |
| repldb |
| ywadmin |
+--------------------+
6 rows in set (0.00 sec)
mysql> use repldb;
Database changed
mysql> show tables;
+------------------+
| Tables_in_repldb |
+------------------+
| repl_table |
+------------------+
1 row in set (0.00 sec)
mysql> select * from repl_table;
+------+----------------+----------+