升级到较新版本Clickhouse,在进行备份恢复操作的时候,出现了某些表建表报错,具体报错如下:can't create table 'db_ops.white_lists_delete': code: 491, message: URL "r-xx-xxxx.service.consul:3306" is not allowed in configuration file, see <remote_url_allow_hosts>, will try again.从报错信息来看,这是由于创建表时使用了远程表引擎(如 MySQL、URL 或 Remote),但 ClickHouse 配置中未允许访问指定的 URL 或主机。我们需要在配置中添加<remote_url_allow_hosts>配置项。此配置是ClickHouse在20.5版本中引入的安全特性,从该版本开始,ClickHouse默认禁止访问未明确允许的外部URL或主机,以增强安全性。打开 ClickHouse 的配置文件,通常位于 /etc/clickhouse-server/config.xml 或 /etc/clickhouse-server/config.d/ 目录下。找到 <remote_url_allow_hosts> 配置项,将目标主机添加进去。<yandex>
<remote_url_allow_hosts>
<host>r-xx-xxxx.service.consul</host>
<!-- 如果需要允许所有主机,可以使用通配符,生产环境不建议 -->
<host>*</host>
</remote_url_allow_hosts>
</yandex>
这里端口号需要注意,若只允许3306端口,其他不允许,我们需要配置里显式添加上3306端口,只填写域名或者IP则允许所有端口。sudo systemctl restart clickhouse-server
3. 若我们不想修改配置文件并重启 ClickHouse,可以通过 SQL 动态设置 remote_url_allow_hosts,然后再尝试建表,不过动态配置只是当前的会话临时有效,永久还是建议走配置文件方式。SET remote_url_allow_hosts = 'r-xx-xxxx.service.consul';
阅读累了,舒缓下眼睛,大佬们