MariaDB [(none)]> grant all on *.* to'root'@'172.16.%.%' identified by 'magedu';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all on *.* to'root'@'%mysql.com' identified by 'magedu'; # 这里的密码应该与dbServer.xml中的数据库密码一致
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
# 登录验证
[root@mysql conf]# mysql -h127.0.0.1 -uroot -p -P3306
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 2097086015
Server version: 5.1.45-mysql-amoeba-proxy-2.2.0 Source distribution
Copyright (c) 2000, 2014, Oracle, SkySQL Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000030 | 326 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
MySQL [(none)]>
# 读写验证
[root@mysql conf]# mysql -h127.0.0.1 -uroot -p -P3306
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 2097086015
Server version: 5.1.45-mysql-amoeba-proxy-2.2.0 Source distribution
Copyright (c) 2000, 2014, Oracle, SkySQL Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> create database amoeba_test;
Query OK, 1 row affected (0.04 sec)
MySQL [(none)]>
[root@mysql bin]# mysql -h127.0.0.1 -uroot -p -P3406
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 33
Server version: 10.0.10-MariaDB-log Source distribution
Copyright (c) 2000, 2014, Oracle, SkySQL Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| amoeba_test |
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
9 rows in set (0.01 sec)
MariaDB [(none)]>
# 从amoeba接口登录创建数据库amoeba_test后,再从主库的接口中去查询数据库已创建,说明写入确实是落在了主库节点上;
# 若要验证ameoba对于读操作的调度,则需要暂时停止从库的复制操作,然后在主库上更新数据,这样从ameoba读取数据将出现不一致的情况;
3.5 后期扩展
利用MMM双主复制架构+Amoeba代理,可以实现对MySQL的高可用性和高性能;
关于MMM的内容参加博文"MySQL Scale Out"
4 问题记录
现象:使用mysql -uroot -p -P8066命令始终无法连接进入ameoba的配置接口,一直都是进入mysql数据库的配置接口
原因:在测试环境下,ameoba和mysql的主库都部署在同一台主机上,当启动ameoba服务后,即使指定-P8066连接,mysql客户端还是默认采用可被识别的socket文件(/tmp/mysql.sock)连接,同样指定-hlocalhost也是一样的;
当使用mysql命令连接mysqld时:
连接主机为localhost或不指定时,mysql会采用Unix Socket的连接方式;
连接主机为127.0.0.1时,mysql会采用TCP的方式连接;
解决方法:指定-h127.0.0.1连接即可,即mysql -h127.0.0.1 -uroot -p -P8066