clickhouse是4台机器,2分片2副本的配置。创建完本地表和分布式表后,往分布式表中插入数据时,发现副本没有同步数据。查看报错日志:
Code: 221, e.displayText() = DB::Exception: No interserver IO endpoint named DataPartsExchange
2022.01.21 14:58:09.189339 [ 7134 ] {} <Error> default.test_tab (6cde91f6-fc30-4a5d-acde-91f6fc30da5d): auto DB::StorageReplicatedMergeTree::processQueueEntry
(ReplicatedMergeTreeQueue::SelectedEntryPtr)::(anonymous class)::operator()(DB::StorageReplicatedMergeTree::LogEntryPtr &) const: Code: 86, e.displayText() =
DB::Exception: Received error from remote server /?endpoint=DataPartsExchange%3A%2Fclickhouse%2Ftables%2F02%2Ftest_0121%2Freplicas%2Frep_2_2&part=20220118_0_0_0
&client_protocol_version=7&compress=false. HTTP status code: 500 Internal Server Error, body: Code: 221, e.displayText() = DB::Exception: No interserver IO endp
oint named DataPartsExchange:/clickhouse/tables/02/test_0121/replicas/rep_2_2, Stack trace (when copying this message, always include the lines below):
配置中internal_replication也设为true,这个配置之前在其他服务器上部署过,是没问题的,副本也是可以同步数据的。
查了下发现是因为interserver_http_host参数或server主机名的设置不正确。这四台机器中既没有配interserver_http_host参数,也没有配主机名。
interserver_http_host参数表示其他服务器可以用来访问该服务器的主机名。如果省略,则其定义方法与hostname -f命令相同,但是不能是localhost。
解决方法:
方法1:在config.xml中,配置interserver_http_host参数,我是直接配置了本机的IP
方法2:在/etc/hostname中配置主机名,之前的服务器中配置过主机名,但是没有配interserver_http_host参数,所以可以正常使用