• 欢迎关注微信公众号:九万里大数据
  • 请使用Ctrl+D收藏本站到书签栏
  • 手机也可访问本站 jwldata.com

ClickHouse更换默认端口和绑定端口到0.0.0.0

大数据技术 九万里大数据 2年前 (2021-03-17) 3783次浏览 0个评论 扫描二维码
文章目录[隐藏]

ClickHouse安装后,默认client连接端口是9000,这个端口跟CDH的cloudera manager agent的默认端口相同。且ClickHouse默认9000端口是绑定在127.0.0.1上的,无法从其他机器连接ClickHouse。

ClickHouse更换默认端口和绑定端口到0.0.0.0

修改config.xml文件权限

chmod u+w /etc/clickhouse-server/config.xml

ClickHouse更换默认端口和绑定端口到0.0.0.0

修改端口和绑定地址

vi /etc/clickhouse-server/config.xml

找到<tcp_port>9000</tcp_port>的配置项,将默认值9000改成其他,比如我改成9020

    <!-- Port for interaction by native protocol with:
         - clickhouse-client and other native ClickHouse tools (clickhouse-benchmark, clickhouse-copier);
         - clickhouse-server with other clickhouse-servers for distributed query processing;
         - ClickHouse drivers and applications supporting native protocol
         (this protocol is also informally called as "the TCP protocol");
         See also 'tcp_port_secure' for secure connections.
    -->
    <tcp_port>9020</tcp_port>

找到<listen_host>::</listen_host>的配置项,取消注释,这样就同时支持IPv4和IPv6了。
也可以选择取消注释<listen_host>0.0.0.0</listen_host>,就仅支持IPv4,不允许IPv6。

    <!-- Listen specified address.
         Use :: (wildcard IPv6 address), if you want to accept connections both with IPv4 and IPv6 from everywhere.
         Notes:
         If you open connections from wildcard address, make sure that at least one of the following measures applied:
         - server is protected by firewall and not accessible from untrusted networks;
         - all users are restricted to subset of network addresses (see users.xml);
         - all users have strong passwords, only secure (TLS) interfaces are accessible, or connections are only made via TLS interfaces.
         - users without password have readonly access.
         See also: https://www.shodan.io/search?query=clickhouse
      -->
    <listen_host>::</listen_host>

    <!-- Same for hosts without support for 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>
    -->

重启ClickHouse

systemctl restart clickhouse-server

ClickHouse更换默认端口和绑定端口到0.0.0.0

测试连接

更改默认client端口后,需要指定port参数指定端口。

clickhouse-client --port 9020 

ClickHouse更换默认端口和绑定端口到0.0.0.0


欢迎关注我的公众号“九万里大数据”,原创技术文章第一时间推送。
欢迎访问原创技术博客网站 jwldata.com,排版更清晰,阅读更爽快。


ClickHouse更换默认端口和绑定端口到0.0.0.0
 


本站文章,如未注明,均为原创 | 原创文章版权归九万里大数据所有,未经许可不得转载。
本文链接:ClickHouse更换默认端口和绑定端口到0.0.0.0
喜欢 (5)

您必须 登录 才能发表评论!