環境
主機名 | ip | zookeeper端口 | clickhouse端口 | node名 | 分片組-副本 |
ck-1 | 192.168.2.100 | 2181/2888/3888 | 8123/9000/9004/9005/9009/8001 | node6 | shard3-replica2 |
8124/9001/9104/9105/9010/8002 | node1 | shard1-replica1 | |||
ck-2 | 192.168.2.101 | 2181/2888/3888 | 8123/9000/9004/9005/9009/8001 | node4 | shard1-replica2 |
8124/9001/9104/9105/9010/8002 | node2 | shard2-replica1 | |||
ck-3 | 192.168.2.102 | 2181/2888/3888 | 8123/9000/9004/9005/9009/8001 | node5 | shard2-replica2 |
8124/9001/9104/9105/9010/8002 | node3 | shard3-replica1 |
架構圖
架構模式
部署路徑
/data/clickhouse/shard3-replica2/users.xml
/data/clickhouse/shard3-replica2/config.xml
/data/clickhouse/shard3-replica2/logs/clickhouse-server.log
/data/clickhouse/shard3-replica2/logs/clickhouse-server.err.log
/data/clickhouse/shard3-replica2/data/
/data/clickhouse/shard3-replica2/tmp/
/data/clickhouse/shard3-replica2/user_files/
/data/clickhouse/shard3-replica2/access/
/data/clickhouse/shard3-replica2/format_schemas/
1、下載下傳安裝包
添加各節點hosts
檢視CPU是否支援SSE 4.2指令
grep -q sse4_2 /proc/cpuinfo && echo "SSE 4.2 supported" || echo "SSE 4.2 not supported"
下載下傳位址:
clickhouse-client-21.7.4.18-2.noarch.rpm
clickhouse-common-static-21.7.4.18-2.x86_64.rpm
clickhouse-server-21.7.4.18-2.noarch.rpm
yum install -y libxml2-devel expat-devel libicu-devel unixODBC libicudata
rpm -ivh clickhouse-*
或者通過yum安裝最新穩定版
yum -y install yum-utils
rpm --import https://repo.clickhouse.tech/CLICKHOUSE-KEY.GPG
yum-config-manager --add-repo https://repo.clickhouse.tech/rpm/stable/x86_64
yum -y install clickhouse-server clickhouse-client
2、配置系統啟動服務
系統服務檔案可自行編輯
3、建立資料相關目錄
ck-1
mkdir /data/clickhouse/{shard1-replica1,shard3-replica2} -p
ck-2
mkdir /data/clickhouse/{shard1-replica2,shard2-replica1} -p
ck-3
mkdir /data/clickhouse/{shard2-replica2,shard3-replica1} -p
4、修改配置檔案
config.xml、metrika.xml、users.xml
chown -R clickhouse:clickhouse /data/clickhouse
echo -n "123456" | sha256sum | tr -d '-'
5、啟動服務
ck-1
systemctl restart clickhouse-server-shard3-replica2
systemctl restart clickhouse-server-shard1-replica1
ck-2
systemctl restart clickhouse-server-shard1-replica2
systemctl restart clickhouse-server-shard2-replica1
ck-3
systemctl restart clickhouse-server-shard2-replica2
systemctl restart clickhouse-server-shard3-replica1
6、檢視叢集狀态
clickhouse-client --password 123456 --port 9001 --host 192.168.2.100
select * from system.clusters
叢集狀态1
SELECT policy_name, volume_name, disks FROM system.storage_policies;
SELECT name,path,formatReadableSize(free_space) AS free,formatReadableSize(total_space) AS total,formatReadableSize(keep_free_space) AS reserved FROM system.disks;
叢集狀态2
環境資訊
環境資訊
需要系統服務啟動腳本的可以私信我。。。。