1、首先检查CPU是否支持SSE 4.2的命令:
[root@host101 mysql]# grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported"
SSE 4.2 supported ---是支持的
2、调整本地运行环境
修改Linux文件打开数限制
在 /etc/security/limits.conf 这个文件的末尾加入一下内容:
vi /etc/security/limits.conf* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
在 /etc/security/limits.d/90-nproc.conf 这个文件的末尾加入一下内容:
vi /etc/security/limits.d/90-nproc.conf* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
重启服务器之后生效,用 ulimit -n 或者 ulimit -a 查看设置结果
ulimit -n
ulimit -a
关闭selinux
修改 /etc/selinux/config 中的 SELINUX=disabled 后重启
vim /etc/selinux/config
SELINUX=disabled
3、安装
yum install yum-util -y
rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG
yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64
yum install clickhouse-server clickhouse-client -y
因为网络的原因,yum安装网络一直失败,
可以选择离线安装,先手动下载rpm包,下载到本地再上传到服务器
下载地址:
https://repo.clickhouse.tech/rpm/stable/x86_64
下载这三个文件
clickhouse-server-20.5.4.40-2.noarch.rpm
clickhouse-common-static-20.5.4.40-2.x86_64.rpm
clickhouse-client-20.5.4.40-2.noarch.rpm
安装
[root@host101 tmp]# rpm -ivh clickhouse-common-static-20.5.4.40-2.x86_64.rpm
Preparing... ################################# [100%] Updating / installing...
1:clickhouse-common-static-20.5.4.4################################# [100%]
[root@host101 tmp]# rpm -ivh clickhouse-client-20.5.4.40-2.noarch.rpm
Preparing... ################################# [100%]
Updating / installing...
1:clickhouse-client-20.5.4.40-2 ################################# [100%]
[root@host101 tmp]# rpm -ivh clickhouse-server-20.5.4.40-2.noarch.rpm
Preparing... ################################# [100%] Updating / installing...
1:clickhouse-server-20.5.4.40-2 ################################# [100%]
Created symlink from /etc/systemd/system/multi-user.target.wants/clickhouse-server.service to /etc/systemd/system/clickhouse-server.service. Path to data directory in /etc/clickhouse-server/config.xml: /var/lib/clickhouse/
[root@host101 tmp]# [root@host101 tmp]# service clickhouse-server start
Start clickhouse-server service: Path to data directory in /etc/clickhouse-server/config.xml: /var/lib/clickhouse/ DONE
[root@host101 tmp]# ps -ef|grep clickhouse
clickho+ 16150 1 14 23:39 ? 00:00:00 clickhouse-server --daemon --pid-file=/var/run/clickhouse-server/clickhouse-server.pid --config-file=/etc/clickhouse-server/config.xml root 16204 8491 0 23:39 pts/0 00:00:00 grep --color=auto clickhouse
4、配置文件主要参数说明及修改
参数文件位置:/etc/clickhouse-server/config.xml,主要参数如下:
1)日志文件位置:
<log>/var/log/clickhouse-server/clickhouse-server.log</log>
<errorlog>/var/log/clickhouse-server/clickhouse-server.err.log</errorlog>
2)http和tcp端口
<http_port>8123</http_port>
<tcp_port>9000</tcp_port>
3)数据文件路径
<path>/data/clickhouse/</path>
说明:可以根据部署要求等情况,修改路径,如果该目录不存在,需提前创建!
4)tmp目录(如果与实例1配置相同,可以用同一个,不需要修改)
<tmp_path>/data/clickhouse/tmp/</tmp_path>
说明:可以根据部署要求等情况,修改路径
5)监听的主机
<listen_host>::</listen_host>
说明:默认情况下该参数是被屏蔽掉的,需要放开!
6)集群内部通讯
<interserver_http_port>9009</interserver_http_port>
<interserver_http_host>192.168.11.11</interserver_http_host>
7)用户配置
将此段放在user中间
<ck_test> <password_sha256_hex>f2ed0119666d8dc99aa751869243a3324a722bbc5798369d0eb2912c60e114c8</password_sha256_hex>密码为密文密码
<networks incl="networks" replace="replace">
<ip>::/0</ip>
</networks>
<profile>default</profile>
<quota>default</quota>
<allow_databases>
<databases>default</databases>
</allow_databases>
</ck_test>
5、启动clickhouse
Systemctl restart clickhouse
Systemctl status clickhouse
6、远程登陆clickhouse数据库
clickhouse-client -u 用户名 -h ip --port 9001 --password 密码
官方不建议直接写明文密码,可以用以下命令生成密码
PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD";
echo -n "$PASSWORD" | sha256sum | tr -d '-'