ClickHouse is a fast open-source column-oriented database management system optimized for real-time analytical queries. Whether you're running Linux, macOS, or FreeBSD, setting up ClickHouse is quick and easy using a single binary download.
This guide walks you through the steps to install ClickHouse on your machine, try it out with clickhouse-local, and optionally run the full ClickHouse server for persistent storage.
Installation and Getting Started Steps
Step 1: Download ClickHouse Binary
Open your terminal and run the following command to download ClickHouse for your system.
curl https://clickhouse.com/ | sh
Step 2: Run the following command to start clickhouse-local.
./clickhouse
$./clickhouse .... ClickHouse local version 25.5.1.1919 (official build). :)
You can execute the command ‘SHOW DATABASES;’ to list all the databases of Clickhouse.
:) SHOW DATABASES; SHOW DATABASES Query id: 7f24112f-2266-48ba-b2ea-46d42fd5ccad ┌─name───────────────┐ 1. │ INFORMATION_SCHEMA │ 2. │ default │ 3. │ information_schema │ 4. │ system │ └────────────────────┘ 4 rows in set. Elapsed: 0.004 sec. :)
Execute the command quit to exit from the Clickhouse interactive shell.
:) quit
Bye.
clickhouse-local is a lightweight version of ClickHouse, designed for developers to quickly process local and remote files using SQL without needing to install a full database server. It’s included with the clickhouse-client package, making it easy to get started with SQL queries for development and testing.
However, clickhouse-local is not intended for production environments or serving end-users. For large-scale analytical workloads, high-performance queries, and production deployments, the full open-source ClickHouse database is recommended, as it supports features like replication, sharding, and high availability to handle large datasets and ensure scalability.
Table data in clickhouse-local is stored temporarily, so after a restart, any previously created tables are no longer accessible.
Step 3: Start ClickHouse Server (For Persistent Usage)
As an alternative to clickhouse-local, we can run the clickhouse server as well. To run a persistent ClickHouse server on your system, execute following command.
./clickhouse server
Upon starting the server successfully, you can see following folders/files are added to your current directory.
$ ls -lart total 922576 drwxr-xr-x 24 krishna demo 768 4 May 18:56 .. -rwxr-xr-x 1 krishna demo 472346800 4 May 18:58 clickhouse drwxr-x--- 3 krishna demo 96 4 May 19:05 preprocessed_configs -rw-r----- 1 krishna demo 59 4 May 19:05 status -rw-r----- 1 krishna demo 36 4 May 19:05 uuid drwxr-x--- 2 krishna demo 64 4 May 19:05 tmp drwxr-x--- 2 krishna demo 64 4 May 19:05 flags drwxr-x--- 2 krishna demo 64 4 May 19:05 user_files drwxr-x--- 2 krishna demo 64 4 May 19:05 metadata_dropped drwxr-x--- 2 krishna demo 64 4 May 19:05 format_schemas drwxr-x--- 3 krishna demo 96 4 May 19:05 data drwxr-xr-x@ 14 krishna demo 448 4 May 19:05 . drwxr-x--- 3 krishna demo 96 4 May 19:05 store drwxr-x--- 6 krishna demo 192 4 May 19:05 metadata
Data is stored in your current directory (./data/ by default). When you start Clickhouse like this, the tables and data remain even after you stop and restart the server.
You can pass a custom configuration file using -C option.
./clickhouse server -C config.xml
Step 4: Connect to Server Using ClickHouse Client
Open a new terminal and connect to the server.
./clickhouse client
$ ./clickhouse client ClickHouse client version 25.5.1.1919 (official build). Connecting to localhost:9000 as user default. Connected to ClickHouse server version 25.5.1. Warnings: * Maximum number of threads is lower than 30000. There could be problems with handling a lot of simultaneous queries. krishna :)
Once Client connected successfully, you can now write and execute SQL queries on the running server.
krishna :) SHOW DATABASES; SHOW DATABASES Query id: 9485c36b-a250-4142-b880-106e75e177fe ┌─name───────────────┐ 1. │ INFORMATION_SCHEMA │ 2. │ default │ 3. │ information_schema │ 4. │ system │ └────────────────────┘ 4 rows in set. Elapsed: 0.002 sec.
Previous Next Home
No comments:
Post a Comment