2018-08-10 14:44:49 +00:00
# Getting Started
2017-12-28 15:13:23 +00:00
2018-08-10 14:44:49 +00:00
## System Requirements
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
ClickHouse can run on any Linux, FreeBSD or Mac OS X with x86\_64 CPU architecture.
2018-09-04 11:18:59 +00:00
2018-12-04 17:09:57 +00:00
Though pre-built binaries are typically compiled to leverage SSE 4.2 instruction set, so unless otherwise stated usage of CPU that supports it becomes an additional system requirement. Here's the command to check if current CPU has support for SSE 4.2:
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
``` bash
$ grep -q sse4_2 /proc/cpuinfo & & echo "SSE 4.2 supported" || echo "SSE 4.2 not supported"
2017-12-28 15:13:23 +00:00
```
## Installation
2018-12-04 17:09:57 +00:00
### From DEB Packages
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
Yandex ClickHouse team recommends using official pre-compiled `deb` packages for Debian or Ubuntu.
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
To install official packages add the Yandex repository in `/etc/apt/sources.list` or in a separate `/etc/apt/sources.list.d/clickhouse.list` file:
2017-12-28 15:13:23 +00:00
2018-10-16 10:47:17 +00:00
```
2018-03-26 13:16:59 +00:00
deb http://repo.yandex.ru/clickhouse/deb/stable/ main/
2017-12-28 15:13:23 +00:00
```
2019-08-03 06:42:33 +00:00
If you want to use the most recent version, replace `stable` with `testing` (this is recommended for your testing environments).
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
Then run these commands to actually install packages:
2017-12-28 15:13:23 +00:00
```bash
2019-02-05 12:54:43 +00:00
sudo apt-get install dirmngr # optional
2019-03-14 09:38:12 +00:00
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E0C56BD4 # optional
2017-12-28 15:13:23 +00:00
sudo apt-get update
2018-04-17 20:57:02 +00:00
sudo apt-get install clickhouse-client clickhouse-server
2017-12-28 15:13:23 +00:00
```
2018-04-23 06:20:21 +00:00
You can also download and install packages manually from here: < https: / / repo . yandex . ru / clickhouse / deb / stable / main / > .
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
### From RPM Packages
2019-08-20 17:42:31 +00:00
Yandex ClickHouse team recommends using official pre-compiled `rpm` packages for CentOS, RedHat and all other rpm-based Linux distributions.
2018-12-04 17:09:57 +00:00
2019-08-20 17:42:31 +00:00
First you need to add the official repository:
2018-12-07 16:24:54 +00:00
2019-08-03 06:42:33 +00:00
```bash
sudo yum install yum-utils
sudo rpm --import https://repo.yandex.ru/clickhouse/CLICKHOUSE-KEY.GPG
sudo yum-config-manager --add-repo https://repo.yandex.ru/clickhouse/rpm/stable/x86_64
```
If you want to use the most recent version, replace `stable` with `testing` (this is recommended for your testing environments).
Then run these commands to actually install packages:
```bash
sudo yum install clickhouse-server clickhouse-client
```
You can also download and install packages manually from here: < https: / / repo . yandex . ru / clickhouse / rpm / stable / x86_64 > .
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
### From Docker Image
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
To run ClickHouse inside Docker follow the guide on [Docker Hub ](https://hub.docker.com/r/yandex/clickhouse-server/ ). Those images use official `deb` packages inside.
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
### From Sources
To manually compile ClickHouse, follow the instructions for [Linux ](../development/build.md ) or [Mac OS X ](../development/build_osx.md ).
You can compile packages and install them or use programs without installing packages. Also by building manually you can disable SSE 4.2 requirement or build for AArch64 CPUs.
2017-12-28 15:13:23 +00:00
2018-10-16 10:47:17 +00:00
```
2018-06-05 20:09:51 +00:00
Client: dbms/programs/clickhouse-client
Server: dbms/programs/clickhouse-server
2017-12-28 15:13:23 +00:00
```
2018-12-04 17:09:57 +00:00
You'll need to create a data and metadata folders and `chown` them for the desired user. Their paths can be changed in server config (src/dbms/programs/server/config.xml), by default they are:
2018-10-16 10:47:17 +00:00
```
2017-12-28 15:13:23 +00:00
/opt/clickhouse/data/default/
/opt/clickhouse/metadata/default/
```
2018-12-04 17:09:57 +00:00
On Gentoo you can just use `emerge clickhouse` to install ClickHouse from sources.
2017-12-28 15:13:23 +00:00
## Launch
2018-12-04 17:09:57 +00:00
To start the server as a daemon, run:
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
``` bash
$ sudo service clickhouse-server start
2017-12-28 15:13:23 +00:00
```
2019-08-03 06:42:33 +00:00
If you don't have `service` command, run as
``` bash
$ sudo /etc/init.d/clickhouse-server start
```
2018-12-04 17:09:57 +00:00
See the logs in the `/var/log/clickhouse-server/` directory.
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
If the server doesn't start, check the configurations in the file `/etc/clickhouse-server/config.xml` .
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
You can also manually launch the server from the console:
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
``` bash
$ clickhouse-server --config-file=/etc/clickhouse-server/config.xml
2017-12-28 15:13:23 +00:00
```
In this case, the log will be printed to the console, which is convenient during development.
2018-12-04 17:09:57 +00:00
If the configuration file is in the current directory, you don't need to specify the `--config-file` parameter. By default, it uses `./config.xml` .
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
ClickHouse supports access restriction settings. They are located in the `users.xml` file (next to `config.xml` ).
By default, access is allowed from anywhere for the `default` user, without a password. See `user/default/networks` .
For more information, see the section ["Configuration Files" ](../operations/configuration_files.md ).
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
After launching server, you can use the command-line client to connect to it:
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
``` bash
$ clickhouse-client
2017-12-28 15:13:23 +00:00
```
2018-12-04 17:09:57 +00:00
By default it connects to `localhost:9000` on behalf of the user `default` without a password. It can also be used to connect to a remote server using `--host` argument.
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
The terminal must use UTF-8 encoding.
For more information, see the section ["Command-line client" ](../interfaces/cli.md ).
2017-12-28 15:13:23 +00:00
2018-12-04 17:09:57 +00:00
Example:
``` bash
$ ./clickhouse-client
2017-12-28 15:13:23 +00:00
ClickHouse client version 0.0.18749.
Connecting to localhost:9000.
Connected to ClickHouse server version 0.0.18749.
:) SELECT 1
SELECT 1
┌─1─┐
│ 1 │
└───┘
1 rows in set. Elapsed: 0.003 sec.
:)
```
**Congratulations, the system works!**
2018-12-04 17:09:57 +00:00
To continue experimenting, you can download one of test data sets or go through [tutorial ](https://clickhouse.yandex/tutorial.html ).
2018-04-23 06:20:21 +00:00
2018-10-16 10:47:17 +00:00
[Original article ](https://clickhouse.yandex/docs/en/getting_started/ ) <!--hide-->