2020-04-03 13:23:32 +00:00
---
toc_priority: 11
toc_title: Installation
---
2020-03-20 10:10:48 +00:00
# Installation {#installation}
2019-12-05 16:36:51 +00:00
2020-03-20 10:10:48 +00:00
## System Requirements {#system-requirements}
2019-12-05 16:36:51 +00:00
2020-10-13 17:23:29 +00:00
ClickHouse can run on any Linux, FreeBSD, or Mac OS X with x86_64, AArch64, or PowerPC64LE CPU architecture.
2019-12-05 16:36:51 +00:00
2020-10-13 17:23:29 +00:00
Official pre-built binaries are typically compiled for x86_64 and 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:
2019-12-05 16:36:51 +00:00
``` bash
$ grep -q sse4_2 /proc/cpuinfo & & echo "SSE 4.2 supported" || echo "SSE 4.2 not supported"
```
To run ClickHouse on processors that do not support SSE 4.2 or have AArch64 or PowerPC64LE architecture, you should [build ClickHouse from sources ](#from-sources ) with proper configuration adjustments.
2020-03-20 10:10:48 +00:00
## Available Installation Options {#available-installation-options}
2019-12-05 16:36:51 +00:00
2020-03-18 18:43:51 +00:00
### From DEB Packages {#install-from-deb-packages}
2019-12-05 16:36:51 +00:00
2020-04-28 16:39:50 +00:00
It is recommended to use official pre-compiled `deb` packages for Debian or Ubuntu. Run these commands to install packages:
2019-12-05 16:36:51 +00:00
2020-03-20 10:10:48 +00:00
``` bash
2020-04-28 16:39:50 +00:00
{% include 'install/deb.sh' %}
2019-12-05 16:36:51 +00:00
```
2020-04-28 16:39:50 +00:00
If you want to use the most recent version, replace `stable` with `testing` (this is recommended for your testing environments).
You can also download and install packages manually from [here ](https://repo.clickhouse.tech/deb/stable/main/ ).
2019-12-05 16:36:51 +00:00
2020-03-20 10:10:48 +00:00
#### Packages {#packages}
2020-01-16 07:55:18 +00:00
2020-03-21 04:11:51 +00:00
- `clickhouse-common-static` — Installs ClickHouse compiled binary files.
2020-03-27 06:02:21 +00:00
- `clickhouse-server` — Creates a symbolic link for `clickhouse-server` and installs the default server configuration.
- `clickhouse-client` — Creates a symbolic link for `clickhouse-client` and other client-related tools. and installs client configuration files.
2020-03-21 04:11:51 +00:00
- `clickhouse-common-static-dbg` — Installs ClickHouse compiled binary files with debug info.
2020-01-16 07:55:18 +00:00
2020-03-20 10:10:48 +00:00
### From RPM Packages {#from-rpm-packages}
2019-12-05 16:36:51 +00:00
2020-03-27 06:02:21 +00:00
It is recommended to use official pre-compiled `rpm` packages for CentOS, RedHat, and all other rpm-based Linux distributions.
2019-12-05 16:36:51 +00:00
2020-03-19 06:53:47 +00:00
First, you need to add the official repository:
2019-12-05 16:36:51 +00:00
2020-03-20 10:10:48 +00:00
``` bash
2019-12-05 16:36:51 +00:00
sudo yum install yum-utils
2020-03-15 18:19:43 +00:00
sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG
sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64
2019-12-05 16:36:51 +00:00
```
2020-05-19 06:02:30 +00:00
If you want to use the most recent version, replace `stable` with `testing` (this is recommended for your testing environments). `prestable` is sometimes also available.
2019-12-05 16:36:51 +00:00
2020-03-19 06:53:47 +00:00
Then run these commands to install packages:
2019-12-05 16:36:51 +00:00
2020-03-20 10:10:48 +00:00
``` bash
2019-12-05 16:36:51 +00:00
sudo yum install clickhouse-server clickhouse-client
```
2020-04-16 09:14:30 +00:00
You can also download and install packages manually from [here ](https://repo.clickhouse.tech/rpm/stable/x86_64 ).
2019-12-05 16:36:51 +00:00
2020-04-08 14:22:25 +00:00
### From Tgz Archives {#from-tgz-archives}
2020-01-10 13:48:28 +00:00
2020-01-10 13:58:26 +00:00
It is recommended to use official pre-compiled `tgz` archives for all Linux distributions, where installation of `deb` or `rpm` packages is not possible.
2020-01-10 13:48:28 +00:00
2020-06-10 18:54:55 +00:00
The required version can be downloaded with `curl` or `wget` from repository https://repo.clickhouse.tech/tgz/.
2020-01-10 14:02:13 +00:00
After that downloaded archives should be unpacked and installed with installation scripts. Example for the latest version:
2020-03-20 10:10:48 +00:00
``` bash
2020-01-10 13:48:28 +00:00
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`
2020-03-15 18:19:43 +00:00
curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-$LATEST_VERSION.tgz
curl -O https://repo.clickhouse.tech/tgz/clickhouse-common-static-dbg-$LATEST_VERSION.tgz
curl -O https://repo.clickhouse.tech/tgz/clickhouse-server-$LATEST_VERSION.tgz
curl -O https://repo.clickhouse.tech/tgz/clickhouse-client-$LATEST_VERSION.tgz
2020-01-10 13:48:28 +00:00
tar -xzvf clickhouse-common-static-$LATEST_VERSION.tgz
sudo clickhouse-common-static-$LATEST_VERSION/install/doinst.sh
tar -xzvf clickhouse-common-static-dbg-$LATEST_VERSION.tgz
sudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.sh
tar -xzvf clickhouse-server-$LATEST_VERSION.tgz
sudo clickhouse-server-$LATEST_VERSION/install/doinst.sh
sudo /etc/init.d/clickhouse-server start
tar -xzvf clickhouse-client-$LATEST_VERSION.tgz
sudo clickhouse-client-$LATEST_VERSION/install/doinst.sh
```
2020-03-20 10:10:48 +00:00
For production environments, it’ s recommended to use the latest `stable` -version. You can find its number on GitHub page https://github.com/ClickHouse/ClickHouse/tags with postfix `-stable` .
2020-01-10 13:48:28 +00:00
2020-03-20 10:10:48 +00:00
### From Docker Image {#from-docker-image}
2019-12-05 16:36:51 +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.
2020-06-23 18:44:13 +00:00
### From Precompiled Binaries for Non-Standard Environments {#from-binaries-non-linux}
For non-Linux operating systems and for AArch64 CPU arhitecture, ClickHouse builds are provided as a cross-compiled binary from the latest commit of the `master` branch (with a few hours delay).
2020-07-09 15:10:35 +00:00
- [macOS ](https://builds.clickhouse.tech/master/macos/clickhouse ) — `curl -O 'https://builds.clickhouse.tech/master/macos/clickhouse' && chmod a+x ./clickhouse`
- [FreeBSD ](https://builds.clickhouse.tech/master/freebsd/clickhouse ) — `curl -O 'https://builds.clickhouse.tech/master/freebsd/clickhouse' && chmod a+x ./clickhouse`
- [AArch64 ](https://builds.clickhouse.tech/master/aarch64/clickhouse ) — `curl -O 'https://builds.clickhouse.tech/master/aarch64/clickhouse' && chmod a+x ./clickhouse`
2020-06-23 18:44:13 +00:00
2021-04-30 13:23:12 +00:00
After downloading, you can use the `clickhouse client` to connect to the server, or `clickhouse local` to process local data.
2021-05-13 17:05:58 +00:00
Run `sudo ./clickhouse install` if you want to install clickhouse system-wide (also with needed configuration files, configuring users etc.). After that run `clickhouse start` commands to start the clickhouse-server and `clickhouse-client` to connect to it.
2020-06-23 18:44:13 +00:00
These builds are not recommended for use in production environments because they are less thoroughly tested, but you can do so on your own risk. They also have only a subset of ClickHouse features available.
2020-03-20 10:10:48 +00:00
### From Sources {#from-sources}
2019-12-05 16:36:51 +00:00
2020-04-30 18:19:18 +00:00
To manually compile ClickHouse, follow the instructions for [Linux ](../development/build.md ) or [Mac OS X ](../development/build-osx.md ).
2019-12-05 16:36:51 +00:00
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.
2020-04-01 23:51:21 +00:00
Client: programs/clickhouse-client
Server: programs/clickhouse-server
2019-12-05 16:36:51 +00:00
2020-04-01 23:51:21 +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/programs/server/config.xml), by default they are:
2020-03-20 10:10:48 +00:00
2020-12-07 16:23:46 +00:00
/var/lib/clickhouse/data/default/
/var/lib/clickhouse/metadata/default/
2019-12-05 16:36:51 +00:00
2020-03-19 06:53:47 +00:00
On Gentoo, you can just use `emerge clickhouse` to install ClickHouse from sources.
2019-12-05 16:36:51 +00:00
2020-03-20 10:10:48 +00:00
## Launch {#launch}
2019-12-05 16:36:51 +00:00
To start the server as a daemon, run:
``` bash
$ sudo service clickhouse-server start
```
2020-03-20 10:10:48 +00:00
If you don’ t have `service` command, run as
2019-12-05 16:36:51 +00:00
``` bash
$ sudo /etc/init.d/clickhouse-server start
```
See the logs in the `/var/log/clickhouse-server/` directory.
2020-03-20 10:10:48 +00:00
If the server doesn’ t start, check the configurations in the file `/etc/clickhouse-server/config.xml` .
2019-12-05 16:36:51 +00:00
You can also manually launch the server from the console:
``` bash
$ clickhouse-server --config-file=/etc/clickhouse-server/config.xml
```
In this case, the log will be printed to the console, which is convenient during development.
2020-03-20 10:10:48 +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` .
2019-12-05 16:36:51 +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` .
2020-04-30 18:19:18 +00:00
For more information, see the section [“Configuration Files” ](../operations/configuration-files.md ).
2019-12-05 16:36:51 +00:00
After launching server, you can use the command-line client to connect to it:
``` bash
$ clickhouse-client
```
2020-03-19 06:53:47 +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.
2019-12-05 16:36:51 +00:00
The terminal must use UTF-8 encoding.
2020-03-20 10:10:48 +00:00
For more information, see the section [“Command-line client” ](../interfaces/cli.md ).
2019-12-05 16:36:51 +00:00
Example:
2020-03-20 10:10:48 +00:00
2020-08-06 22:14:31 +00:00
```
2019-12-05 16:36:51 +00:00
$ ./clickhouse-client
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!**
2020-03-19 06:53:47 +00:00
To continue experimenting, you can download one of the test data sets or go through [tutorial ](https://clickhouse.tech/tutorial.html ).
2019-12-05 16:36:51 +00:00
2020-01-30 10:34:55 +00:00
[Original article ](https://clickhouse.tech/docs/en/getting_started/install/ ) <!--hide-->