clickhouse主从部署(1分片2副本)


环境:
192.168.1.118
192.168.1.134

OS:Centos 7

DB:21.9.7

1.安装zookeeper
可以安装集群也可以安装单节点

集群的安装步骤请参考:https://www.cnblogs.com/hxlasky/p/14665752.html

我这里安装的是单节点的zookeeper

2.每个节点上都安装好clickhouse
安装步骤请参考
https://www.cnblogs.com/hxlasky/p/15325313.html

3.创建 /etc/metrika.xml 文件

192.168.1.118节点

<?xml version="1.0"?>

  
    
      
        true
        
          192.168.1.118
          9000
        
        
          192.168.1.134
          9000
        
      
    
  
  
  
    "1">
      192.168.1.118
      2181
    
  
  
    01
    192.168.1.118
  
  
    ::/0
  
  
    <case>
      10000000000
      0.01
      lz4
    case>
  

192.168.1.134节点

<?xml version="1.0"?>

  
    
      
        true
        
          192.168.1.118
          9000
        
        
          192.168.1.134
          9000
        
      
    
  
  
  
    "1">
      192.168.1.118
      2181
    
  
  
    01
    192.168.1.134
  
  
    ::/0
  
  
    <case>
      10000000000
      0.01
      lz4
    case>
  

4.修改配置文件,引入metrika.xml

修改 /etc/clickhouse-server/config.xml 文件


    
    /etc/metrika.xml
    
    
    incl="zookeeper-servers" optional="true">
    
    
    incl="clickhouse_remote_servers">