ClickHouse集群部署(二)

EMQX 客服发表于:2022年03月07日 14:14:31

  1. metrika.xml
        <?xml version="1.0"?>
        <yandex>    
            <!--ck集群节点-->    
            <clickhouse_remote_servers>        
                <emqx_cluster_all>            
                    <!--分片1-->            
                    <shard>                
                        <internal_replication>true</internal_replication>                
                        <replica>                    
                            <host>192.168.0.27</host>                    
                            <port>9000</port>                    
                            <user>default</user>                    
                            <password>supersecrect</password>                
                        </replica>                
                        <!--复制集1-->                
                        <replica>                    
                            <host>192.168.0.74</host>                    
                            <port>9002</port>                    
                            <user>default</user>                    
                            <password>supersecrect</password>                
                        </replica>            
                    </shard>            
                    <!--分片2-->            
                    <shard>                
                        <internal_replication>true</internal_replication>                
                        <replica>                    
                            <host>192.168.0.221</host>                    
                            <port>9000</port>                    
                            <user>default</user>                    
                            <password>supersecrect</password>                
                        </replica>                
                        <!--复制集2-->                
                        <replica>                    
                            <host>192.168.0.27</host>                    
                            <port>9002</port>                    
                            <user>default</user>                    
                            <password>supersecrect</password>                
                        </replica>            
                    </shard>            
                    <!--分片3-->            
                    <shard>                
                        <internal_replication>true</internal_replication>                
                        <replica>                    
                            <host>192.168.0.74</host>                    
                            <port>9000</port>                    
                            <user>default</user>                    
                            <password>supersecrect</password>                
                        </replica>                
                        <!--复制集3-->                
                        <replica>                    
                            <host>192.168.0.221</host>                    
                            <port>9002</port>                    
                            <user>default</user>                    
                            <password>supersecrect</password>                
                        </replica>            
                    </shard>        
                </emqx_cluster_all>    
            </clickhouse_remote_servers>    
            <!--zookeeper相关配置-->    
            <zookeeper-servers>        
                <node index="1">            
                    <host>192.168.0.27</host>            
                    <port>2181</port>        
                </node>        
                <node index="2">            
                    <host>192.168.0.221</host>            
                    <port>2181</port>        
                </node>        
                <node index="3">            
                    <host>192.168.0.74</host>            
                    <port>2181</port>        
                </node>    
            </zookeeper-servers>    
            <macros>        
                <layer>01</layer>        
                <shard>02</shard>        
                <!--分片号-->        
                <replica>node2</replica>        
                <!--当前节点IP-->    
            </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>            
                    <!--压缩算法lz4压缩比zstd快, 更占磁盘-->        
                </case>    
            </clickhouse_compression>
        </yandex>

    image.png

    image.png

    users.xml

    每个node中users.xml是相同配置,拷贝node1中的users.xml

    node3配置文件:

    config.xml
        <?xml version="1.0"?>
        <yandex>    
            <!--日志-->    
            <logger>        
                <level>warning</level>        
                <log>/data/clickhouse/node3/logs/clickhouse.log</log>        
                <errorlog>/data/clickhouse/node3/logs/error.log</errorlog>        
                <size>500M</size>        
                <count>5</count>    
            </logger>    
            <!--本地节点信息-->    
            <http_port>8123</http_port>    
            <tcp_port>9000</tcp_port>    
            <interserver_http_port>9009</interserver_http_port>    
            <interserver_http_host>192.168.0.74</interserver_http_host>    
            <!--本机域名或IP-->    
            <!--本地配置-->    
            <listen_host>0.0.0.0</listen_host>    
            <max_connections>2048</max_connections>    
            <keep_alive_timeout>3</keep_alive_timeout>    
            <max_concurrent_queries>64</max_concurrent_queries>    
            <uncompressed_cache_size>4294967296</uncompressed_cache_size>    
            <mark_cache_size>5368709120</mark_cache_size>    
            <path>/data/clickhouse/node3/</path>    
            <tmp_path>/data/clickhouse/node3/tmp/</tmp_path>    
            <users_config>/data/clickhouse/node3/users.xml</users_config>    
            <default_profile>default</default_profile>    
            <query_log>        
                <database>system</database>        
                <table>query_log</table>        
                <partition_by>toMonday(event_date)</partition_by>        
                <flush_interval_milliseconds>7500</flush_interval_milliseconds>    
            </query_log>    
            <query_thread_log>        
                <database>system</database>        
                <table>query_thread_log</table>        
                <partition_by>toMonday(event_date)</partition_by>        
                <flush_interval_milliseconds>7500</flush_interval_milliseconds>    
            </query_thread_log>    
            <prometheus>        
                <endpoint>/metrics</endpoint>        
                <port>8001</port>        
                <metrics>true</metrics>        
                <events>true</events>        
                <asynchronous_metrics>true</asynchronous_metrics>    
            </prometheus>    
            <default_database>default</default_database>    
            <timezone>Asia/Shanghai</timezone>    
            <!--集群相关配置-->    
            <remote_servers incl="clickhouse_remote_servers" />    
            <zookeeper incl="zookeeper-servers" optional="true" />    
            <macros incl="macros" optional="true" />    
            <builtin_dictionaries_reload_interval>3600</builtin_dictionaries_reload_interval>    
                <max_session_timeout>3600</max_session_timeout>    
                <default_session_timeout>300</default_session_timeout>    
                <max_table_size_to_drop>0</max_table_size_to_drop>    
                <merge_tree>        
                    <parts_to_delay_insert>300</parts_to_delay_insert>        
                    <parts_to_throw_insert>600</parts_to_throw_insert>        
                    <max_delay_to_insert>2</max_delay_to_insert>    
                </merge_tree>    
                <max_table_size_to_drop>0</max_table_size_to_drop>    
                <max_partition_size_to_drop>0</max_partition_size_to_drop>    
                <distributed_ddl>        
                    <!-- Path in ZooKeeper to queue with DDL queries -->        
                    <path>/clickhouse/task_queue/ddl</path>    
                </distributed_ddl>    
                <include_from>/data/clickhouse/node3/metrika.xml</include_from>
        </yandex>

    image.png

    image.png

    metrika.xml
        <?xml version="1.0"?>
        <yandex>    
            <!--ck集群节点-->    
            <clickhouse_remote_servers>        
                <emqx_cluster_all>            
                    <!--分片1-->            
                    <shard>                
                        <internal_replication>true</internal_replication>                
                        <replica>                    
                            <host>192.168.0.27</host>                    
                            <port>9000</port>                    
                            <user>default</user>                    
                            <password>supersecrect</password>                
                        </replica>                
                        <!--复制集1-->                
                        <replica>                    
                            <host>192.168.0.74</host>                    
                            <port>9002</port>                    
                            <user>default</user>                    
                            <password>supersecrect</password>                
                        </replica>            
                    </shard>            
                    <!--分片2-->            
                    <shard>                
                        <internal_replication>true</internal_replication>                
                        <replica>                    
                            <host>192.168.0.221</host>                    
                            <port>9000</port>                    
                            <user>default</user>                    
                            <password>supersecrect</password>                
                        </replica>                
                        <!--复制集2-->                
                        <replica>                    
                            <host>192.168.0.27</host>                    
                            <port>9002</port>                    
                            <user>default</user>                    
                            <password>supersecrect</password>                
                        </replica>            
                        </shard>            
                        <!--分片3-->            
                        <shard>                
                            <internal_replication>true</internal_replication>                
                            <replica>                    
                                <host>192.168.0.74</host>                    
                                <port>9000</port>                    
                                <user>default</user>                    
                                <password>supersecrect</password>                
                            </replica>                
                            <!--复制集3-->                
                            <replica>                    
                                <host>192.168.0.221</host>                    
                                <port>9002</port>                    
                                <user>default</user>                    
                                <password>supersecrect</password>                
                            </replica>            
                        </shard>        
                    </emqx_cluster_all>    
                </clickhouse_remote_servers>    
                <!--zookeeper相关配置-->    
                <zookeeper-servers>        
                    <node index="1">            
                        <host>192.168.0.27</host>            
                        <port>2181</port>        
                    </node>        
                    <node index="2">            
                        <host>192.168.0.221</host>            
                        <port>2181</port>        
                    </node>        
                    <node index="3">            
                        <host>192.168.0.74</host>            
                        <port>2181</port>        
                    </node>    
                </zookeeper-servers>    
                <macros>        
                    <layer>01</layer>        
                    <shard>03</shard>        
                    <!--分片号-->        
                    <replica>node3</replica>        
                    <!--当前节点IP-->    
                </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>            
                        <!--压缩算法lz4压缩比zstd快, 更占磁盘-->        
                    </case>    
                </clickhouse_compression>
            </yandex>

    image.png

    image.png

    users.xml

    每个node中users.xml是相同配置,拷贝node1中的users.xml

    node4配置文件

    config.xml
        <?xml version="1.0"?>
        <yandex>    
            <!--日志-->    
            <logger>        
                <level>warning</level>        
                <log>/data/clickhouse/node4/logs/clickhouse.log</log>        
                <errorlog>/data/clickhouse/node4/logs/error.log</errorlog>        
                <size>500M</size>        
                <count>5</count>    
            </logger>    
            <!--本地节点信息-->    
            <http_port>8124</http_port>    
            <tcp_port>9002</tcp_port>    
            <interserver_http_port>9010</interserver_http_port>    
            <interserver_http_host>192.168.0.27</interserver_http_host>    
            <!--本机域名或IP-->    
            <!--本地配置-->    
            <listen_host>0.0.0.0</listen_host>    
            <max_connections>2048</max_connections>    
            <keep_alive_timeout>3</keep_alive_timeout>    
            <max_concurrent_queries>64</max_concurrent_queries>    
            <uncompressed_cache_size>4294967296</uncompressed_cache_size>    
            <mark_cache_size>5368709120</mark_cache_size>    
            <path>/data/clickhouse/node4/</path>    
            <tmp_path>/data/clickhouse/node4/tmp/</tmp_path>    
            <users_config>/data/clickhouse/node4/users.xml</users_config>    
            <default_profile>default</default_profile>    
            <query_log>        
                <database>system</database>        
                <table>query_log</table>        
                <partition_by>toMonday(event_date)</partition_by>        
                <flush_interval_milliseconds>7500</flush_interval_milliseconds>    
            </query_log>    
            <query_thread_log>        
                <database>system</database>        
                <table>query_thread_log</table>        
                <partition_by>toMonday(event_date)</partition_by>        
                <flush_interval_milliseconds>7500</flush_interval_milliseconds>    
            </query_thread_log>    
            <prometheus>        
                <endpoint>/metrics</endpoint>        
                <port>8002</port>        
                <metrics>true</metrics>        
                <events>true</events>        
                <asynchronous_metrics>true</asynchronous_metrics>    
            </prometheus>    
            <default_database>default</default_database>    
            <timezone>Asia/Shanghai</timezone>    
            <!--集群相关配置-->    
            <remote_servers incl="clickhouse_remote_servers" />    
            <zookeeper incl="zookeeper-servers" optional="true" />    
            <macros incl="macros" optional="true" />    
            <builtin_dictionaries_reload_interval>3600</builtin_dictionaries_reload_interval>    
            <max_session_timeout>3600</max_session_timeout>    
            <default_session_timeout>300</default_session_timeout>    
            <max_table_size_to_drop>0</max_table_size_to_drop>    
            <merge_tree>        
                <parts_to_delay_insert>300</parts_to_delay_insert>        
                <parts_to_throw_insert>600</parts_to_throw_insert>        
                <max_delay_to_insert>2</max_delay_to_insert>    
            </merge_tree>    
            <max_table_size_to_drop>0</max_table_size_to_drop>    
            <max_partition_size_to_drop>0</max_partition_size_to_drop>    
            <distributed_ddl>        
                <!-- Path in ZooKeeper to queue with DDL queries -->        
                <path>/clickhouse/task_queue/ddl</path>    
            </distributed_ddl>    
            <include_from>/data/clickhouse/node4/metrika.xml</include_from>
        </yandex>

    image.png

    image.png

    metrika.xml
        <?xml version="1.0"?>
        <yandex>    
            <!--ck集群节点-->    
            <clickhouse_remote_servers>        
            <emqx_cluster_all>            
            <!--分片1-->            
            <shard>                
                <internal_replication>true</internal_replication>                
                <replica>                    
                    <host>192.168.0.27</host>                    
                    <port>9000</port>                    
                    <user>default</user>                    
                    <password>supersecrect</password>                
                </replica>                
                <!--复制集1-->                
                <replica>                    
                    <host>192.168.0.74</host>                    
                    <port>9002</port>                    
                    <user>default</user>                    
                    <password>supersecrect</password>                
                </replica>            
            </shard>            
            <!--分片2-->            
            <shard>                
                <internal_replication>true</internal_replication>                
                <replica>                    
                    <host>192.168.0.221</host>                    
                    <port>9000</port>                    
                    <user>default</user>       &nbs

    您需要登录后才可以回复