\前言**
本文档为基于ClickHouse-Keeper搭建集群,和单机版本安装步骤差不多,差异在于在config.xml中增加一段配置,以及增加了metrika.xml配置文件,安装过程中需要在防火墙中多开几个端口号。以下为基于单机版本ClickHouse安装步骤增加了集群的内容,集群内容为标黄色字体。
多节点配置文件样例SVN地址:https://192.168.60.125/svn/非银绩效分析/06_实施/01_中信XT/部署/clickhouse/集群版本配置_clickhouse-keeper/
\clickhouse安装与启动**
操作步骤与用户 | 操作内容 |
---|---|
创建用户/root | 1.创建用户 useradd clickhouse |
解压安装包/root | 1. 上传安装包及单机配置文件到/home/clickhouseSvn路径:https://192.168.60.125/svn/非银绩效分析/06_实施/01_中信XT/部署/clickhouse1. 解压安装包 (clickhouse-client-22.3.6.5.tar.gz, clickhouse-common-static-22.3.6.5.tar.gz,clickhouse-server-22.3.6.5.tar.gz) cd /home/clickhouse tar -zxvf clickhouse-client-22.3.6.5-amd64.tgztar -zxvf clickhouse-common-static-22.3.6.5-amd64.tgztar -zxvf clickhouse-server-22.3.6.5-amd64.tgz |
安装列式数据库/root | 1.安装公共包 ./clickhouse-common-static-22.3.6.5/install/doinst.sh 2.安装服务端./clickhouse-server-22.3.6.5/install/doinst.sh 输入 cebrisk 输入 N 安装服务端成功 3. 安装客户端 ./clickhouse-client-22.3.6.5/install/doinst.sh |
防火墙增加端口配置/root | 1. 防火墙增加端口配置 firewall-cmd –add-port=8123/tcp –permanent firewall-cmd –add-port=9000/tcp –permanent firewall-cmd –add-port=9004/tcp –permanent 集群:下面是clickhouse-keeper集群配置需要放开的端口:firewall-cmd –add-port=9181/tcp –permanentfirewall-cmd –add-port=9234/tcp –permanentfirewall-cmd –add-port=9009/tcp –permanent 2. 重新加载防火墙配置 firewall-cmd –reload |
创建数据挂载目录/root | 1. 创建数据挂载目录 (根据实际硬盘挂载目录再调整) mkdir -p /大空间目录/ck1此处使用mkdir -p /data/clickhouse/ck1(实际情况调整) 2. 给目录赋权 chown clickhouse:clickhouse -R /大空间目录/ck1此处使用chown clickhouse:clickhouse -R /data/clickhouse/ck1查看storage.xml里配置的存储路径 修改config.xml中关于本机ip等配置 clickhouse-keeper集群相关:在config.xml中增加集群配置: 需要注意:1、集群中每个IP节点的config.xml中都需要增加这段配置,且每个文件中第53行server_id不能重复;2、从第65行开始,集群中有多少个节点就配置多少个server,比如样例中有三个节点,那么每个config.xml中65~87行是一样的。id和priority可以配自增的数字,IP改成对应的IP,端口号9234不用改;3、第95行要改成对应节点的IP地址;样例: <keeper_server> <tcp_port>9181</tcp_port> <server_id>1</server_id> <log_storage_path>/var/lib/clickhouse/coordination/log</log_storage_path> <snapshot_storage_path>/var/lib/clickhouse/coordination/snapshots</snapshot_storage_path> <coordination_settings> <operation_timeout_ms>5000</operation_timeout_ms> <session_timeout_ms>10000</session_timeout_ms> <snapshot_distance>75</snapshot_distance> <raft_logs_level>trace</raft_logs_level> </coordination_settings> <raft_configuration> |
启动服务,同步数据/root | 1.启动服务 clickhouse start 2.登录客户端 clickhouse-client -h 127.0.0.1 -u cebrisk –password cebrisk若遇到登录错误时可查看日志检查是否与以下命令有关,如果有关,则需执行以下命令openssl dhparam -out /etc/clickhouse-server/dhparam.pem 4096相关命令存在于config.xml中,可查看相关解决问题openssl req -subj “/CN=localhost” -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout /etc/clickhouse-server/server.key -out /etc/clickhouse-server/server.crt |
clickhouse-backup安装 | 0. cd /home/clickhouse1. tar -xf clickhouse-backup.tar 2. cd clickhouse-backup3. cp clickhouse-backup /usr/local/bin4. 验证: clickhouse-backup -v 5. 配置目录属主赋予clickhouse用户 chown clickhouse:clickhouse -R /usr/local/bin/clickhouse-backup 6. 添加配置文件到/etc/clickhouse-backup/config.yml。如果没有则创建目录及文件。注意账号密码是否需要修改 general: remote_storage: none backups_to_keep_local: 30 backups_to_keep_remote: 31clickhouse: username: cebrisk password: cebrisk host: localhost port: 9000 data_path: “/var/log/clickhouse-server/data” |
查看日志 | tail -200f /var/log/clickhouse-server/clickhouse-server.log |
导入数据库脚本 | clickhouse-client -h 127.0.0.1 -u cebrisk –password cebrisk –multiquery < /home/clickhouse/20200627_clickhouse单库基础数据.sql** 注意到数据库脚本已经内部创建数据库,可根据实际修改 |