一、ClickHouse簡單介紹
什麼是ClickHouse?ClickHouse是一個用於聯機分析(OLAP)的列式資料庫管理系統(DBMS)。
具體概念可以參考官方文件中的介紹:https://clickhouse.tech/docs/zh/
二、ClickHouse特點以及業務價值(圖片可放大檢視)
(圖片可放大檢視)
(圖片可放大檢視)
三、CentOS7下搭建ClickHouse叢集1、基礎環境介紹三臺CentOS7.9伺服器(均可以訪問網際網路)
node1 192.168.31.121
node2 192.168.31.122
node3 192.168.31.123
(圖片可放大檢視)
2、利用指令碼搭建zookeeper+clickhouse叢集具體操作步驟
cd /optrz上傳clickhouse.zipunzip clickhouse.zip#所在節點執行對應的安裝指令碼#例如node1執行sh jdk_zookeeper_clickhouse_node1.sh sh jdk_zookeeper_clickhouse_node1.sh
(圖片可放大檢視)
jdk_zookeeper_clickhouse_node1.sh指令碼內容如下
以node1為例
[root@node1 opt]# cat jdk_zookeeper_clickhouse_node1.sh #!/bin/bash#wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo#sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo#wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo#yum clean all#yum makecacheecho "-----------基礎環境配置----------------"setenforce 0sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/configsystemctl disable firewalldsystemctl stop firewalldcat >> /etc/security/limits.conf << EOF* soft nofile 65536 * hard nofile 65536 * soft nproc 131072 * hard nproc 131072EOFcat >> /etc/security/limits.d/90-nproc.conf << EOF* soft nofile 65536* hard nofile 65536* soft nproc 131072* hard nproc 131072EOFcat >> /etc/hosts << EOF192.168.31.121 node1192.168.31.122 node2192.168.31.123 node3EOFcat > /etc/yum.repos.d/clickhouse.repo << EOF[repo.yandex.ru_clickhouse_rpm_stable_x86_64]name=clickhouse stablebaseurl=https://mirrors.tuna.tsinghua.edu.cn/clickhouse/rpm/stable/x86_64enabled=1EOFecho "-----------安裝JDK----------------"cd /optsleep 5rpm -ivh jdk-8u251-linux-x64.rpmecho "export JAVA_HOME=/usr/java/jdk1.8.0_251-amd64" >> /etc/profileecho "export PATH=\$PATH:\$JAVA_HOME/bin" >> /etc/profileecho "export CLASSPATH=.:\$JAVA_HOME/jre/lib:\$JAVA_HOME/lib:\$JAVA_HOME/lib/tools.jar" >> /etc/profileecho "-----------安裝zookeeper----------------"cd /opttar -zxf apache-zookeeper-3.6.2-bin.tar.gzmv apache-zookeeper-3.6.2-bin zookeepercd zookeepermkdir datacd confcp zoo_sample.cfg zoo.cfgsed -i "s#dataDir=/tmp/zookeeper#dataDir=/opt/zookeeper/data#g" zoo.cfgecho "server.1=node1:2888:3888" >> zoo.cfgecho "server.2=node2:2888:3888" >> zoo.cfgecho "server.3=node3:2888:3888" >> zoo.cfgecho 1 > /opt/zookeeper/data/myid#echo 2 > /opt/zookeeper/data/myid#echo 3 > /opt/zookeeper/data/myidecho "export PATH=\$PATH:/opt/zookeeper/bin" >> /etc/profile. /etc/profileecho "-----------安裝clickhouse---------------"sed -i "s/gpgcheck=1/gpgcheck=0/g" /etc/yum.conf yum install clickhouse-server clickhouse-client -y\cp -rf /opt/config_node1.xml /etc/clickhouse-server/config.xml#\cp -rf /opt/config_node2.xml /etc/clickhouse-server/config.xml#\cp -rf /opt/config_node3.xml /etc/clickhouse-server/config.xml\cp -rf /opt/users.xml /etc/clickhouse-server/mkdir -p /opt/clickhousechown -R clickhouse:clickhouse /opt/clickhouseecho "-----------啟動zookeeper---------------"zkServer.sh startsleep 2zkServer.sh statusecho "-----------啟動clickhouse---------------"systemctl enable clickhouse-server systemctl start clickhouse-server systemctl status clickhouse-server sleep 2echo "-----------clickhouse-client連線---------------"clickhouse-client --user=ck --password=clickhouse2021 -m --host=node1 --port=9000#clickhouse-client --user=ck --password=clickhouse2021 -m --host=node2 --port=9000#clickhouse-client --user=ck --password=clickhouse2021 -m --host=node3 --port=9000
(圖片可放大檢視)
其中 config.xml中如下地方均做了修改 如下圖所示
-- 1)、路徑均修改為/opt/clickhouse目錄
(圖片可放大檢視)
(圖片可放大檢視)
(圖片可放大檢視)
-- 2)、叢集<remote_server>配置,<zookeeper>配置,以及 <macros>配置修改
(圖片可放大檢視)
(圖片可放大檢視)
其中<macros>配置不同節點配置不同,注意區分
當然我這裡是三分片一副本的配置,可以根據自身實際環境進行修改
-- 3)、監聽地址修改為0.0.0.0
<listen_host>0.0.0.0</listen_host>
(圖片可放大檢視)
-- 4)、users.xml中新增ck使用者及密碼等配置
(圖片可放大檢視)
3、叢集狀態驗證在node1上
zkServer.sh statussystemctl status clickhouse-serverclickhouse-client --user=ck --password=clickhouse2021 -m --host=node1 --port=9000:)select * from system.clusters;
(圖片可放大檢視)
(圖片可放大檢視)
可以看到 cluster_clickhouse名稱的叢集資訊說明叢集搭建成功
clickhouse叢集的簡單搭建就介紹到這裡
最新評論