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

首发于: https://www.jwldata.com/archives/90.html

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

修改config.xml文件权限

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

修改端口和绑定地址

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

测试连接

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

clickhouse-client --port 9020 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值