Introduction
ClickHouse is a column-oriented database designed to address OLAP – Online Analytical Processing. OLAP is a technique for advanced big data analysis.
The language ClickHouse uses is a variation of SQL, which helps beginners learn this query language faster.
This tutorial will show you how to install and start using ClickHouse on Ubuntu 20.04.
Prerequisites
- A system running Ubuntu 20.04
- A user account with sudo or root privileges
- Access to a terminal window / command-line prompt
Installing ClickHouse on Ubuntu 20.04
To learn how to install ClickHouse on Ubuntu, follow the steps below. Make sure not to skip any steps to avoid potential issues when launching the tool.
STEP 1: Install apt-transport Package
ClickHouse needs the apt-transport package that does not come by default with Ubuntu 20.04.
To install the tool, open a terminal window, and update the package repository:
sudo apt update
Then, install the apt-transport-https package with the following command:
sudo apt install apt-transport-https ca-certificates dirmngr/code>
STEP 2: Add the Repository GPG Key
Before you download and install the latest ClickHouse version, add the GPG key from the Yandex repository:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E0C56BD4
The terminal output shows a confirmation message when the key is added.
Make sure the output shows the key is processed and imported.
STEP 3: Add ClickHouse to APT Repository
Now, add ClickHouse to your software repository.
Execute the following echo
command to add the repository to the clickhouse.list file:
echo "deb http://repo.yandex.ru/clickhouse/deb/stable/ main/" | sudo tee /etc/apt/sources.list.d/clickhouse.list
The output returns a new line. Update the package repository one more time:
sudo apt update
When the system finishes, move to the final step.
STEP 4: Install ClickHouse Server and Client
Install the ClickHouse client and server:
sudo apt install clickhouse-server clickhouse-client
Enter a password when prompted.
This is the password for the default user that you will later use to load the ClickHouse console.
The final output after the installation looks similar to the one in the image below:
Getting Started With ClickHouse
Now that the ClickHouse server and client is installed on Ubuntu, Linux systemd controls this service. You can start, stop, and check the ClickHouse service with a few commands.
To start the clickhouse-server, use:
sudo systemctl start clickhouse-server
The output does not return a confirmation.
To check the ClickHouse service status, enter:
sudo systemctl status clickhouse-server
To stop the ClickHouse server, run this command:
sudo systemctl stop clickhouse-server
To enable ClickHouse on boot:
sudo systemctl enable clickhouse-server
Start ClickHouse Session
To start working with ClickHouse databases, launch the ClickHouse client. When you start a session, the procedure is similar to other SQL management systems.
To start the client, use the command:
clickhouse-client
You may get this error:
“Code: 516. DB::Exception: Received from localhost:9000. DB::Exception: default: Authentication failed: password is incorrect or there is no user with such name.”
When that error occurs, you need to define the password entered during the installation for the default user.
To do so, enter:
clickhouse-client --password test1234 --user default
Replace the sample password with your own.
The session starts.
Conclusion
The steps in this guide showed you how to install ClickHouse on Ubuntu 20.04 and get started.
If you get an error with code 516 when you start the ClickHouse client, use the solution we provided in the final section.
If you are using CentOS, be sure to read our guide on ClickHouse installation on CentOS 7.
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/223675.html