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

Clickhouse单机安装

程序员文章站 2022-07-06 15:46:47
...

下载可参考:https://clickhouse.tech/docs/zh/getting-started/install/#from-rpm-packages

-- 下载
# wget -c https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-client-20.9.5.5-2.noarch.rpm
# wget -c https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-common-static-20.9.5.5-2.x86_64.rpm
# wget -c https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-common-static-dbg-20.9.5.5-2.x86_64.rpm
# wget -c https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-server-20.9.5.5-2.noarch.rpm
# wget -c https://repo.yandex.ru/clickhouse/rpm/stable/x86_64/clickhouse-test-20.9.5.5-2.noarch.rpm

Clickhouse单机安装

-- 安装
# rpm -ihv clickhouse-common-static-20.9.5.5-2.x86_64.rpm
# rpm -ihv clickhouse-common-static-dbg-20.9.5.5-2.x86_64.rpm
# rpm -ihv clickhouse-server-20.9.5.5-2.noarch.rpm
# rpm -ihv clickhouse-client-20.9.5.5-2.noarch.rpm

-- 安装成功后有以下两目录
/etc/clickhouse-client/ 
/etc/clickhouse-server/

Clickhouse单机安装

ClickHouse目录结构

/etc/clickhouse-server: 服务端的配置文件目录,包括全局配置config.xml 和用户配置users.xml,我们一般修改一下配置项:

logger 修改日志的存放路径
http_port 修改浏览器访问的端口,默认为8123
tcp_port 修改tcp协议的传输端口
openSSL 一些ssl的认证配置文件
listen_host 如果我们要对外使用服务的话,对外网开放的话我们要设置0.0.0.0或::
remote_servers 此处是集群相关

创建磁盘目录并授权,便于管理维护

#mkdir -p /data/clickhouse-server/{access,data,format_schemas,logs,tmp,user_files}
#chown -R clickhouse:clickhouse /data/clickhouse-server

配置文件主要内容config.xml

<yandex>
<!--日志-->
<logger>
    <!-- Possible levels: https://github.com/pocoproject/poco/blob/poco-1.9.4-release/Foundation/include/Poco/Logger.h#L105 -->
    <level>trace</level>
    <log>/data/clickhouse-server/logs/clickhouse-server.log</log>
    <errorlog>/data/clickhouse-server/logs/clickhouse-server.err.log</errorlog>
    <size>1000M</size>
    <count>10</count>
</logger>    

<!--端口-->
<http_port>8123</http_port>
<tcp_port>9000</tcp_port>
<interserver_http_port>9009</interserver_http_port>
<interserver_http_host>dr</interserver_http_host>

<!--监听-->
<listen_host>0.0.0.0</listen_host>

<!--连接相关-->
<max_connections>4096</max_connections>
<keep_alive_timeout>3</keep_alive_timeout>
<max_concurrent_queries>100</max_concurrent_queries>

<!--内存限制相关-->
<max_server_memory_usage>0</max_server_memory_usage>
<max_server_memory_usage_to_ram_ratio>0.9</max_server_memory_usage_to_ram_ratio>
<total_memory_profiler_step>4194304</total_memory_profiler_step>
<total_memory_tracker_sample_probability>0</total_memory_tracker_sample_probability>
<uncompressed_cache_size>8589934592</uncompressed_cache_size>
<mark_cache_size>5368709120</mark_cache_size>

<!--路径相关-->
<path>/data/clickhouse-server/data/</path>
<tmp_path>/data/clickhouse-server/tmp/</tmp_path>
<user_files_path>/data/clickhouse-server/user_files/</user_files_path>
<access_control_path>/data/clickhouse-server/access/</access_control_path>

<!--集群配置相关
<include_from>/etc/clickhouse-server/config.d/metrika.xml</include_from>
<remote_servers incl="clickhouse_remote_servers" />
<zookeeper incl="zookeeper-servers" optional="true" />
<macros incl="macros" optional="true" /> -->
<yandex>

服务启停及客户端连接
1:停止服务
service clickhouse-server stop
2:启动服务
service clickhouse-server start
3:重启服务
service clickhouse-server restart
4:client命令行连接本地ClickHouse服务器
Clickhouse-client
5:client命令行clickhouse-client连接远程clickhouse-server服务器
clickhouse-client –host 172.168.11.11 –port 9000 –database default –user default –password “”

相关标签: clickhouse