Clickhouse副本表以及分布式表简单实践

集群配置:

192.168.0.106 node3
192.168.0.101 node2
192.168.0.103 node1

  

zookeeper配置忽略,自行实践!

node1配置:



    
        
        trace
        /var/log/clickhouse-server/clickhouse-server.log
        /var/log/clickhouse-server/clickhouse-server.err.log
        1000M
        10
         
    
     
    8123
    9000

    
    

    
    
         
            
            /etc/clickhouse-server/server.crt
            /etc/clickhouse-server/server.key
            
            /etc/clickhouse-server/dhparam.pem
            none
            true
            true
            sslv2,sslv3
            true
        

         
            true
            true
            sslv2,sslv3
            true
            
            
                
                RejectCertificateHandler
            
        
    

    
    

    
    9009

    
    

    
    
    
    

    
    
	  0.0.0.0
    
    

    
    

    

    4096
    3

    
    100

    
    

    
    8589934592

    
    5368709120


    
    /var/lib/clickhouse/

    
    /var/lib/clickhouse/tmp/

    
    /var/lib/clickhouse/user_files/

    
    users.xml

    
    default

    
    

    
    default

    
    

    
    

    
    
    
	
            
                node1
                9000
            
        
			
            
                node2
                9000
            
        
			
            
                node3
                9000
            
        
	
    


    

       
	
	
	  
		node1
		2181
	  
	
    
   
    01
    node1
   

    
    3600


    
    3600

    
    60

    
    
    


    
    
        
        system
        query_log
toYYYYMM(event_date) 7500
*_dictionary.xml /clickhouse/task_queue/ddl click_cost any 0 3600 86400 60 max 0 60 3600 300 86400 3600 /var/lib/clickhouse/format_schemas/

  

node2:



    
        
        trace
        /var/log/clickhouse-server/clickhouse-server.log
        /var/log/clickhouse-server/clickhouse-server.err.log
        1000M
        10
         
    
     
    8123
    9000

    
    

    
    
         
            
            /etc/clickhouse-server/server.crt
            /etc/clickhouse-server/server.key
            
            /etc/clickhouse-server/dhparam.pem
            none
            true
            true
            sslv2,sslv3
            true
        

         
            true
            true
            sslv2,sslv3
            true
            
            
                
                RejectCertificateHandler
            
        
    

    
    

    
    9009

    
    

    
    
    
    

    
    
	  0.0.0.0
    
    

    
    

    

    4096
    3

    
    100

    
    

    
    8589934592

    
    5368709120


    
    /var/lib/clickhouse/

    
    /var/lib/clickhouse/tmp/

    
    /var/lib/clickhouse/user_files/

    
    users.xml

    
    default

    
    

    
    default

    
    

    
    

    
    
    
	            
	
            
                node1
                9000
            
        
			
            
                node2
                9000
            
        
			
            
                node3
                9000
            
        
	
    


    

       
	
	
	  
		node1
		2181
	  
	
    
   
    02
    node2
   

    
    3600


    
    3600

    
    60

    
    
    


    
    
        
        system
        query_log
toYYYYMM(event_date) 7500
*_dictionary.xml /clickhouse/task_queue/ddl click_cost any 0 3600 86400 60 max 0 60 3600 300 86400 3600 /var/lib/clickhouse/format_schemas/

  

node3:



    
        
        trace
        /var/log/clickhouse-server/clickhouse-server.log
        /var/log/clickhouse-server/clickhouse-server.err.log
        1000M
        10
         
    
     
    8123
    9000

    
    

    
    
         
            
            /etc/clickhouse-server/server.crt
            /etc/clickhouse-server/server.key
            
            /etc/clickhouse-server/dhparam.pem
            none
            true
            true
            sslv2,sslv3
            true
        

         
            true
            true
            sslv2,sslv3
            true
            
            
                
                RejectCertificateHandler
            
        
    

    
    

    
    9009

    
    

    
    
    
    

    
    
	  0.0.0.0
    
    

    
    

    

    4096
    3

    
    100

    
    

    
    8589934592

    
    5368709120


    
    /var/lib/clickhouse/

    
    /var/lib/clickhouse/tmp/

    
    /var/lib/clickhouse/user_files/

    
    users.xml

    
    default

    
    

    
    default

    
    

    
    

    
    
    
	            
	
            
                node1
                9000
            
        
			
            
                node2
                9000
            
        
			
            
                node3
                9000
            
        
	
    


    

       
	
	
	  
		node1
		2181
	  
	
    
   
    03
    node3
   

    
    3600


    
    3600

    
    60

    
    
    


    
    
        
        system
        query_log
toYYYYMM(event_date) 7500
*_dictionary.xml /clickhouse/task_queue/ddl click_cost any 0 3600 86400 60 max 0 60 3600 300 86400 3600 /var/lib/clickhouse/format_schemas/

  

 

 

建表语句,三个节点都执行一遍:

CREATE TABLE emp
(
    EventDate DateTime,
    CounterID UInt32,
    UserID UInt32
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/emp', '{replica}')
PARTITION BY toYYYYMM(EventDate)
ORDER BY (CounterID, EventDate, intHash32(UserID))
SAMPLE BY intHash32(UserID)

CREATE TABLE emp_all (
    EventDate DateTime,
    CounterID UInt32,
    UserID UInt32
) ENGINE = Distributed('ck-daxin', 'default', 'emp', UserID) ;

  

节点1执行:

insert into emp_all values ('2018-01-01 01:01:01',1,1);

节点2执行:

insert into emp_all values ('2018-02-02 02:02:02',2,2);

 节点3执行:

insert into emp_all values ('2018-03-03 03:03:03',3,3);

最终任意节点查询,本文节点3查询分布式表:

Clickhouse副本表以及分布式表简单实践_第1张图片

 

 

查询单个节点的本地表,只有本地部分数据!!!

 

 

 

Clickhouse副本表以及分布式表简单实践_第2张图片

 

转载于:https://www.cnblogs.com/leodaxin/p/10023641.html

你可能感兴趣的:(Clickhouse副本表以及分布式表简单实践)