Ankit Shah
Ankit Shah

Reputation: 13

clickhouse replica/server is not able to connect to each other when setting up a clickhouse 3 node circular cluster using zookeeper

Data is not getting replicated to each clickhouse replica. While checking clickhouse-server log it is showing

DB::StorageReplicatedMergeTree::queueTask()::: Poco::Exception. Code: 1000, e.code() = 0, e.displayText() = Host not found: ip-172-1-140-243 (version 19.9.2.4)

I have 3 different machines on each machine I've installed both clickhouse and zookeeper. I'm trying to setup 3 node clickhouse cluster using zookeeper. I have followed these steps for configuration https://blog.uiza.io/replicated-and-distributed-on-clickhouse-part-2/ . I have created tables and replicas on all clickhouse instances and verified in zookeeper as well. Directory got created in zookeeper for all replicas. Have created /etc/metrica.xml , zoo.cfg , /etc/clickhouse-server/config.xml on all instances. Providing all 3 files from 1 instance

/etc/metrica.xml file

<?xml version="1.0"?>
<yandex>
<clickhouse_remote_servers>
    <perftest_3shards_1replicas>
        <shard>
             <internal_replication>true</internal_replication>
            <replica>
                <default_database>dwh01</default_database>
                <host>172.1.34.199</host>
                <port>9000</port>
            </replica>
            <replica>
                <default_database>dwh01</default_database>
                <host>172.1.73.156</host>
                <port>9000</port>
            </replica>
        </shard>

         <shard>
             <internal_replication>true</internal_replication>
            <replica>
                <default_database>dwh02</default_database>
                <host>172.1.73.156</host>
                <port>9000</port>
            </replica>
            <replica>
                <default_database>dwh02</default_database>
                <host>172.1.140.243</host>
                <port>9000</port>
            </replica>
        </shard>

        <shard>
             <internal_replication>true</internal_replication>
            <replica>
                <default_database>dwh03</default_database>
                <host>172.1.140.243</host>
                <port>9000</port>
            </replica>
            <replica>
                <default_database>dwh03</default_database>
                <host>172.1.34.199</host>
                <port>9000</port>
            </replica>
        </shard>
    </perftest_3shards_1replicas>
</clickhouse_remote_servers>


<zookeeper-servers>
  <node index="1">
    <host>172.1.34.199</host>
    <port>2181</port>
  </node>
 <node index="2">
    <host>172.1.73.156</host>
    <port>2181</port>
  </node>
 <node index="3">
    <host>172.1.140.243</host>
    <port>2181</port>
  </node> 
</zookeeper-servers>

<macros replace="replace">
  <cluster>OLAPLab</cluster>
  <dwhshard00>01</dwhshard00>
  <dwhshard01>03</dwhshard01>
  <dwhreplica00>01</dwhreplica00>
  <dwhreplica01>02</dwhreplica01>
  <shard>01</shard>
  <replica>node1</replica>
</macros>
<interserver_http_host>ip-172-1-34-199</interserver_http_host>
</yandex>

/etc/clickhouse-server/config.xml

Only added this line rest of the config is default config
<listen_host>::</listen_host>

/usr/lib/zookeeper/conf/zoo.cfg

maxClientCnxns=50
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/var/lib/zookeeper
# the port at which the clients will connect
clientPort=2181
# the directory where the transaction logs are stored.
dataLogDir=/var/lib/zookeeper
server.1=172.1.34.199:2888:3888
server.2=172.1.73.156:2888:3888
server.3=172.1.140.243:2888:3888

/etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost6 localhost6.localdomain6
127.0.0.1    ip-172-1-34-199
127.0.0.1    172.1.34.199

What should I change to get replicated data in all replicas belongs to all instances

Upvotes: 0

Views: 3575

Answers (2)

vladimir
vladimir

Reputation: 15226

It looks like you need to add to hosts-file of both nodes (172.1.34.199 and 172.1.73.156) the string

172.1.140.243 ip-172-1-140-243

Upvotes: 1

George
George

Reputation: 4011

Are the clickhouse and zookeeper ports accessible among the machines ?

As in, can you run wget http://172.1.140.243:9000 ? Same applies to the zookeper ports respectively.

Upvotes: 0

Related Questions