微信搜索superit|邀请体验:大数据, 数据管理、OLAP分析与可视化平台 | 赞助作者:赞助作者

ClickHouse系列教程四:允许远程连接 allow remote access

clickhouse aide_941 30℃

ClickHouse系列教程四:允许远程连接 allow remote access

ClickHouse系列教程: ClickHouse系列教程


先查看ClickHouse server端监听端口的状态:

root@ubuntu:/var/lib/clickhouse/# lsof -i :8123
COMMAND   PID       USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
clickhous 653 clickhouse   41u  IPv6  32544      0t0  TCP ip6-localhost:8123 (LISTEN)
clickhous 653 clickhouse   44u  IPv4  32547      0t0  TCP localhost:8123 (LISTEN)
  • 1
  • 2
  • 3
  • 4

这里显示监听本地端口,需要修改配置:

nano /etc/clickhouse-server/config.xml
  • 1
    <!-- Listen specified host. use :: (wildcard IPv6 address), if you want to accept connections both with IPv4 and IPv6 from everywhere. -->
    <!--<listen_host>::</listen_host>       -->
    <!-- Same for hosts with disabled ipv6: -->
    <!-- <listen_host>0.0.0.0</listen_host> -->

    <!-- Default values - try listen localhost on ipv4 and ipv6: -->
    <!--
    <listen_host>::1</listen_host>
    <listen_host>127.0.0.1</listen_host>
    -->
    <!-- Don't exit if ipv6 or ipv4 unavailable, but listen_host with this protocol specified -->
    <!-- <listen_try>0</listen_try> -->

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

把注释掉的<listen_host>::</listen_host>取消注释,然后重启服务:

service clickhouse-server restart 
  • 1

现在就的端口监听情况:

root@ubuntu:/var/lib/clickhouse/data/# lsof -i :8123
COMMAND    PID       USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
clickhous 9188 clickhouse   32u  IPv6  61573      0t0  TCP *:8123 (LISTEN)
  • 1
  • 2
  • 3

一般来说不需要修改 users.xml这个文件。

-> # locate users.xml
/etc/clickhouse-server/users.xml
/var/lib/clickhouse/preprocessed_configs/users.xml
-> # nano /etc/clickhouse-server/users.xml
  • 1
  • 2
  • 3
  • 4

里面的内容如果是::/0那就不用修改了:

            <networks incl="networks" replace="replace">
                <ip>::/0</ip>
            </networks>
  • 1
  • 2
  • 3

转载请注明:SuperIT » ClickHouse系列教程四:允许远程连接 allow remote access

喜欢 (0)or分享 (0)