1. Prepare

Tencent cloud server: Centos7 system is actually installed, ch official website description is very clear, github.com/Altinity/cl… Just make a note and write it down

2. Install

# curl curl yum install -y curl # curl curl # https://packagecloud.io/install/repositories/altinity/clickhouse/script.rpm.sh | bash installation server and client, this process need to spend some time, Yum install -y clickhouse-server clickhouse-client # yum list installed 'clickhouse*' # Systemctl start clickhouse #Copy the code

You now have a ClickHouse client installed and started, but there is no password authentication that anyone can access, so you need to set a password.

3. Set the user name and password

Clickhouse passwords are written in plain text and Hash for sha256sum

You are not advised to write a plain password. You can run the following command to generate a password

PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; 
echo -n "$PASSWORD" | sha256sum | tr -d '-'
Copy the code

This yields two lines of data, the first in plain text and the second in ciphertext

The default address of the cilckhouse configuration file is /etc/clickhouse-server

Vim users. XML, find the users –> default –> TAB and change the password to password_sha256_hex and fill in the ciphertext

<password_sha256_hex> Password ciphertext </password_sha256_hex>Copy the code

After the password is added, the command line startup mode must also be added with the password

Clickhouse-client -h IP address -d default -m -u default --password Specifies the password in plain textCopy the code

Open Internet access, vim config. XML finds the listen_host tag and changes it to the following

<listen_host>0.0.0.0</listen_hostCopy the code

Connect to clickHouse using datagrip

Use datagrip to connect, enter username and password,

Create a new table under the default library to test it:

create table table1
(
    userId  Int32,
    appId   String,
    version String,
    regTime Date
)
    engine = MergeTree PARTITION BY toYYYYMM(regTime) ORDER BY userId SETTINGS index_granularity = 8192;
Copy the code

This allows you to use ClickHouse directly