@zhangyy
2021-01-06T14:13:26.000000Z
字数 8231
阅读 356
ClickHouse系列
系统:CentOS7.9x64主机名:cat /etc/hosts----192.168.100.11 node01.flyfish.cn192.168.100.12 node02.flyfish.cn192.168.100.13 node03.flyfish.cn192.168.100.14 node04.flyfish.cn192.168.100.15 node05.flyfish.cn192.168.100.16 node06.flyfish.cn192.168.100.17 node07.flyfish.cn192.168.100.18 node08.flyfish.cn----
系统语言:echo "export LANG=en_US.UTF8" >> ~/.bash_profilecat ~/.bash_profile

非强制执行步骤:---umount /mntmount /dev/cdrom /mntcd /etc/yum.repos.dmkdir bkmv *.repo bk/echo "[EL7-1]" > /etc/yum.repos.d/itpux.repoecho "name =Linux-7" >> /etc/yum.repos.d/itpux.repoecho "baseurl=file://mnt" >> /etc/yum.repos.d/itpux.repoecho "gpgcheck=0" >> /etc/yum.repos.d/itpux.repoecho "enabled=1" >> /etc/yum.repos.d/itpux.repo---yum install lvm2 -ypvcreate /dev/sdbvgcreate datavg /dev/sdblvcreate -n datalv -L 200000M datavgmkfs.ext4 /dev/datavg/datalvvi /etc/fstab/dev/sda1 / xfs defaults 0 0/dev/sda2 swap swap defaults 0 0/dev/datavg/datalv /clickhouse ext4 defaults,nobarrier,noatime 0 0nobarrier: 强制底层设备不需要刷新缓存noatime: 不记录资源硬盘的访问时间mkdir /clickhousemount /dev/datavg/datalv /clickhouse
创建clickhouse 的 存放 soft 目录mkdir /clickhouse/soft -p
创建安装用户:groupadd -g 60001 clickhouseuseradd -u 61001 -g clickhouse clickhousechown -R clickhouse:clickhouse /clickhousechmod -R 775 /clickhouseecho "clickhouse" | passwd --stdin clickhouse默认启动字符界面:systemctl set-default multi-user.target

设置clickhouse 的系统句柄数cat >> /etc/security/limits.conf << EOFroot soft nofile 1048576root hard nofile 1048576clickhouse soft nproc 1048576clickhouse hard nproc 1048576clickhouse soft nofile 1048576clickhouse hard nofile 1048576clickhouse soft stack 10240clickhouse hard stack 32768clickhouse hard memlock unlimitedclickhouse soft memlock unlimitedEOF

设置系统极限数cat >> /etc/sysctl.conf << EOFfs.aio-max-nr = 1048576fs.file-max = 6815744net.ipv4.ip_local_port_range = 10000 65535net.ipv4.tcp_mem = 786432 2097152 3145728net.ipv4.tcp_rmem = 4096 4096 16777216net.ipv4.tcp_wmem = 4096 4096 16777216vm.swappiness=1vm.min_free_kbytes=204800vm.overcommit_memory=0EOFsysctl -p
修改 系统时间:ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime关闭selinux 与 firewalld ,iptables 防火墙echo "SELINUX=disabled" > /etc/selinux/configecho "#SELINUXTYPE=targeted " >> /etc/selinux/configcat /etc/selinux/configsetenforce 0systemctl stop firewalld.servicesystemctl disable firewalld.service


关闭透明大页:cat /sys/kernel/mm/transparent_hugepage/defrag[always] madvise nevercat /sys/kernel/mm/transparent_hugepage/enabled[always] madvise nevervi /etc/rc.d/rc.localif test -f /sys/kernel/mm/transparent_hugepage/enabled; thenecho never > /sys/kernel/mm/transparent_hugepage/enabledfiif test -f /sys/kernel/mm/transparent_hugepage/defrag; thenecho never > /sys/kernel/mm/transparent_hugepage/defragfichmod +x /etc/rc.d/rc.local
参考官网:https://clickhouse.tech/#quick-start源码包安装:下载包: https://repo.clickhouse.tech/tgz/stable/----export LATEST_VERSION=$(curl -s https://repo.clickhouse.tech/tgz/stable/ | \grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | sort -V -r | head -n 1)curl -O https://repo.clickhouse.tech/tgz/stable/clickhouse-common-static-$LATEST_VERSION.tgzcurl -O https://repo.clickhouse.tech/tgz/stable/clickhouse-common-static-dbg-$LATEST_VERSION.tgzcurl -O https://repo.clickhouse.tech/tgz/stable/clickhouse-server-$LATEST_VERSION.tgzcurl -O https://repo.clickhouse.tech/tgz/stable/clickhouse-client-$LATEST_VERSION.tgztar -xzvf clickhouse-common-static-$LATEST_VERSION.tgzsudo clickhouse-common-static-$LATEST_VERSION/install/doinst.shtar -xzvf clickhouse-common-static-dbg-$LATEST_VERSION.tgzsudo clickhouse-common-static-dbg-$LATEST_VERSION/install/doinst.shtar -xzvf clickhouse-server-$LATEST_VERSION.tgzsudo clickhouse-server-$LATEST_VERSION/install/doinst.shsudo /etc/init.d/clickhouse-server starttar -xzvf clickhouse-client-$LATEST_VERSION.tgzsudo clickhouse-client-$LATEST_VERSION/install/doinst.sh----
新建安装目录:mkdir /clickhouse/appmkdir /clickhouse/datamkdir /clickhouse/logmkdir /clickhouse/etcmkdir /clickhouse/soft

