环境:
OS:Centos 7
db:24.11.8.5
1.下载安装介质
下载地址为:https://packagecloud.io/Altinity/clickhouse
或是这里下载
https://mirrors.tuna.tsinghua.edu.cn/clickhouse/rpm/stable/x86_64/
我这里下载的是如下三个包
clickhouse-client-24.8.11.5.noarch.rpm
clickhouse-common-static-24.8.11.5.x86_64.rpm
clickhouse-server-24.8.11.5.noarch.rpm
[root@localhost soft]# mkdir /soft/clickhouse
[root@localhost soft]# cd /soft/clickhouse
[root@localhost soft]#wget https://packages.clickhouse.com/rpm/stable/clickhouse-server-24.8.11.5.x86_64.rpm
[root@localhost soft]#wget https://packages.clickhouse.com/rpm/stable/clickhouse-common-static-24.8.11.5.x86_64.rpm
[root@localhost soft]#wget https://packages.clickhouse.com/rpm/stable/clickhouse-client-24.8.11.5.x86_64.rpm
2.安装
[root@localhost clickhouse]#rpm -ivh clickhouse-common-static-24.8.11.5.x86_64.rpm
[root@localhost clickhouse]#rpm -ivh clickhouse-client-24.8.11.5.x86_64.rpm
[root@localhost clickhouse]#rpm -ivh clickhouse-server-24.8.11.5.x86_64.rpm
这里会提示输入默认的密码,可以直接回车 不需要密码,后面单独对用户进行设置密码
若之前安装了历史版本的,需要进行删除后再安装
[root@localhost clickhouse]# rpm -qa|grep clickhouse
clickhouse-client-21.9.7.2-2.noarch
clickhouse-common-static-21.9.7.2-2.x86_64
clickhouse-server-21.9.7.2-2.noarch
[root@localhost clickhouse]#rpm -e clickhouse-server-21.9.7.2-2.noarch
[root@localhost clickhouse]#rpm -e clickhouse-client-21.9.7.2-2.noarch
[root@localhost clickhouse]#rpm -e clickhouse-common-static-21.9.7.2-2.x86_64
3.修改数据目录和日志目录
创建数据目录和日志目录
[root@localhost ~]# mkdir -p /home/middle/clickhouse/data
[root@localhost ~]# mkdir -p /home/middle/clickhouse/log
[root@localhost ~]# chown -R clickhouse:clickhouse /home/middle/clickhouse/
修改数据目录
vi /etc/clickhouse-server/config.xml
原来的 <!-- Path to data directory, with trailing slash. --> <path>/var/lib/clickhouse/</path>
修改为 <!-- Path to data directory, with trailing slash. --> <path>/home/middle/clickhouse/data/</path>
修改日志目录
原来的: <level>trace</level> <log>/var/log/clickhouse-server/clickhouse-server.log</log> <errorlog>/var/log/clickhouse-server/clickhouse-server.err.log</errorlog>
修改为: <level>trace</level> <log>/home/middle/clickhouse/log/clickhouse-server.log</log> <errorlog>/home/middle/clickhouse/log/clickhouse-server.err.log</errorlog>
4.配置远程登录
[root@localhost clickhouse]#vi /etc/clickhouse-server/config.xml
把下面2行注释去掉,之前是注释的,现在要开启
原来的: <!-- Default values - try listen localhost on IPv4 and IPv6. --> <!-- <listen_host>::1</listen_host> <listen_host>127.0.0.1</listen_host> -->
修改为: <!-- Default values - try listen localhost on IPv4 and IPv6. --> <listen_host>::1</listen_host> <listen_host>0.0.0.0</listen_host>
5.修改允许删除掉任何表和表分区,将如下两行去掉注释,使其生效
[root@localhost clickhouse]#vi /etc/clickhouse-server/config.xml
原来的: <!-- <max_table_size_to_drop>0</max_table_size_to_drop> --> <!-- <max_partition_size_to_drop>0</max_partition_size_to_drop> -->
修改为: <max_table_size_to_drop>0</max_table_size_to_drop> <max_partition_size_to_drop>0</max_partition_size_to_drop>
6.启动clickhouse-server
centos 7需要使用systemctl启动
systemctl status clickhouse-server.service
systemctl start clickhouse-server.service
systemctl stop clickhouse-server.service
clickhouse默认使用的是9000端口,注意避免端口冲突:
<tcp_port>9000</tcp_port>
或是使用如下方式启动或停止
[root@localhost middle]# clickhouse start chown -R clickhouse: '/var/run/clickhouse-server/' Will run sudo --preserve-env -u 'clickhouse' /usr/bin/clickhouse-server --config-file /etc/clickhouse-server/config.xml --pid-file /var/run/clickhouse-server/clickhouse-server.pid --daemon Waiting for server to start Waiting for server to start Server started [root@localhost]# clickhouse stop [root@localhost middle]# clickhouse stop /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 12262. The process with pid = 12262 is running. Sent terminate signal to process with pid 12262. Waiting for server to stop /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 12262. The process with pid = 12262 is running. Waiting for server to stop /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 12262. The process with pid = 12262 is running. Waiting for server to stop /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 12262. The process with pid = 12262 is running. Waiting for server to stop /var/run/clickhouse-server/clickhouse-server.pid file exists and contains pid = 12262. The process with pid = 12262 is running. Waiting for server to stop Now there is no clickhouse-server process. Server stopped
7.登陆
这个时候是免密登录
[root@localhost log]# clickhouse-client -h 192.168.1.134 -m -u default --port=9000 ClickHouse client version 24.8.11.5 (official build). Connecting to 192.168.1.134:9000 as user default. Connected to ClickHouse server version 24.8.11. localhost :) show databases; SHOW DATABASES Query id: 012f544b-e900-4c21-9621-f8984b987b36 ┌─name───────────────┐ 1. │ INFORMATION_SCHEMA │ 2. │ default │ 3. │ information_schema │ 4. │ system │ └────────────────────┘ 4 rows in set. Elapsed: 0.003 sec. localhost :) select version(); SELECT version() Query id: d3a3f703-7cb2-4354-8686-6275af7409a9 ┌─version()─┐ 1. │ 24.8.11.5 │ └───────────┘ 1 row in set. Elapsed: 0.002 sec.
8.配置默认密码
生成加密密码,我这里明文密码是 clickhouse123 ,对其加密后生成的串如下
[root@localhost log]# echo -n clickhouse123 | openssl dgst -sha256 (stdin)= 2cca9d8714615f4132390a3db9296d39ec051b3faff87be7ea5f7fe0e2de14c9
9.修改users.xml配置文件
修改配置文件:/etc/clickhouse-server/users.xml
在默认账号栏目加入如下项<default></default>
<password_sha256_hex>2cca9d8714615f4132390a3db9296d39ec051b3faff87be7ea5f7fe0e2de14c9</password_sha256_hex>
同时注释掉如下项目
<password></password>
<password_sha256_hex> 和 <password> 不能同时出现,最后效果如下:
然后重新启动
[root@localhost log]# systemctl stop clickhouse-server.service
[root@localhost log]# systemctl start clickhouse-server.service
尝试使用密码登录:
clickhouse-client -h 192.168.1.134 -m -u default --password clickhouse123 localhost :) select version(); SELECT version() Query id: 31dc8e72-443c-431b-a505-954e3b9f7666 ┌─version()─┐ 1. │ 24.8.11.5 │ └───────────┘ 1 row in set. Elapsed: 0.002 sec.
10.确保默认账号有创建其他用户的权限
more /etc/clickhouse-server/users.xml
确保该栏目设置的值为1,之前版本默认是0的
<access_management>1</access_management>
标签:8.5,root,pid,server,clickhouse,24.11,rpm,localhost From: https://www.cnblogs.com/hxlasky/p/18676651