启用监听主机0.0.0.0后,clickhouse-client无法登录

时间:2019-07-24 02:02:47

标签: clickhouse

在Hyper-V VM的Ubuntu 18.04.2上安装ClickHouse之后,我使用VM内的clickhouse-client进行连接,效果很好。

我使用主机PC中的浏览器打开http://127.27.16.11:8123,它显示ERR_CONNECTION_REFUSED错误。然后,我编辑/etc/clickhouse-server/config.xml并取消注释0.0.0.0,然后重新启动clickhouse-server。我刷新浏览器,它显示OK状态。

但是,当我再次使用VM内的clickhouse-client来连接服务器时,它提示连接被拒绝。有什么方法可以同时启用本​​地和远程连接?

还尝试同时启用IPv4和IPv6 :: 0.0.0.0

ubuntu02:/$ clickhouse-client
ClickHouse client version 19.11.3.11 (official build).
Connecting to localhost:9000 as user default.
Connected to ClickHouse server version 19.11.3 revision 54423.

ubuntu02 :) quit
Bye.

ubuntu02:/$ sudo vi /etc/clickhouse-server/config.xml
[sudo] password for panco:

##uncomment
<listen_host>0.0.0.0</listen_host>

ubuntu02:/$ ping ubuntu02
PING ubuntu02 (172.27.16.11) 56(84) bytes of data.
64 bytes from ubuntu02 (172.27.16.11): icmp_seq=1 ttl=64 time=0.015 ms
64 bytes from ubuntu02 (172.27.16.11): icmp_seq=2 ttl=64 time=0.040 ms
^C
--- ubuntu02 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3039ms
rtt min/avg/max/mdev = 0.015/0.033/0.040/0.012 ms

ubuntu02:/$ sudo service clickhouse-server restart

ubuntu02:/$ clickhouse-client
ClickHouse client version 19.11.3.11 (official build).
Connecting to localhost:9000 as user default.
Code: 210. DB::NetException: Connection refused (localhost:9000)

代码:210。DB :: NetException:连接被拒绝(localhost:9000)

3 个答案:

答案 0 :(得分:0)

您可以指定几个主机进行监听。尝试以下配置:

<!-- Listen specified host. use :: (wildcard IPv6 address), if you want to accept connections both with IPv4 and IPv6 from everywhere. -->
<listen_host>::</listen_host>
<!-- Default values - try listen localhost on ipv4 and ipv6: -->
<listen_host>::1</listen_host>
<listen_host>127.0.0.1</listen_host>

答案 1 :(得分:0)

找到了答案,我太在意那些我使用的IP是IPv4,实际上,Ubuntu默认情况下启用了IPv6。只需取消注释此行

<listen_host>::</listen_host> 

问题已解决。无论如何,都要感谢Slesh的热烈响应。

答案 2 :(得分:0)

尝试:

clickhouse-client -h 127.0.0.1