clckhouse集群 可以向分布式表插入数据,但是无法查询 查询报错

org.jkiss.dbeaver.model.sql.DBSQLException: SQL 错误 [516]: ClickHouse exception, code: 516, host: 192.168.3.50, port: 8123; Code: 516, e.displayText() = DB::Exception: Received from 192.168.0.183:9000. DB::Exception: default: Authentication failed: password is incorrect or there is no user with such name. (version 21.5.5.12 (official build))

    at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:133)
    at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeStatement(SQLQueryJob.java:509)
    at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.lambda$0(SQLQueryJob.java:440)
    at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:168)
    at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeSingleQuery(SQLQueryJob.java:427)
    at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.extractData(SQLQueryJob.java:812)
    at org.jkiss.dbeaver.ui.editors.sql.SQLEditor$QueryResultsContainer.readData(SQLEditor.java:3220)
    at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:121)
    at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:168)
    at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:119)
    at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:4516)
    at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:105)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: ru.yandex.clickhouse.except.ClickHouseException: ClickHouse exception, code: 516, host: 192.168.3.50, port: 8123; Code: 516, e.displayText() = DB::Exception: Received from 192.168.0.183:9000. DB::Exception: default: Authentication failed: password is incorrect or there is no user with such name. (version 21.5.5.12 (official build))

    at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.specify(ClickHouseExceptionSpecifier.java:59)
    at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.specify(ClickHouseExceptionSpecifier.java:29)
    at ru.yandex.clickhouse.ClickHouseStatementImpl.checkForErrorAndThrow(ClickHouseStatementImpl.java:1094)
    at ru.yandex.clickhouse.ClickHouseStatementImpl.getInputStream(ClickHouseStatementImpl.java:773)
    at ru.yandex.clickhouse.ClickHouseStatementImpl.getLastInputStream(ClickHouseStatementImpl.java:691)
    at ru.yandex.clickhouse.ClickHouseStatementImpl.executeQuery(ClickHouseStatementImpl.java:340)
    at ru.yandex.clickhouse.ClickHouseStatementImpl.executeQuery(ClickHouseStatementImpl.java:324)
    at ru.yandex.clickhouse.ClickHouseStatementImpl.executeQuery(ClickHouseStatementImpl.java:319)
    at ru.yandex.clickhouse.ClickHouseStatementImpl.executeQuery(ClickHouseStatementImpl.java:314)
    at ru.yandex.clickhouse.ClickHouseStatementImpl.execute(ClickHouseStatementImpl.java:445)
    at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.execute(JDBCStatementImpl.java:327)
    at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:130)
    ... 12 more
Caused by: java.lang.Throwable: Code: 516, e.displayText() = DB::Exception: Received from 192.168.0.183:9000. DB::Exception: default: Authentication failed: password is incorrect or there is no user with such name. (version 21.5.5.12 (official build))

    at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.specify(ClickHouseExceptionSpecifier.java:54)
    ... 23 more
 

default不设置密码即可

可以在/etc/clickhouse-server/config.xml的分片副本设置用户名密码,参考官方文档:https://clickhouse.com/docs/zh/engines/table-engines/special/distributed/
例如

<shard>
                <internal_replication>true</internal_replication>
                <replica>
                    <host>ck001</host>
                    <port>9000</port>
                    <user>default</user>
                    <password>default</password>
                </replica>
            </shard>

server :) CREATE TABLE default.t_cluster ON CLUSTER distable ( id Int16, name String, birth Date )ENGINE = MergeTree() PARTITION BY toYYYYMM(birth) ORDER BY id;

CREATE TABLE default.t_cluster ON CLUSTER distable
(
    `id` Int16,
    `name` String,
    `birth` Date
)
ENGINE = MergeTree
PARTITION BY toYYYYMM(birth)
ORDER BY id

Query id: 1d0e4858-3347-46f4-ac0a-b2c3a915a505

┌─host──────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ 192.168.0.183 │ 9000 │      0 │       │                   3 │                2 │
│ 192.168.0.183 │ 9001 │      0 │       │                   2 │                2 │
└───────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
┌─host─────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ 192.168.3.50 │ 9000 │      0 │       │                   1 │                0 │
│ 192.168.3.50 │ 9001 │      0 │       │                   0 │                0 │
└──────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘

4 rows in set. Elapsed: 0.291 sec. 

server :) CREATE TABLE default.dist_t_cluster ON CLUSTER distable as t_cluster engine = Distributed(distable, default, t_cluster, rand());

CREATE TABLE default.dist_t_cluster ON CLUSTER distable AS t_cluster
ENGINE = Distributed(distable, default, t_cluster, rand())

Query id: 393c8c2b-3604-4f5e-b925-1ede8b842c26

┌─host──────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ 192.168.0.183 │ 9000 │      0 │       │                   3 │                0 │
│ 192.168.3.50  │ 9000 │      0 │       │                   2 │                0 │
│ 192.168.0.183 │ 9001 │      0 │       │                   1 │                0 │
└───────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
┌─host─────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐
│ 192.168.3.50 │ 9001 │      0 │       │                   0 │                0 │
└──────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘

4 rows in set. Elapsed: 0.292 sec. 

server :) insert into dist_t_cluster values(1, 'aaa', '2021-02-01'), (2, 'bbb', '2021-02-02');

INSERT INTO dist_t_cluster VALUES

Query id: 118dd13f-f8e8-48f2-be87-6dfec5771b2c

Ok.

2 rows in set. Elapsed: 0.004 sec. 

server :) select * from dist_t_cluster;

SELECT *
FROM dist_t_cluster

Query id: 97401bdf-1979-4578-86ab-25980f179f88


0 rows in set. Elapsed: 0.008 sec. 

Received exception from server (version 21.5.5):
Code: 516. DB::Exception: Received from localhost:9000. DB::Exception: Received from 192.168.0.183:9000. DB::Exception: default: Authentication failed: password is incorrect or there is no user with such name. 

server :) 
 

我也遇到这个问题了,大佬解决了吗?default 不设置密码我也可以,设置密码就报这个错。

集群ip 端口均设置正常 也已设置任何ip都可以连接各个节点 但是查询分布式表一直报这个错,,插入缺没有问题