当前位置:网站首页>clickhouse 21. X cluster four piece one copy deployment

clickhouse 21. X cluster four piece one copy deployment

2022-06-22 17:18:00 51CTO

label ( Test case space separation for air test ):clickhouse series


One : Introduction to system environment deployment

1.1: System initialization

 System :
   centos7.9x64
 
  Host name :
   cat /etc/hosts 
   
   -----
   
172.16.10.11    flyfishsrvs01
172.16.10.12    flyfishsrvs02
172.16.10.13    flyfishsrvs03
172.16.10.14    flyfishsrvs04
172.16.10.15    flyfishsrvs05
172.16.10.16    flyfishsrvs06
172.16.10.17    flyfishsrvs07 

   ------
   The first four servers are deployed this time  

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.

1.2 System deployment jdk

 stay flyfishsrvs02,flyfishsrvs03,flyfishsrvs04  Deployment above 

tar -zxvf jdk-8u301-linux-x64.tar.gz
mv jdk1.8.0_301/ /usr/local/jdk
vim /etc/profile 
----

### jdk
export JAVA_HOME=/usr/local/jdk
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
----

source /etc/profile

java -version 

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.

clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse

clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse_02

clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x Cluster deployment _03

1.3 To configure zookeeper colony

 stay flyfishsrvs02,flyfishsrvs03,flyfishsrvs04  Deployment above 
tar -zxvf apache-zookeeper-3.7.0-bin.tar.gz
mv apache-zookeeper-3.7.0-bin /usr/local/zookeeper

mkdir -p /usr/local/zookeeper/data
mkdir -p /usr/local/zookeeper/log

cd /usr/local/zookeeper/data/

echo 1 > myid
----
cd /usr/local/zookeeper/conf 

cp zoo_sample.cfg zoo.cfg 

vim zoo.cfg 

----
#  Heartbeat time 
tickTime=2000
# follow Connect leader The initial connection time of , Express tickTime Multiple 
initLimit=10
# syncLimit Configuration representation leader And follower Sending messages between , Length of request and reply time . If followe Cannot communicate with... Within the set time leader communicate , Then this follower Will be discarded ,tickTime Multiple 
syncLimit=5
#  Client connection port 
clientPort=2181
#  Node data storage directory , It needs to be created in advance , Be careful myid add to , Used to identify the server node 
dataDir=/usr/local/zookeeper/data
dataLogDir=/usr/local/zookeeper/log
server.1=172.16.10.12:2888:3888
server.2=172.16.10.13:2888:3888
server.3=172.16.10.14:2888:3888
---
-----

scp -r zookeeper [email protected]:/usr/local/
scp -r zookeeper [email protected]:/usr/local/
 modify 172.16.10.13  node  myid 
cd /usr/local/zookeeper/data/
echo 2 > myid 
 modify 172.16.10.14  node  myid
cd /usr/local/zookeeper/data/
echo 3 > myid



     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.

clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x_04
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse_05

 start-up zookeeper 

cd /usr/local/zookeeper/bin/

./zkServer.sh start

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x Cluster deployment _06
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x_07
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x_08

Two : Deploy clickhouse 21.x

2.1 install clickhouse 21.x

rpm -ivh clickhouse-* [ All nodes are installed and processed ]

     
  • 1.

clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x Cluster deployment _09

 modify listen_host

vim +164 /etc/clickhouse-server/config.xml

----
<listen_host>::1</listen_host>
<listen_host>flyfishsrvs01</listen_host>  ###  Other nodes modify the host name 
-----

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.

clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse_10
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x_11
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse_12
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x Cluster deployment _13

2.2 Configure the cluster file

 Configure the cluster connection file 
cd /etc/clickhouse-server/config.d
vim metrika.xml 
-----
<yandex> 
    <remote_servers> 
        <clickhouse_cluster_4shards_1replicas> 
           <shard> 
               <internal_replication>true</internal_replication>
                  <replica> 
                     <host>flyfishsrvs01</host> 
                     <port>9000</port> 
                  </replica> 
           </shard> 
           <shard> 
               <internal_replication>true</internal_replication> 
                  <replica> 
                     <host>flyfishsrvs02</host> 
                     <port>9000</port> 
                  </replica> 
           </shard> 
           <shard> 
               <internal_replication>true</internal_replication> 
                  <replica> 
                     <host>flyfishsrvs03</host> 
                     <port>9000</port> 
                  </replica> 
           </shard>
           <shard> 
               <internal_replication>true</internal_replication> 
                  <replica> 
                     <host>flyfishsrvs04</host> 
                     <port>9000</port> 
                  </replica> 
           </shard>
           </clickhouse_cluster_4shards_1replicas>
    </remote_servers> 
    <zookeeper>
       <node index="1"> 
           <host>flyfishsrvs02</host> 
           <port>2181</port> 
        </node> 
       <node index="2"> 
          <host>flyfishsrvs03</host> 
          <port>2181</port> 
       </node> 
       <node index="3"> 
          <host>flyfishsrvs04</host> 
          <port>2181</port> 
       </node> 
     </zookeeper>

     <macros> 
        <shard>01</shard> 
        <replica>flyfishsrvs01</replica> 
     </macros> 
     <networks> 
         <ip>::/0</ip> 
     </networks> 
     <clickhouse_compression> 
         <case> 
            <min_part_size>10000000000</min_part_size> 
            <min_part_size_ratio>0.01</min_part_size_ratio> 
            <method>lz4</method> 
         </case> 
     </clickhouse_compression> 
</yandex>

---------------
scp metrika.xml [email protected]:/etc/clickhouse-server/config.d/
scp metrika.xml [email protected]:/etc/clickhouse-server/config.d/
scp metrika.xml [email protected]:/etc/clickhouse-server/config.d/

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.

clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse_14

clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x Cluster deployment _15
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x Cluster deployment _16

2.3 Cluster startup and verification

 Modify the replica hostname of the corresponding node 
vim 
#flyfishsrvs02 Node modification metrika.xml The macro variables in are as follows : 
<macros> 
<shard>02</replica>
<replica>flyfishsrvs02</replica> 
</macros> 
#flyfishsrvs03 Node modification metrika.xml The macro variables in are as follows : 
<macros> 
<shard>03</replica>
<replica>flyfishsrvs03</replica> 
</macros>

#flyfishsrvs04 Node modification metrika.xml The macro variables in are as follows : 
<macros> 
<shard>04</replica>
<replica>flyfishsrvs04</replica> 
</macros>
 


     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.

clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse_17
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x Cluster deployment _18
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x_19

# Start of each node Clickchouse service  
service clickhouse-server start
# View each node clickhouse Service status  
service clickhouse-server status 
# Restart each node clickhouse service  
service clickhouse-server restart 
# Each node is shut down Clikchouse service  
service clickhouse-server stop

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.

clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse_20
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x Cluster deployment _21
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x Cluster deployment _22
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x Cluster deployment _23

 verification :
clickhouse-client -h flyfishsrvs01
 View cluster :
select * from system.clusters;
select cluster,host_name from system.clusters;


     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x_24
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x Cluster deployment _25
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x Cluster deployment _26

 Other nodes verify :
select * from system.clusters;
select cluster,host_name from system.clusters;

     
  • 1.
  • 2.
  • 3.

clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x_27
clickhouse 21.x The cluster is deployed in four pieces and one copy _clickhouse21.x_28

原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206221532330141.html