clickhouse单机版部署

\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 ls *.tar.gz \ xargs -n1 tar xzvf
安装列式数据库/root 1.安装公共包 ./clickhouse-common-static-22.3.6.5/install/doinst.sh 2.安装服务端./clickhouse-server-22.3.6.5/install/doinst.shimg 输入 cebriskimg 输入 N img安装服务端成功 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 2. 重新加载防火墙配置 firewall-cmd –reload
创建数据挂载目录/root 1. 创建数据挂载目录 (根据实际硬盘挂载目录再调整) mkdir -p /大空间目录/ck1此处使用mkdir -p /home/clickhouse/ck1(实际情况调整) 2. 给目录赋权 chown clickhouse:clickhouse -R /大空间目录/ck1此处使用chown clickhouse:clickhouse -R /home/clickhouse/ck1查看storage.xml里配置的存储路径img 修改config.xml中关于本机ip等配置 如果目录空间不够需要更换目录的话,执行以下(待定,命令尚不完善): img 3.复制配置文件(storage.xml需要先修改路径到大空间目录下) cp storage.xml /etc/clickhouse-server/config.d/storage.xml cp users.xml /etc/clickhouse-server/users.xmlcp config.xml /etc/clickhouse-server/config.xml 如果提示是否强制替换?输入 y:是 4.配置目录属主赋予clickhouse用户 chown clickhouse:clickhouse -R /etc/clickhouse-serverchown clickhouse:clickhouse -R /etc/clickhouse-client/chown clickhouse:clickhouse -R /home/clickhouse(修改到大空间目录)
启动服务,同步数据/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-backup chmod +x clickhouse-backup3. cp clickhouse-backup /usr/local/bin4. 验证: clickhouse-backup –vimg 5. 配置目录属主赋予clickhouse用户 chown clickhouse:clickhouse -R /usr/local/bin/clickhouse-backup 6. 添加配置文件到/etc/clickhouse-backup/config.yml。如果没有则创建目录及文件。img 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** 注意到数据库脚本已经内部创建数据库,可根据实际修改img