首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >ClickHouse错误(21.6.6版):代码: 1000 DB::Exception: Exception:连接到所有副本失败

ClickHouse错误(21.6.6版):代码: 1000 DB::Exception: Exception:连接到所有副本失败
EN

Stack Overflow用户
提问于 2021-07-26 16:58:39
回答 3查看 2K关注 0票数 2

我正在尝试将ClickHouse与本地MySQL数据库连接起来,即使用引擎MYSQL。我已经运行了这些命令来获取重要的数据。

代码语言:javascript
运行
复制
mysql> SELECT * FROM amazon_redshift.analytics limit 10;

+-------+------------+----------+------------+------------+-----------------------------+-------------------------------+-------------------------+
| count | date       | store_id | created_at | updated_at | ret_cust_rate               | orders_ret_cust               | recommendation_accuracy |
+-------+------------+----------+------------+------------+-----------------------------+-------------------------------+-------------------------+
|   875 | 2021-03-01 |   199703 | 2021-07-26 | 2021-07-26 | {"new":"1","returning":"0"} | {"new":"100","returning":"0"} | NULL                    |
|   425 | 2021-03-01 |   212743 | 2021-07-26 | 2021-07-26 | {"new":"1","returning":"0"} | {"new":"100","returning":"0"} | NULL                    |
|    81 | 2021-03-01 |   213745 | 2021-07-26 | 2021-07-26 | {"new":"1","returning":"0"} | {"new":"100","returning":"0"} | NULL                    |
|   189 | 2021-03-01 |   204112 | 2021-07-26 | 2021-07-26 | {"new":"1","returning":"0"} | {"new":"100","returning":"0"} | NULL                    |
|   309 | 2021-03-01 |   204125 | 2021-07-26 | 2021-07-26 | {"new":"1","returning":"0"} | {"new":"100","returning":"0"} | NULL                    |
|   761 | 2021-03-01 |   209940 | 2021-07-26 | 2021-07-26 | {"new":"1","returning":"0"} | {"new":"100","returning":"0"} | NULL                    |
|   699 | 2021-03-01 |   214119 | 2021-07-26 | 2021-07-26 | {"new":"1","returning":"0"} | {"new":"100","returning":"0"} | NULL                    |
|   913 | 2021-03-01 |   201062 | 2021-07-26 | 2021-07-26 | {"new":"1","returning":"0"} | {"new":"100","returning":"0"} | NULL                    |
|   792 | 2021-03-01 |   210493 | 2021-07-26 | 2021-07-26 | {"new":"1","returning":"0"} | {"new":"100","returning":"0"} | NULL                    |
|   182 | 2021-03-01 |   203925 | 2021-07-26 | 2021-07-26 | {"new":"1","returning":"0"} | {"new":"100","returning":"0"} | NULL                    |
+-------+------------+----------+------------+------------+-----------------------------+-------------------------------+-------------------------+
10 rows in set (0,00 sec)
代码语言:javascript
运行
复制
mysql> status
--------------
mysql  Ver 8.0.25-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))

Connection id:      13
Current database:   amazon_redshift
Current user:       root@localhost
SSL:            Not in use
Current pager:      stdout
Using outfile:      ''
Using delimiter:    ;
Server version:     8.0.25-0ubuntu0.20.04.1 (Ubuntu)
Protocol version:   10
Connection:     Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:        /var/run/mysqld/mysqld.sock
Binary data as:     Hexadecimal
Uptime:         2 hours 53 min 46 sec

Threads: 2  Questions: 52  Slow queries: 0  Opens: 157  Flush tables: 3  Open tables: 76  Queries per second avg: 0.004
--------------

mysql> SELECT SUBSTRING_INDEX(USER(), '@', -1) AS ip,  @@hostname as hostname, @@port as port, DATABASE() as current_database;
+-----------+--------------------------------+------+------------------+
| ip        | hostname                       | port | current_database |
+-----------+--------------------------------+------+------------------+
| localhost | helena-ZenBook-UX451FL-UX289FL | 3306 | amazon_redshift  |
+-----------+--------------------------------+------+------------------+
代码语言:javascript
运行
复制
$ sudo lsof -i TCP:3306 
COMMAND  PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
mysqld  1134 mysql   27u  IPv4  42528      0t0  TCP localhost:mysql (LISTEN)

然后我运行了clickHouse的码头映像:

代码语言:javascript
运行
复制
CREATE DATABASE dummy ENGINE = Memory;

CREATE TABLE dummy.analytics
(
    `count` UInt8,
    `date` date NOT NULL,
    `store_id` bigint NOT NULL,
    `created_at` date NOT NULL,
    `updated_at` date NOT NULL,
    `ret_cust_rate` text,
    `orders_ret_cust` text,
    `recommendation_accuracy` text
)
ENGINE = MySQL('localhost:3306', 'amazon_redshift', 'analytics', 'root', 'Password9876')


SELECT *
FROM dummy.analytics
LIMIT 10;

从服务器接收异常(21.6.6版本):代码: 1000。DB::Exception:从clickhouse-server:9000收到。异常:异常:连接到所有副本的失败: amazon_redshift@localhost:3306作为用户根。

有人知道为什么吗?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2021-07-26 17:33:55

原因是使用localhost:3306,其中localhost指向容器,而不是外部主机。

出于测试目的,考虑使用网络-settings作为主机访问主机网络:

代码语言:javascript
运行
复制
docker run --network="host" ..

作为另一种方式,可以使用docker同时托管MySQL和ClickHouse (例如,请参见CH & Kafka)。

票数 1
EN

Stack Overflow用户

发布于 2021-07-27 10:21:21

使用docker时,我以其他方式启动了clickHouse客户机:

代码语言:javascript
运行
复制
sudo apt-get install apt-transport-https ca-certificates dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E0C56BD4
echo "deb https://repo.clickhouse.tech/deb/stable/ main/" | sudo tee \
    /etc/apt/sources.list.d/clickhouse.list
sudo apt-get update

sudo apt-get install -y clickhouse-server clickhouse-client

sudo service clickhouse-server start

clickhouse-client --password=<your-password>

然后使用另一个命令:

代码语言:javascript
运行
复制
CREATE DATABASE analytics ENGINE = MySQL('127.0.0.1:3306', 'amazon_redshift', 'root', 'Password9876')

并且它的工作原理与ClickHouse示例(https://clickhouse.tech/docs/en/engines/database-engines/mysql/)一样正确。

票数 1
EN

Stack Overflow用户

发布于 2022-08-18 10:42:34

您的mysql需要访问者ip白名单

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68533770

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档