欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

clickhouse集群安装部署

程序员文章站 2022-07-13 10:19:13
...

一、 安装
每台机器上按照单节点模式安装,按照官网步骤安装:

sudo yum install yum-utils
sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG
sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/clickhouse.repo
sudo yum install clickhouse-server clickhouse-client

sudo /etc/init.d/clickhouse-server start
clickhouse-client

二、 配置
在每台机器上添加配置文件/etc/metrika.xml

<yandex>
    <!-- /etc/clickhouse-server/config.xml 中配置的remote_servers的incl属性值,-->
    <clickhouse_remote_servers>
    <!-- 3分片2备份 -->
        <perftest_3shards_2replicas>
        <!-- 数据分片1  -->
            <shard>
                <internal_replication>true</internal_replication>
                <replica>
                    <host>master</host>
                    <port>9000</port>
                </replica>
            </shard>
            <!-- 数据分片2  -->
            <shard>
                <replica>
                    <internal_replication>true</internal_replication>
                    <host>salve1</host>
                    <port>9000</port>
                </replica>
            </shard>
            <!-- 数据分片3  -->
            <shard>
                <internal_replication>true</internal_replication>
                <replica>
                    <host>salve2</host>
                    <port>9000</port>
                </replica>
            </shard>
             <!-- 数据分片4  -->
            <shard>
                <replica>
                    <host>master</host>
                    <port>9000</port>
                </replica>
            </shard>
             <!-- 数据分片5  -->
            <shard>
                <replica>
                    <host>salve1</host>
                    <port>9000</port>
                </replica>
            </shard>
        </perftest_3shards_2replicas>
    </clickhouse_remote_servers>
    <!--zookeeper相关配置-->
    <zookeeper-servers>
        <node index="1">
            <host>master</host>
            <port>2181</port>
        </node>
        <node index="2">
            <host>salve1</host>
            <port>2181</port>
        </node>
        <node index="3">
            <host>salve2</host>
            <port>2181</port>
        </node>
    </zookeeper-servers>
    
    <macros>
        <replica>master</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>

三、 每台机器上启动clickhouse-server

 sudo /etc/init.d/clickhouse-server start
 sudo /etc/init.d/clickhouse-server status

四、 任意一台机器上启动clickhouse-client,查看集群
clickhouse集群安装部署

五、导入外部json数据(待续)
cat stu.json | clickhouse-client --query=“INSERT INTO jsontest.stu_new FORMAT JSONEachRow”