cd /clickhouse/apptar zxvf /clickhouse/soft/clickhouse-common-static-20.12.2.1.tgzmv clickhouse-common-static-20.12.2.1/ clickhouse-common-statictar -zxvf /clickhouse/soft/clickhouse-common-static-dbg-20.12.2.1.tgztar -zxvf /clickhouse/soft/clickhouse-server-20.12.2.1.tgzmv clickhouse-common-static-dbg-20.12.2.1/ clickhouse-common-static-dbgmv clickhouse-server-20.12.2.1/ clickhouse-server


修改clickhouse-server 配置文件:vim clickhouse-server/install/doinst.sh-----CLICKHOUSE_DATADIR=${CLICKHOUSE_DATADIR:=/clickhouse/data}CLICKHOUSE_LOGDIR=${CLICKHOUSE_LOGDIR:=/clickhouse/log}-----

vim /clickhouse/app/clickhouse-server/etc/clickhouse-server/config.xml----<log>/clickhouse/log/clickhouse-server.log</log><errorlog>/clickhouse/log/clickhouse-server.err.log</errorlog>----<!-- Path to data directory, with trailing slash. --><path>/clickhouse/data</path>-----<!-- Path to temporary data for processing hard queries. --><tmp_path>/clickhouse/data/tmp/</tmp_path>----<!-- Directory with user provided files that are accessible by 'file' table function.--><user_files_path>/clickhouse/data/user_files/</user_files_path><format_schema_path>/clickhouse/data/format_schemas/</format_schema_path>------<local_directory><!-- Path to folder where users created by SQL commands are stored. --><path>/clickhouse/data/access/</path></local_directory>------修改 IP 地址监听:打开<listen_host>::</listen_host>----<! 设置时区为东八区--><timezone>Asia/Shanghai</timezone>-----vim /clickhouse/app/clickhouse-server/etc/clickhouse-server/users.xml----<max_memory_usage>80000000000</max_memory_usage><access_management>1</access_management> 打开----
cd /clickhouse/app----tar -zxvf /clickhouse/soft/clickhouse-client-20.12.2.1.tgzmv clickhouse-client-20.12.2.1/ clickhouse-client----

启动clickhouse:./clickhouse-common-static/install/doinst.sh./clickhouse-common-static-dbg/install/doinst.sh./clickhouse-server/install/doinst.sh./clickhouse-client/install/doinst.sh



cd /etc/ls -ld /etc/clickhouse-*生成clickhouse的 server 与 client 端

mv /etc/clickhouse-* /clickhouse/etc/ln -sf /clickhouse/etc/* .

检查参数:/clickhouse/etc/clickhouse-server/config.xml/clickhouse/etc/clickhouse-server/users.xml-----chown -R clickhouse:clickhouse /clickhousechmod -R 755 /clickhouse
clickhouse 启动脚本:vim /etc/systemd/system/clickhouse-server.service---[Unit]Description=ClickHouse Server (analytic DBMS for big data)Requires=network-online.targetAfter=network-online.target[Service]Type=simpleUser=clickhouseGroup=clickhouseRestart=alwaysRestartSec=30RuntimeDirectory=clickhouse-serverExecStart=/usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickhouse-server.pidLimitCORE=infinityLimitNOFILE=500000CapabilityBoundingSet=CAP_NET_ADMIN CAP_IPC_LOCK CAP_SYS_NICE[Install]WantedBy=multi-user.target---systemctl daemon-reloadsystemctl status clickhouse-serversystemctl start clickhouse-serversystemctl stop clickhouse-servernetstat -nultp |grep 9000


登录 clickhouseclickhouse-client

脚本启动:su - clickhousenohup clickhouse-server --config=/etc/clickhouse-server/config.xml &
cd /clickhouse/appvim clickhouse.sh----#!/bin/bashnohup clickhouse-server --config=/etc/clickhouse-server/config.xml &-----chmod 775 clickhouse.start/clickhouse/app/clickhouse.startclickhouse-client -h 192.168.100.11 --port 9000 --user default --password----




192.168.100.11:9200 的端口实例----配置 config.xml 文件cp -p /clickhouse/etc/clickhouse-server/config.xml /clickhouse/etc/clickhouse-server/config9200.xmlvim /clickhouse/etc/clickhouse-server/config9200.xml---<log>/clickhouse/log9200/clickhouse-server.log</log><errorlog>/clickhouse/log9200/clickhouse-server.err.log</errorlog><http_port>8224</http_port><tcp_port>9200</tcp_port><mysql_port>9204</mysql_port><interserver_http_port>9209</interserver_http_port><path>/clickhouse/data9200</path><tmp_path>/clickhouse/data9200/tmp/</tmp_path><user_files_path>/clickhouse/data9200/user_files/</user_files_path><access_control_path>/clickhouse/data9200/access/</access_control_path><format_schema_path>/clickhouse/data9200/format_schemas/</format_schema_path>
mkdir -p /clickhouse/data9200mkdir -p /clickhouse/log9200chown -R clickhouse:clickhouse /clickhouse/data9200chown -R clickhouse:clickhouse /clickhouse/log9200

启动clickhouse9200 实例:#!/bin/bashnohup clickhouse-server --config=/etc/clickhouse-server/config.xml &sleep 10nohup clickhouse-server --config=/etc/clickhouse-server/config9200.xml &su - clickhouseclickhouse-server --config=/etc/clickhouse-server/config9200.xmlclickhouse-client -h 192.168.100.11 --port 9200


