mycat中间件读写分离配置(4)
时间:2016-10-30 22:22 来源:潇湘夜雨 作者:华嵩阳 点击:次
| NAME | DATHOST | INDEX | TYPE | ACTIVE | IDLE | SIZE | EXECUTE | TOTAL_TIME | MAX_TIME | MAX_SQL | RECOVERY_TIME |
+------+---------------------+-------+-------+--------+------+------+---------+------------+----------+---------+---------------+
| dn1 | localhost1/test | 0 | mysql | 0 | 6 | 1000 | 425 | 0 | 0 | 0 | -1 |
| dn2 | localhost1/phpcmsv9 | 0 | mysql | 0 | 2 | 1000 | 157 | 0 | 0 | 0 | -1 |
+------+---------------------+-------+-------+--------+------+------+---------+------------+----------+---------+---------------+
2 rows in set (0.01 sec)
mysql> show @@server; #mycat服务运行状态
+-------------+-------------+--------------+------------+---------------+---------------+---------+--------+-----------------------+
| UPTIME | USED_MEMORY | TOTAL_MEMORY | MAX_MEMORY | RELOAD_TIME | ROLLBACK_TIME | CHARSET | STATUS | AVG_BUFPOOL_ITEM_SIZE |
+-------------+-------------+--------------+------------+---------------+---------------+---------+--------+-----------------------+
| 1h 11m 44s | 195614552 | 1037959168 | 4151836672 | 1477638123211 | -1 | utf8 | ON | 351 |
+-------------+-------------+--------------+------------+---------------+---------------+---------+--------+-----------------------+
5、配置中的问题
1>mycat1.6版本在centos6上配置后可能启动不了,目前建议在centos7上安装,或者使用1.5版本.
2>mycat的sql_mode =STRICT_TRANS_TABLES,如果表字段为空且没有默认值,一般会报错。如下
INSERT INTO `phpcmsv9`.`v9_log`(`module`,`username`,`userid`,`action`,`querystring`,`time`,`ip`) VALUES ('content','phpcms','1','content','?m=content&c=content&a=clear_data','2016-10-28 16-23-24','172.18.109.207')
mysql> select @@sql_mode;
+-------------------------------------------------------------------------------------------------------------------------------------------+
| @@sql_mode |
+-------------------------------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
解决方法:取消STRICT_TRANS_TABLES的限制
mysql> SET sql_mode=`NO_FIELD_OPTIONS,HIGH_NOT_PRECEDENCE`;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> select @@sql_mode;
+--------------------------------------+
| @@sql_mode |
+--------------------------------------+
| NO_FIELD_OPTIONS,HIGH_NOT_PRECEDENCE |
+--------------------------------------+
|