Course Overview
Clickhouse For Data Engineers

Running and Connecting To Clickhouse

Lesson #2

In this lesson we will:

  • Use the command line interface (CLI) to start the Clickhouse server and then connect to it from a local client.

Starting The Server

The training virtual machine already has the Clickhouse binary installed, but the server has not been started. We can begin therefore by simply running the clickhouse server command to start the process.

cd clickhouse
./clickhouse server

This will output a fairly lengthy set of logs, but a number of informational messages show that the server is starting cleanly:

2021.11.25 12:17:42.942929 [ 25 ] {} <Information> : Starting ClickHouse 21.11.4.14 with revision 54456, build id: 8332E80F7ACF6DE1033E1A6D9F16415C6E03DBF0, PID 25                                                                           2021.11.25 12:17:42.946195 [ 25 ] {} <Information> Application: starting up                                                                                                                                                       2021.11.25 12:17:42.946278 [ 25 ] {} <Information> Application: OS name: Linux, version: 5.10.47-linuxkit, architecture: x86_64
2021.11.25 12:17:45.423613 [ 25 ] {} <Information> Application: Calculated checksum of the binary: 805E158CCA2B20788668232443B9CEE6, integrity check passed.
2021.11.25 12:17:45.555272 [ 25 ] {} <Information> DatabaseCatalog: Found 0 partially dropped tables. Will load them and retry removal.                                                                                                       2021.11.25 12:17:45.561421 [ 25 ] {} <Information> DatabaseAtomic (default): Metadata processed, database default has 0 tables and 0 dictionaries in total.                                                                                   2021.11.25 12:17:45.561494 [ 25 ] {} <Information> TablesLoader: Parsed metadata of 0 tables in 1 databases in 0.000178457 sec
2021.11.25 12:17:45.561503 [ 25 ] {} <Information> TablesLoader: Loading 0 tables with 0 dependency level                                                                                                                                     2021.11.25 12:17:45.561511 [ 25 ] {} <Information> DatabaseAtomic (default): Starting up tables.                                                                                                                                              2021.11.25 12:17:45.561518 [ 25 ] {} <Information> DatabaseAtomic (system): Starting up tables.
2021.11.25 12:17:45.565785 [ 25 ] {} <Information> BackgroundSchedulePool/BgSchPool: Create BackgroundSchedulePool with 128 threads

Starting The Client

In a second shell, we can then start the Clickhouse client command. This is a command line tool which allows us to send commands to the server which we've just started:

./clickhouse client

The connection should be succesful out of the box. This is because the client assumes some defaults for the connection, such as the fact that we would like to connect to localhost, with the username default and a blank password.

If we were connecting to a different secured Clickhouse machine or with a different username or password, we can specify these details at the command line:

clickhouse-client -i clickhouse.timeflow.com:2131 -u benjaminwootton --password ABC123

For the purpose of the lesson, the defaults are fine so the client should connect succesfully. We can then issue a command within the Clickhouse client to check connectivity:

show databases

Outputs:

SHOW DATABASES

Query id: a3f1db00-87af-47a8-9096-dad14df00589

┌─name───────────────┐
│ INFORMATION_SCHEMA │
│ default            │
│ information_schema │
│ system             │
└────────────────────┘

4 rows in set. Elapsed: 0.004 sec.

This shows that the server is running, and we now have connectivity between our client the server.

Next Lesson:
02

Database Objects

In this lesson we will explain the core database objects in Clickhouse including tables, views, users, roles and more.

0h 5m



Continuous Delivery For Data Engineers

This site has been developed by the team behind Timeflow, an Open Source CI/CD platform designed for Data Engineers who use dbt as part of the Modern Data Stack. Our platform helps Data Engineers improve the quality, reliability and speed of their data transformation pipelines.

Join our mailing list for our latest insights on Data Engineering:

Timeflow Academy is the leading online, hands-on platform for learning about Data Engineering using the Modern Data Stack. Bought to you by Timeflow CI

© 2023 Timeflow Academy. All rights reserved