当前位置:首页 > 数据库 > 正文内容

clickhouse 搭建

root2年前 (2021-12-13)数据库674

通过docker 部署clickhouse

docker-compose文件内容如下:

services:
    ipwave-clickhouse:
        image: yandex/clickhouse-server:20.8.3.18
        container_name: clickhouse-test
        # environment:
        #    - CLICKHOUSE_USER=default
        #    - CLICKHOUSE_PASSWORD=JyqUaEps
        #    - CLICKHOUSE_DB=default
        volumes:
            - "./clickhouse_config/clickhouse-server-config.xml:/etc/clickhouse-server/config.xml"
            #- "./clickhouse_config/rollup.xml:/etc/clickhouse-server/config.d/rollup.xml"
            - "./clickhouse_config/clickhouse-users-with-passwd.xml:/etc/clickhouse-server/users.xml"
            - "./data/clickhouse/data:/var/lib/clickhouse/data"
            - "./metadata:/var/lib/clickhouse/metadata"
        network_mode: "host"


其中配置文件
clickhouse-server-config.xml

添加zookeeper的配置 (zookeeper的搭建参考zookeeper安装

    <zookeeper>
        <node>
            <host>192.168.8.16</host>
            <port>2181</port>
        </node>
    </zookeeper>


如果是分布式,需添加主机节点。如下

 <remote_servers incl="clickhouse_remote_servers" >
        <!-- Test only shard config for testing distributed storage -->
        <test_cluster>
            <shard>
                <replica>
                    <host>zkdemo0</host>
                    <port>9000</port>
                </replica>
            </shard>
            <shard>
                <replica>
                    <host>zkdemo1</host>
                    <port>9000</port>
                </replica>
            </shard>
            <shard>
                <replica>
                    <host>zkdemo2</host>
                    <port>9000</port>
                </replica>
            </shard>
        </test_cluster>
    </remote_servers>

配置文件的其他内容是默认的,可以采用默认内容


clickhouse-users-with-passwd.xml

配置文件设置用户密码

l version="1.0"?>
<yandex>
    <profiles>
        <default>
            <max_memory_usage>10000000000</max_memory_usage>
            <use_uncompressed_cache>0</use_uncompressed_cache>
            <load_balancing>random</load_balancing>
        </default>
        <readonly>
            <readonly>1</readonly>
        </readonly>
    </profiles>
    <users>
        <default>
            <password>qwerty</password>
            <networks incl="networks" replace="replace">
                <ip>::/0</ip>
            </networks>
            <profile>default</profile>
            <quota>default</quota>
        </default>
    </users>
    <quotas>
        <default>
            <interval>
                
                <duration>3600</duration>
                <queries>0</queries>
                <errors>0</errors>
                <result_rows>0</result_rows>
                <read_rows>0</read_rows>
                <execution_time>0</execution_time>
            </interval>
        </default>
    </quotas>
</yandex>


配置允许远程连接

clickhouse-server-config.xml

<listen_host>::</listen_host>取消注释

重启服务:service clickhouse-server restart  


参考连接

参考连接

参考连接


扫描二维码推送至手机访问。

版权声明:本文由一叶知秋发布,如需转载请注明出处。

本文链接:https://zhiqiu.top/?id=178

分享给朋友:

相关文章

mysql 主键 用int还是long 还是char?有什么区别

char是定长0-255 bytes longtext是0-4 294 967 295 bytes 极大文本数据longblob是二进制形式的极大文本数据...

mysql 导出csv格式数据

mysql -e "select * from newsdb.t_hk_stock_news where id <100  ...

ES 修改 查询最大行数

curl  -XPUT  http://ip:port/your_index/_settings?preserve_existing=true  -H  'Content-Type: &nbs...

postgresql 查看数据库、表的大小

查看数据库的大小 select pg_database_size('test'); select pg_size_pretty(pg_database_size('test');查看单...

mysql数据导入es

将mysql数据取出放到elasticsearch中from datetime import datetime from elasticsearch import Elastic...

mysql like 模糊查询和REGEXP 正则查询

like%:表示任意个或多个字符。可匹配任意类型和长度的字符。_:表示任意单个字符。匹配单个任意字符,它常用来限制表达式的字符长度语句:(可以代表一个中文字符)匹配”三”字结尾select * from use...