如何在Ubuntu 18.04/CentOS 7上安装ClickHouse分析DBMS
时间:2020-02-23 14:32:08 来源:igfitidea点击:
在本教程中,我们将介绍在Ubuntu 18.04/CentOS 7上安装ClickHouse的步骤。ClickHouse是一个免费的开源面向列的数据库管理系统,可实时生成分析数据报告。
ClickHouse是一个多平台,可以在具有x86_64 CPU架构的任何Linux,FreeBSD或者Mac OS X上运行。预编译的二进制软件包可用于更快,更干净的安装。
在Ubuntu 18.04上安装ClickHouse
对于Ubuntu用户,可以使用受支持的apt存储库。通过运行以下命令添加它。
echo "deb http://repo.yandex.ru/clickhouse/deb/stable/main/" | sudo tee /etc/apt/sources.list.d/clickhouse.list
导入GPG密钥:
$sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E0C56BD4 Executing: /tmp/apt-key-gpghome.t6IDTPxi7M/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv E0C56BD4 gpg: key C8F1E19FE0C56BD4: public key "ClickHouse Repository Key theitroad@localhost" imported gpg: Total number processed: 1 gpg: imported: 1
然后运行以下命令来安装ClickHouse解析DBMS:
sudo apt update sudo apt -y install dirmngr clickhouse-server clickhouse-client
ClickHouse配置文件位于/etc/clickhouse-server/config.xml
中。
启动ClickHouse并将服务设置为在启动时启动。
$sudo systemctl enable --now clickhouse-server.service Synchronizing state of clickhouse-server.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable clickhouse-server $sudo systemctl is-enabled clickhouse-server.service enabled
确认服务是否正在运行:
$systemctl status clickhouse-server.service ● clickhouse-server.service - ClickHouse Server (analytic DBMS for big data) Loaded: loaded (/etc/systemd/system/clickhouse-server.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2019-03-25 21:45:58 CET; 1min 40s ago Main PID: 18406 (clickhouse-serv) Tasks: 35 (limit: 4583) CGroup: /system.slice/clickhouse-server.service └─18406 /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml Mar 25 21:45:58 ubuntu-4gb-nbg1-1 systemd[1]: Started ClickHouse Server (analytic DBMS for big data). Mar 25 21:45:58 ubuntu-4gb-nbg1-1 clickhouse-server[18406]: Include not found: clickhouse_remote_servers Mar 25 21:45:58 ubuntu-4gb-nbg1-1 clickhouse-server[18406]: Include not found: clickhouse_compression Mar 25 21:45:58 ubuntu-4gb-nbg1-1 clickhouse-server[18406]: Logging trace to /var/log/clickhouse-server/clickhouse-server.log Mar 25 21:45:58 ubuntu-4gb-nbg1-1 clickhouse-server[18406]: Logging errors to /var/log/clickhouse-server/clickhouse-server.err.log Mar 25 21:45:58 ubuntu-4gb-nbg1-1 clickhouse-server[18406]: Include not found: networks Mar 25 21:46:00 ubuntu-4gb-nbg1-1 clickhouse-server[18406]: Include not found: clickhouse_remote_servers Mar 25 21:46:00 ubuntu-4gb-nbg1-1 clickhouse-server[18406]: Include not found: clickhouse_compression
如果服务器无法启动,请在进行故障排除时检查/var/log/clickhouse-server /
上的日志。
$ls /var/log/clickhouse-server/ clickhouse-server.err.log clickhouse-server.log
在CentOS 7上安装ClickHouse
对于运行CentOS 7服务器的用户,我们可以通过packagecloud存储库执行脚本化安装。确保在系统上安装了curl。
sudo yum install -y curl
运行安装程序脚本以将Packagecloud存储库添加到CentOS 7服务器。
curl -s https://packagecloud.io/install/repositories/altinity/clickhouse/script.rpm.sh | sudo bash
确认ClickHouse软件包可用于安装。
$sudo yum list 'clickhouse*' Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.alpix.eu * extras: mirror.ratiokontakt.de * updates: mirror.checkdomain.de Available Packages clickhouse-client.x86_64 19.4.1.3-1.el7 Altinity_clickhouse clickhouse-common-static.x86_64 19.4.1.3-1.el7 Altinity_clickhouse clickhouse-compressor.x86_64 1.1.54336-3.el7 Altinity_clickhouse clickhouse-debuginfo.x86_64 18.14.15-1.el7 Altinity_clickhouse clickhouse-mysql.noarch 0.0.20160319-1 Altinity_clickhouse clickhouse-odbc.x86_64 20160903-1 Altinity_clickhouse clickhouse-server.x86_64 19.4.1.3-1.el7 Altinity_clickhouse clickhouse-server-common.x86_64 19.4.1.3-1.el7 Altinity_clickhouse clickhouse-test.x86_64 19.4.1.3-1.el7
现在安装ClickHouse服务器和客户端应用程序
sudo yum install -y clickhouse-server clickhouse-client
确认软件包已列出为已安装
sudo yum list installed 'clickhouse*'
确保ClickHouse服务器已启动,并设置为在服务器启动时启动。
$sudo systemctl start clickhouse-server $sudo systemctl enable clickhouse-server clickhouse-server.service is not a native service, redirecting to /sbin/chkconfig. Executing /sbin/chkconfig clickhouse-server on
检查服务器现在是否正在运行。
$sudo systemctl status clickhouse-server ● clickhouse-server.service - LSB: Yandex clickhouse-server daemon Loaded: loaded (/etc/rc.d/init.d/clickhouse-server; bad; vendor preset: disabled) Active: active (running) since Mon 2019-03-25 22:07:22 CET; 1min 1s ago Docs: man:systemd-sysv-generator(8) Mar 25 22:07:21 centos-4gb-nbg1-1 systemd[1]: Starting LSB: Yandex clickhouse-server daemon… Mar 25 22:07:21 centos-4gb-nbg1-1 su[12427]: (to clickhouse) root on none Mar 25 22:07:21 centos-4gb-nbg1-1 clickhouse-server[12419]: Start clickhouse-server service: Path to data directory in /etc/clickhouse-server…khouse/ Mar 25 22:07:21 centos-4gb-nbg1-1 su[12432]: (to clickhouse) root on none Mar 25 22:07:21 centos-4gb-nbg1-1 su[12434]: (to clickhouse) root on none Mar 25 22:07:21 centos-4gb-nbg1-1 su[12440]: (to clickhouse) root on none Mar 25 22:07:21 centos-4gb-nbg1-1 su[12445]: (to clickhouse) root on none Mar 25 22:07:22 centos-4gb-nbg1-1 clickhouse-server[12419]: DONE Mar 25 22:07:22 centos-4gb-nbg1-1 systemd[1]: Started LSB: Yandex clickhouse-server daemon. Hint: Some lines were ellipsized, use -l to show in full.
使用clickhouse-client连接到ClickHouse服务器
启动服务器后,我们可以使用命令行客户端连接到它:
$clickhouse-client ClickHouse client version 19.4.1.3. Connecting to localhost:9000 as user default. Connected to ClickHouse server version 19.4.1 revision 54416. ubuntu-server :)
默认情况下,它将以默认用户身份连接到localhost:9000,而无需输入密码。客户端也可以通过参数--host连接到远程服务器。
ubuntu-server :) SELECT 1 SELECT 1 ┌─1─┐ │ 1 │ └───┘ 1 rows in set. Elapsed: 0.008 sec. ubuntu-server :)