XiaoMi / Gaea

Gaea is a mysql proxy, it's developed by xiaomi b2c-dev team.
Apache License 2.0
2.65k stars 426 forks source link

HeidiSQL无法连接Gaea中间件Proxy #257

Closed DTCCP closed 5 months ago

DTCCP commented 5 months ago

配置类别是file 其中namespace内容为

{
    "name": "Proxy_namespace_1",
    "online": true,
    "read_only": false,
    "allowed_dbs": {
        "DB": true
    },
    "slow_sql_time": "1000",
    "black_sql": [
        ""
    ],
    "allowed_ip": null,
    "slices": [
        {
            "name": "slice-0",
            "user_name": "root",
            "password": "123456",
            "master": "192.168.226.10:3306",
            "slaves": ["192.168.226.11:3307"],
            "statistic_slaves": null,
            "capacity": 12,
            "max_capacity": 24,
            "idle_timeout": 60
        }
    ],
    "shard_rules": null,
    "users": [
        {
            "user_name": "Proxy",
            "password": "123456",
            "namespace": "Proxy_namespace_1",
            "rw_flag": 2,
            "rw_split": 1,
            "other_property": 0
        }
    ],
    "default_slice": "slice-0",
    "global_sequences": null
}

Gaea组件在192.168.226.9服务器上部署,和MySQL主从复制分开部署 主从多实例分开部署

使用Navicat,能通过测试连接,但是无法打开连接

屏幕截图 2024-06-04 220603

Gaea也能启动

屏幕截图 2024-06-04 220113

Gaea生成日志文件内容如下:

[2024-06-04 21:17:22] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [github.com/XiaoMi/Gaea/proxy/server.(*Server).onConn:server.go:144] Connected conn_id=10011, Proxy@192.168.226.205:11009 () namespace:Proxy_namespace_1 capability: 8365701
[2024-06-04 21:18:29] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [main.main.func1:main.go:86] Got signal 2, quit
[2024-06-04 21:49:46] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [github.com/XiaoMi/Gaea/proxy/server.NewAdminServer:admin.go:110] [server] NewAdminServer, Api Server running, netProto: http, addr: 0.0.0.0:13307
[2024-06-04 21:49:46] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [github.com/XiaoMi/Gaea/proxy/server.NewServer:server.go:103] server start succ, netProtoType: tcp4, addr: 0.0.0.0:13306
[2024-06-04 21:49:56] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [github.com/XiaoMi/Gaea/proxy/server.(*Server).onConn:server.go:144] Connected conn_id=10001, Proxy@192.168.226.205:11844 () namespace:Proxy_namespace_1 capability: 8365701
[2024-06-04 21:51:12] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [github.com/XiaoMi/Gaea/proxy/server.(*Server).onConn:server.go:144] Connected conn_id=10002, Proxy@192.168.226.205:11866 () namespace:Proxy_namespace_1 capability: 8365701
[2024-06-04 21:53:43] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [main.main.func1:main.go:86] Got signal 2, quit
[2024-06-04 21:56:03] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [github.com/XiaoMi/Gaea/proxy/server.NewAdminServer:admin.go:110] [server] NewAdminServer, Api Server running, netProto: http, addr: 0.0.0.0:13307
[2024-06-04 21:56:03] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [github.com/XiaoMi/Gaea/proxy/server.NewServer:server.go:103] server start succ, netProtoType: tcp4, addr: 0.0.0.0:13306
[2024-06-04 21:56:15] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [github.com/XiaoMi/Gaea/proxy/server.(*Server).onConn:server.go:144] Connected conn_id=10001, Proxy@192.168.226.205:11908 () namespace:Proxy_namespace_1 capability: 8365701
[2024-06-04 21:58:36] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [main.main.func1:main.go:86] Got signal 2, quit
[2024-06-04 22:05:45] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [github.com/XiaoMi/Gaea/proxy/server.NewAdminServer:admin.go:110] [server] NewAdminServer, Api Server running, netProto: http, addr: 0.0.0.0:13307
[2024-06-04 22:05:45] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [github.com/XiaoMi/Gaea/proxy/server.NewServer:server.go:103] server start succ, netProtoType: tcp4, addr: 0.0.0.0:13306
[2024-06-04 22:05:53] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [github.com/XiaoMi/Gaea/proxy/server.(*Server).onConn:server.go:144] Connected conn_id=10001, Proxy@192.168.226.205:11998 () namespace:Proxy_namespace_1 capability: 8365701
[2024-06-04 22:07:08] [gaea_proxy] [localhost.localdomain] [NOTICE] [900000001] [github.com/XiaoMi/Gaea/proxy/server.(*Server).onConn:server.go:144] Connected conn_id=10002, Proxy@192.168.226.205:12010 () namespace:Proxy_namespace_1 capability: 8365701

请问该怎么解决

xiyangxixian commented 5 months ago

这个应该是 Gaea 不支持多语句执行的,比如 db.Query('select 1;select 1;') 会报语法错误