【ClickHouse】1:clickhouse安装 (CentOS7)
一:安装clickhouse
官网地址:https://clickhouse.tech/#quick-start
按照官网提供的方法快速安装:(依次执行)
sudo yum install yum-utils sudo rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG sudo yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/clickhouse.repo sudo yum install clickhouse-server clickhouse-client
启动服务并登陆:
# 启动服务 sudo /etc/init.d/clickhouse-server start # 客户端登录 clickhouse-client
官方文档:https://clickhouse.tech/docs/en/
服务各种操作:
# 查看状态 service clickhouse-server status # 启动服务 service clickhouse-server start # 停止服务 service clickhouse-server stop # 停止服务 service clickhouse-server restart
二:目录配置
修改data目录,安装好后默认目录是/var/lib/clickhouse/目录下。要把这个目录放在空间容量大的目录下,比如我这里是:/data/clickhouse/ 。
修改的配置文件目录在/etc/clickhouse-server/config.xml
官方说明:
Server config files are located in /etc/clickhouse-server/
. Before going further, please notice the <path>
element in config.xml
. Path determines the location for data storage, so it should be located on volume with large disk capacity; the default value is /var/lib/clickhouse/.If you want to adjust the configuration, it’s not handy to directly edit
config.xml
file, considering it might get rewritten on future package updates. The recommended way to override the config elements is to create files in config.d directory which serve as “patches” to config.xml.
The default location for server logs is /var/log/clickhouse-server/
. The server is ready to handle client connections once it logs the Ready for connections
message.
把数据存放目录都配置到 /data/clickhouse/ 目录下面。
vim /etc/clickhouse-server/config.xml
<!-- Path to data directory, with trailing slash. --> <path>/data/clickhouse/</path> <!-- Path to temporary data for processing hard queries. --> <tmp_path>/data/clickhouse/tmp/</tmp_path> <!-- Directory with user provided files that are accessible by 'file' table function. --> <user_files_path>/data/clickhouse/user_files/</user_files_path> <!-- Path to folder where users and roles created by SQL commands are stored. --> <access_control_path>/data/clickhouse/access/</access_control_path> <!-- Directory in <clickhouse-path> containing schema files for various input formats. The directory will be created if it doesn't exist. --> <format_schema_path>/data/clickhouse/format_schemas/</format_schema_path>
修改完之后重启服务:
service clickhouse-server restart
三:登录数据库
登录查看数据库(默认用户是default,密码为空)
clickhouse-client 或者 clickhouse-client -h127.0.0.1 都可以。
[root@centf8120 ~]# clickhouse-client -h127.0.0.1 ClickHouse client version 20.6.4.44 (official build). Connecting to 127.0.0.1:9000 as user default. Connected to ClickHouse server version 20.6.4 revision 54436. centf8120.sharding3.db :) show databases; SHOW DATABASES ┌─name───────────────────────────┐ │ _temporary_and_external_tables │ │ default │ │ system │ └────────────────────────────────┘ 3 rows in set. Elapsed: 0.003 sec. centf8120.sharding3.db :)