Install of ClickHouse on Ubuntu involves a series of steps that includes adjusting the configuration file to enable listening over other IP address and remote access.
As a part of our Server Management Services, we help our Customers with Software installations regularly.
Let us today discuss the steps to install ClickHouse on Ubuntu.
How to install ClickHouse on Ubuntu?
ClickHouse is an open-source analytics database developed for big data use cases. Typically, the installation process involves the steps below:
- Installing ClickHouse
- Starting the Service
- Change the listening IP address
- Enable Tabix
- Setting Up Firewall Rules
Let us discuss each of them in detail.
In this section, we will install the ClickHouse server and client programs using apt.
In the first step, we need to add the repository of ClickHouse. To add the repository’s GPG key and then to add the repository to the APT repositories, use the command below:
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv E0C56BD4 $ echo "deb http://repo.yandex.ru/clickhouse/deb/stable/ main/" | sudo tee /etc/apt/sources.list.d/clickhouse.list
Now, we shall update the packages:
$ sudo apt update
Next, we shall proceed to install the clickhouse-server and clickhouse-client packages:
$ sudo apt install clickhouse-server clickhouse-client
Here, it will ask to set a password for the default ClickHouse user. We will require this password to access ClickHouse server later.
Starting the Service
After the ClickHouse server and client installation, let us proceed to start the database service.
We can start the clickhouse-server service and verify its status with the commands below:
$ sudo service clickhouse-server start $ sudo service clickhouse-server status
The output of the status command confirms that the server is running. Further, we can also enable ClickHouse to run on boot with the command below:
$ sudo systemctl enable clickhouse-server
Now that we have enabled ClickHouse, we can access ClickHouse with the password that we set during installation.
$ clickhouse-client --password
This will take us to the prompt where we can execute SQL statements create, update and delete databases, tables, etc. We can also execute queries to retrieve filtered data from this client prompt.
For instance, to create a test database use the command below:
ch:) CREATE DATABASE test;
Change the listening IP address
By default ClickHouse only listens on localhost. Thus we can access it only from the same server. However, we can change the listening IP address, by editing the
Open this file with any available text editor, find the string listen_host, and uncomment the line.
To make the ClickHouse server listen only on a specific IP address, we can edit the line as follows:
Replace xxx.xxx.xxx.xxx with the actual IP address.
To access the ClickHouse server through a web browser, we need to enable Tabix by editing the
config.xml file as mentioned before. Open the config.xml file as we did earlier, find the string http_server_default_response and uncomment the line.
After making changes to the
config.xml file, we need to restart our
# sudo systemctl restart clickhouse-server
Now, we can access ClickHouse over a browser with the link
http://Your_IP_Address:8123 and log in using the default user and password that we specified earlier in the installation process.
Setting Up Firewall Rules
This step should be followed if we intend to connect to the ClickHouse database server remotely. Remote connection requires ClickHouse to listen to an IP address other than localhost. Thus changing the listening IP address that we discussed earlier is the primary step to enable remote access.
ClickHouse’s server listens on port 8123 for HTTP connections and port 9000 for connections from clickhouse-client.
Allow access to both ports for the remote server IP address with the following command:
$ sudo ufw allow from remote_server_ip/32 to any port 8123 $ sudo ufw allow from remote_server_ip/32 to any port 9000
We can add additional IPs such as our local machine’s address in the same manner if required.
Now to verify the remote connection, install the clickhouse-client on the remote server with the steps that we followed initially. Then, start a client session by executing:
$ clickhouse-client --host your_server_ip --password
We will see an output that we have connected to the server.
[Need any further assistance to install ClickHouse on Ubuntu?– We’re available 24*7]
In short, ClickHouse is an open-source analytics database developed for big data use cases. Install of ClickHouse on Ubuntu involves a series of steps that includes adjusting the configuration file to enable listening over other IP address and remote access. Today, we saw how our Support Engineers install ClickHouse on Ubuntu.
var google_conversion_label = “owonCMyG5nEQ0aD71QM”;