ClickHouse学习笔记

这篇博客详细介绍了ClickHouse的使用,包括登录、密码设置、查询和建表操作,还探讨了chproxy配置和用户权限设置。文章强调了查询优化,如使用prewhere和避免大表JOIN,同时讲解了MaterializeMySQL的全量和增量同步功能,以及如何结合Kafka进行数据集成。
摘要由CSDN通过智能技术生成

安装部署

Centos、RedHat
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/stable/x86_64
sudo yum install clickhouse-server clickhouse-client

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

vi /etc/security/limits.d/clickhouse.conf
clickhouse      soft    nofile  262144
clickhouse      hard    nofile  262144

vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072


vi /etc/selinux/config
SELINUX=disabled


关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
创建目录
mkdir -p /data/clickhouse/config
chown -R clickhouse:clickhouse /data/clickhouse
mkdir -p /data/clickhouse/log/clickhouse-server
mkdir /data/clickhouse/tmp/
mkdir /data/clickhouse/format_schemas
mkdir -p /data/clickhouse/task_queue/ddl

cp  /etc/clickhouse-server/config.xml /data/clickhouse/config/config.xml
cp  /etc/clickhouse-server/users.xml /data/clickhouse/config/users.xml

chmod 755 config.xml
chmod 755 users.xml

ln -s /data/clickhouse/config/config.xml /etc/clickhouse-server/config.xml
config.xml

<log>/data/clickhouse/log/clickhouse-server/clickhouse-server.log</log>
<errorlog>/data/clickhouse/log/clickhouse-server/clickhouse-server.err.log</errorlog>

<!-- Path to data directory, with trailing slash. -->
<path>/data/clickhouse/data/</path>

<tmp_path>/data/clickhouse/tmp/</tmp_path>
<format_schema_path>/data/clickhouse/format_schemas/</format_schema_path>


    <remote_servers incl="clickhouse_remote_servers" >
       <perftest_2shards_1replicas>
       <!-- 数据分片1 -->
         <shard>
           <internal_replication>true</internal_replication>
           <replica>
              <host>clickhouse1</host>
              <port>9000</port>
          </replica>
           <replica>
              <host>clickhouse2</host>
              <port>9000</port>
          </replica>
         </shard>
       <!-- 数据分片2 -->
         <shard>
           <internal_replication>true</internal_replication>
           <replica>
              <host>clickhouse3</host>
              <port>9000</port>
          </replica>
           <replica>
              <host>clickhouse4</host>
              <port>9000</port>
          </replica>
         </shard>
       </perftest_2shards_1replicas>
   </remote_servers>


    <zookeeper>
        <node>
            <host>clickhouse2</host>
            <port>2181</port>
        </node>
        <node>
            <host>clickhouse3</host>
            <port>2181</port>
        </node>
        <node>
            <host>clickhouse4</host>
            <port>2181</port>
        </node>
    </zookeeper>


    <macros>
        <shard>shard1</shard>
        <replica>replica1</replica>
    </macros>

    <distributed_ddl>
        <!-- Path in ZooKeeper to queue with DDL queries -->
        <path>/data/clickhouse/task_queue/ddl</path>

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值