clickhouse单机部署
个人学习笔记,谢绝转载!!!
原文:https://www.cnblogs.com/wshenjin/p/13052211.html
安装
https://packagecloud.io/altinity/clickhouse
##el7
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-test-20.3.11.97-1.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-server-common-20.3.11.97-1.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-server-20.3.11.97-1.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-common-static-20.3.11.97-1.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-client-20.3.11.97-1.el7.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/7/clickhouse-test-20.3.8.53-1.el7.x86_64.rpm/download.rpm
##el6
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/6/clickhouse-test-19.9.2.4-1.el6.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/6/clickhouse-server-common-19.9.2.4-1.el6.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/6/clickhouse-server-19.9.2.4-1.el6.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/6/clickhouse-debuginfo-19.9.2.4-1.el6.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/6/clickhouse-common-static-19.9.2.4-1.el6.x86_64.rpm/download.rpm
wget --content-disposition https://packagecloud.io/Altinity/clickhouse/packages/el/6/clickhouse-client-19.9.2.4-1.el6.x86_64.rpm/download.rpm
[root@ ~]# rpm -ivh clickhouse-common-static-20.3.11.97-1.el7.x86_64.rpm \
clickhouse-server-20.3.11.97-1.el7.x86_64.rpm \
clickhouse-server-common-20.3.11.97-1.el7.x86_64.rpm \
clickhouse-client-20.3.11.97-1.el7.x86_64.rpm
配置
[root@ ~]# mkdir /data/database/clickhouse /var/log/clickhouse-server /var/run/clickhouse-server/
[root@ ~]# chown clickhouse:clickhouse /data/database/clickhouse /var/log/clickhouse-server /var/run/clickhouse-server/
[root@ ~]# vi /etc/clickhouse-server/config.xml
<!-- Path to data directory, with trailing slash. -->
<path>/data/database/clickhouse/</path>
<!-- Path to temporary data for processing hard queries. -->
<tmp_path>/data/database/clickhouse/tmp/</tmp_path>
<!-- Directory with user provided files that are accessible by 'file' table function. -->
<user_files_path>/data/database/clickhouse/user_files/</user_files_path>
<!-- Directory in <clickhouse-path> containing schema files for various input formats.The directory will be created if it doesn't exist.-->
<format_schema_path>/data/database/clickhouse/format_schemas/</format_schema_path>
<!-- Same for hosts with disabled ipv6.-->
<listen_host>0.0.0.0</listen_host>
<timezone>Asia/Shanghai</timezone>
[root@ ~]# vi /etc/clickhouse-server/users.xml
<users>
<!-- If user name was not specified, 'default' user is used. -->
<default>
<!-- 'default'配置一个明文密码 -->
<password>123456</password>
服务启动
[root@ ~]# /etc/init.d/clickhouse-server start
#或者
[root@ ~]# su -s /bin/bash clickhouse -c "/usr/bin/clickhouse-server --daemon \
--pid-file=/var/run/clickhouse-server/clickhouse-server.pid \
--config-file=/etc/clickhouse-server/config.xml"
登录
[root@ ~]# clickhouse-client -h 127.0.0.1 --password "123456"
localhost :) show databases;
SHOW DATABASES
┌─name────┐
│ default │
│ system │
└─────────┘
2 rows in set. Elapsed: 0.007 sec.
新增一个账户
在/etc/clickhouse-server/users.xml的
<admin>
<password>123456</password>
<networks incl="networks" replace="replace">
<ip>::/0</ip>
</networks>
<profile>default</profile>
<quota>default</quota>
</admin>
用mysql客户端登录
ClickHouse支持MySQL线协议。 它可以通过启用mysql_port在配置文件中设置:
<mysql_port>9004</mysql_port>
使用mysql命令行工具连接 :
[root@ ~]# mysql --protocol tcp -u admin -p -P 9004
Enter password: ******
mysql> show databases ;
+---------+
| name |
+---------+
| default |
| system |
+---------+
2 rows in set (0.00 sec)
Read 2 rows, 263.00 B in 0.001 sec., 1887 rows/sec., 242.42 KiB/sec.
mysql> \q
Bye