ClickHouse installation and use

<ClickHouse introduction >We introduced ClickHouse, learning technology. The most important thing is practice. Through step by step, we can experience ClickHouse.

Whether a software is easy to use or not, installation is the first impression.

ClickHouse can be installed in any with x86_64, AArch64 or PowerPC64LE CPU architecture running on Linux, FreeBSD or Mac OS X. Official pre built binaries are usually targeted at x86_64 and uses the SSE 4.2 instruction set. Therefore, unless otherwise specified, supporting its CPU usage will become an additional system requirement.

The following is a command to check whether the current CPU supports SSE 4.2,

[root@bisal ~]# grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported"
SSE 4.2 supported

ClickHouse supports many installations,

(1) DEB installation package

(2) RPM installation package

(3) Tgz installation package

(4) Docker installation package

(5) Other environment installation packages. For non linux operating system and Arch64 CPU architecture, ClickHouse will be compiled and provided with the latest submitted from the master branch

(6) Source code installation

I tried to install ClickHouse through Tgz on a set of 1C2G cloud resources.

Store the latest version number in latest according to the instructions of the official documents_ Version, and then download the latest 4 tgz s through curl,

export LATEST_VERSION=`curl https://api.github.com/repos/ClickHouse/ClickHouse/tags 2>/dev/null | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1`
curl -O https://repo.clickhouse.com/tgz/clickhouse-common-static-$LATEST_VERSION.tgz
curl -O https://repo.clickhouse.com/tgz/clickhouse-common-static-dbg-$LATEST_VERSION.tgz
curl -O https://repo.clickhouse.com/tgz/clickhouse-server-$LATEST_VERSION.tgz
curl -O https://repo.clickhouse.com/tgz/clickhouse-client-$LATEST_VERSION.tgz

As shown below, the latest is 21.12.1.8816,

[root@bisal ~]# echo $LATEST_VERSION
21.12.1.8816

But so far, curl's address https://repo.clickhouse.com/tgz/ , the latest version is not available, so the download will fail,

You can download the latest version from GitHub, but note that the end is stable, which is the stable version, https://github.com/ClickHouse/ClickHouse/tags ,

curl returns information in json format,

Download these,

Enter these folders and execute install/doinst.sh to complete the installation,

sudo clickhouse-common-static-$LATEST_VERSION/install/doinst.sh
sudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.sh
sudo clickhouse-server-$LATEST_VERSION/install/doinst.sh
sudo clickhouse-client-$LATEST_VERSION/install/doinst.sh

ClickHouse Server can be started in the following ways:,

sudo /etc/init.d/clickhouse-server start
sudo service clickhouse-server start
clickhouse-server --config-file=/etc/clickhouse-server/config.xml(Starting from the console, the log will be printed to the console)

The log path is / var / log / Clickhouse server /, and the configuration file path is / etc / Clickhouse server / config.xml.

At this time, you can connect to the database through the client,

clickhouse-client

If you change your password, you may be prompted with an error,

ClickHouse client version 21.11.3.6 (official build).
Connecting to localhost:9000 as user default.
If you have installed ClickHouse and forgot password you can reset it in the configuration file.
The password for default user is typically located at /etc/clickhouse-server/users.d/default-password.xml
and deleting this file will reset the password.
See also /etc/clickhouse-server/users.xml on the server where ClickHouse is installed.
Code: 516. DB::Exception: Received from localhost:9000. DB::Exception: default: Authentication failed: password is incorrect or there is no user with such name. (AUTHENTICATION_FAILED)

At this time, you can use -- password to specify the specific password,

clickhouse-client --user=default --password=clickhouse --host=127.0.0.1 --multiline

Please note that -- multiline is used here. It means to escape long SQL. Otherwise, an error will be prompted when executing cross row SQL. As shown below, it will execute each row as an independent SQL,

Log in to the database and execute select 1. There may be garbled code. At this time, adjust your software character set such as secureCRT to UTF-8 and restart to take effect,

VM-24-12-centos :) select 1


SELECT 1


Query id: e10f42f2-92f9-426e-88ba-6a22f5a84fc5


Beryllium 1 beryllium€Beryllium
 Beryllium 1 beryllium
 Beryllium€Beryllium€Beryllium


1 rows in set. Elapsed: 0.001 sec.

Log in again and the execution will be normal,

VM-24-12-centos :) select 1


SELECT 1


Query id: 141db667-bfca-41da-bffd-e85f8d62cbc6


┌─1─┐
│ 1 │
└───┘


1 rows in set. Elapsed: 0.002 sec.

ClickHouse will automatically record the. ClickHouse client history of the root path for each SQL executed by logging in to the database,

### 2021-11-13 10:50:14.109
show tables;
### 2021-11-13 10:56:56.225
show processlist;
### 2021-11-13 10:57:27.228
exit
### 2021-11-13 10:58:02.519
select 1
### 2021-11-13 10:58:13.384
select * from system.processes;

Create a test table,

Insert test data,

Retrieve data,

They are all standard SQL, a little basic, and can be operated. Moreover, many operations are very similar to MySQL,

show databases,use database,show tables,

ClickHouse supports many forms of client connection,

https://clickhouse.com/docs/zh/interfaces/third-party/gui/

DBeaver supports it,

The command line is followed by query to execute SQL, which is convenient for use in scripts,

[clickhouse@bisal ~]$ ck --query "select count(*) from datasets.city"
0

reference material,

https://blog.51cto.com/u_15127645/2777968

https://blog.csdn.net/weixin_45727359/article/details/114421863

https://blog.csdn.net/wbl381/article/details/106995351/

https://clickhouse.com/docs/en/introduction/distinctive-features/

https://www.jianshu.com/p/350b59e8ea68

https://clickhouse.com/docs/zh/getting-started/example-datasets/ontime/

Posted by RobbertvanOs on Fri, 03 Dec 2021 02:17:59 -0800