Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.2.0 ready #298

Merged
merged 41 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
01cbca2
feat: remove ZkStatusPort, adapt to clickhouse-keeper
YenchangChan Jun 10, 2024
c9eb687
update frontend
YenchangChan Jun 10, 2024
69de22a
feat: create cluster default value
YenchangChan Jun 10, 2024
750da46
feat: do not check nodes when zk changed
YenchangChan Jun 10, 2024
1855c56
refactor: get replica status from system.replicas, not zookeeper
YenchangChan Jun 10, 2024
0d7d275
chore: remove useless code
YenchangChan Jun 10, 2024
828daef
feat: add schema-ui of clickhouse-keeper
YenchangChan Jun 11, 2024
0d104da
feat: clickhouse-keeper package management
YenchangChan Jun 11, 2024
eb45e8e
clickhouse-keeper is ready
YenchangChan Jun 22, 2024
5011d72
clickhouse-keeper with tgz
YenchangChan Jun 23, 2024
6b47c2d
feat: add comment
YenchangChan Jun 23, 2024
e65650a
feat: add api export to excel
YenchangChan Jun 24, 2024
f71913d
feat: rebalance by shardingkey with saveTemps, allowLossRate
YenchangChan Jun 24, 2024
157c176
perf: use 'check table' instead of query system.tables when create table
YenchangChan Jun 24, 2024
dc7aa74
perf: remove zooPath
YenchangChan Jun 24, 2024
0aebb9f
feat: export query result to csv
YenchangChan Jun 26, 2024
4c8f67f
feat: add CurClusterOnly when config
YenchangChan Jun 26, 2024
7790842
golint
YenchangChan Jun 27, 2024
ca3a70f
fix: rebalance by part issue
YenchangChan Jul 8, 2024
1c0db1f
[wip]metrics
YenchangChan Jul 16, 2024
92a5122
feat: add DMLOnLogic api
YenchangChan Jul 17, 2024
a530504
feat: do not allow import a cluster with logic witch has deployed clu…
YenchangChan Jul 18, 2024
64725b8
fix: DMLOnLogic issue
YenchangChan Jul 18, 2024
abc3687
fix: permission denied issue when access with userToken
YenchangChan Jul 18, 2024
27ceb57
fix: unfinished return success when alter TTL
YenchangChan Aug 11, 2024
914e223
feat: add cronjob to clear expired znodes
YenchangChan Aug 17, 2024
37a3be0
perf: check table issue
YenchangChan Aug 17, 2024
0b51a2c
update frontend
YenchangChan Aug 17, 2024
a0725f8
use metadata cache
YenchangChan Aug 22, 2024
1148d15
do not remove block_number znodes, which will cause transaction faile…
YenchangChan Aug 24, 2024
a583b1d
refactor: ckmanctl command
YenchangChan Aug 25, 2024
db6af9c
add query cache
YenchangChan Aug 25, 2024
70f742a
cluster settings issue
YenchangChan Aug 25, 2024
dbd095c
fix: CurClusterOnly cause logic cluster loss
YenchangChan Aug 26, 2024
2c47c46
fix: restart cluster failed when deployed by tgz
YenchangChan Aug 28, 2024
7470156
fix: get partitions min_time and max_time issue
YenchangChan Sep 14, 2024
682fcb2
fix: loss http_port when deploy cluster
YenchangChan Sep 20, 2024
b9f1485
perfect GetReplicaQueueZnodes
YenchangChan Sep 20, 2024
82b4193
feat: do not return error when zookeeper offline
YenchangChan Oct 13, 2024
f6e5c42
feat: tableLists add empty database
YenchangChan Oct 13, 2024
1888f68
update frontend
YenchangChan Oct 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ckmanpasswd
migrate
znodefix
znode_count
cmd/ckmanctl/ckmanctl
pkged.go
static/dist/
coverage.xml
Expand Down
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ FROM debian:stable-slim
RUN mkdir -p /etc/ckman && cd /etc/ckman && \
mkdir bin run logs conf package
ADD ./ckman /etc/ckman/bin/ckman
ADD ./migrate /etc/ckman/bin/migrate
ADD ./ckmanpasswd /etc/ckman/bin/ckmanpasswd
ADD ./znodefix /etc/ckman/bin/znodefix
ADD ./znode_count /etc/ckman/bin/znode_count
ADD ./cmd/ckmanctl/ckmanctl /etc/ckman/bin/ckmanctl
ADD ./README.md /etc/ckman/package/README.md
ADD ./resources/ckman.hjson /etc/ckman/conf
ADD ./resources/migrate.hjson /etc/ckman/conf
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# You can run command like: "docker build -f Dockerfile.test -t ckman-clickhouse:centos-7 ."
# the offical image is eoitek/ckman-clickhouse:centos-7, You can pull it from dockerhub.

#FROM centos:7
FROM ccr.ccs.tencentyun.com/library/centos:7
FROM centos:7
#FROM ccr.ccs.tencentyun.com/library/centos:7
WORKDIR /var/

RUN yum -y update && yum install -y openssh* \
Expand Down
17 changes: 9 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ GOARCH?=$(shell go env GOARCH)
TARNAME=${PKGDIR}-${VERSION}-${DATE}.${OS}.$(GOARCH).tar.gz
TAG?=$(shell date +%y%m%d)
LDFLAGS=-ldflags "-X main.BuildTimeStamp=${TIME} -X main.GitCommitHash=${REVISION} -X main.Version=${VERSION}"
GCFLAGS=-gcflags "all=-N -l"
PUB_KEY=$(shell cat resources/eoi_public_key.pub 2>/dev/null)
export GOPROXY=https://goproxy.cn,direct

Expand All @@ -28,10 +29,13 @@ frontend:
backend:
@rm -rf ${PKGFULLDIR}
go build ${LDFLAGS}
go build ${LDFLAGS} -o ckmanpasswd cmd/password/password.go
go build ${LDFLAGS} -o migrate cmd/migrate/migrate.go
go build ${LDFLAGS} -o znodefix cmd/znodefix/znodefix.go
go build ${LDFLAGS} -o znode_count cmd/znodecnt/znodecount.go
go build ${LDFLAGS} -o cmd/ckmanctl/ckmanctl cmd/ckmanctl/ckmanctl.go

.PHONY: debug
debug:
@rm -rf ${PKGFULLDIR}
go build ${GCFLAGS} ${LDFLAGS}
go build ${LDFLAGS} -o cmd/ckmanctl/ckmanctl cmd/ckmanctl/ckmanctl.go

.PHONY: pre
pre:
Expand Down Expand Up @@ -66,10 +70,7 @@ package:build
@rm -rf ${PKGFULLDIR_TMP}
@mkdir -p ${PKGFULLDIR_TMP}/bin ${PKGFULLDIR_TMP}/conf ${PKGFULLDIR_TMP}/run ${PKGFULLDIR_TMP}/logs ${PKGFULLDIR_TMP}/package ${PKGFULLDIR_TMP}/dbscript
@mv ${SHDIR}/ckman ${PKGFULLDIR_TMP}/bin
@mv ${SHDIR}/ckmanpasswd ${PKGFULLDIR_TMP}/bin
@mv ${SHDIR}/migrate ${PKGFULLDIR_TMP}/bin
@mv ${SHDIR}/znodefix ${PKGFULLDIR_TMP}/bin
@mv ${SHDIR}/znode_count ${PKGFULLDIR_TMP}/bin
@mv ${SHDIR}/cmd/ckmanctl/ckmanctl ${PKGFULLDIR_TMP}/binn
@cp ${SHDIR}/resources/start ${PKGFULLDIR_TMP}/bin
@cp ${SHDIR}/resources/stop ${PKGFULLDIR_TMP}/bin
@cp ${SHDIR}/resources/yaml2json.${GOARCH} ${PKGFULLDIR_TMP}/bin/yaml2json
Expand Down
26 changes: 26 additions & 0 deletions ckconfig/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func root(conf *model.CKManClickHouseConfig, ipv6Enable bool) map[string]interfa
output["default_replica_path"] = "/clickhouse/tables/{cluster}/{database}/{table}/{shard}"
output["default_replica_name"] = "{replica}"
output["tcp_port"] = conf.Port
output["http_port"] = conf.HttpPort
if ipv6Enable {
output["listen_host"] = "::"
} else {
Expand Down Expand Up @@ -173,6 +174,25 @@ func expert(exp map[string]string) map[string]interface{} {
return common.ConvertMapping(output)
}

func query_cache() map[string]interface{} {
output := make(map[string]interface{})
output["query_cache"] = map[string]interface{}{
"max_size_in_bytes": 1073741824,
"max_entries": 1024,
"max_entry_size_in_bytes": 1048576,
"max_entry_size_in_rows": 30000000,
}
return output
}
func merge_tree_metadata_cache() map[string]interface{} {
output := make(map[string]interface{})
output["merge_tree_metadata_cache"] = map[string]interface{}{
"lru_cache_size": 1073741824,
"continue_if_corrupted": true,
}
return output
}

func GenerateCustomXML(filename string, conf *model.CKManClickHouseConfig, ipv6Enable bool) (string, error) {
rootTag := "yandex"
if common.CompareClickHouseVersion(conf.Version, "22.x") >= 0 {
Expand All @@ -185,6 +205,12 @@ func GenerateCustomXML(filename string, conf *model.CKManClickHouseConfig, ipv6E
mergo.Merge(&custom, system_log())
mergo.Merge(&custom, distributed_ddl(conf.Cluster))
mergo.Merge(&custom, prometheus())
if common.CompareClickHouseVersion(conf.Version, "22.4.x") >= 0 {
mergo.Merge(&custom, merge_tree_metadata_cache())
}
if common.CompareClickHouseVersion(conf.Version, "23.4.x") >= 0 {
mergo.Merge(&custom, query_cache())
}
storage_configuration, backups := storage(conf.Storage)
mergo.Merge(&custom, storage_configuration)
mergo.Merge(&custom, backups)
Expand Down
4 changes: 4 additions & 0 deletions ckconfig/custom_fake.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
<replicated_fetches_http_receive_timeout>0</replicated_fetches_http_receive_timeout>
<replicated_fetches_http_send_timeout>0</replicated_fetches_http_send_timeout>
</merge_tree>
<merge_tree_metadata_cache>
<continue_if_corrupted>true</continue_if_corrupted>
<lru_cache_size>1073741824</lru_cache_size>
</merge_tree_metadata_cache>
<metric_log>
<flush_interval_milliseconds>30000</flush_interval_milliseconds>
<partition_by>toYYYYMMDD(event_date)</partition_by>
Expand Down
2 changes: 1 addition & 1 deletion ckconfig/custom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestGenerateCustomXML(t *testing.T) {
Cwd: "/home/eoi/clickhouse",
NeedSudo: false,
Path: "/data01/",
Version: "22.3.3.44",
Version: "23.3.3.44",
}
_, err := GenerateCustomXML("custom_fake.xml", conf, true)
assert.Nil(t, err)
Expand Down
93 changes: 93 additions & 0 deletions ckconfig/keeper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package ckconfig

import (
"path"

"github.com/housepower/ckman/common"
"github.com/housepower/ckman/model"
"github.com/imdario/mergo"
)

func keeper_root(ipv6Enable bool) map[string]interface{} {
output := make(map[string]interface{})
if ipv6Enable {
output["listen_host"] = "::"
} else {
output["listen_host"] = "0.0.0.0"
}
output["max_connections"] = 4096
return output
}

func keeper_server(conf *model.CKManClickHouseConfig, ipv6Enable bool, idx int) map[string]interface{} {
output := keeper_root(ipv6Enable)
output["logger"] = keeper_logger(conf)
keeper_server := make(map[string]interface{})
mergo.Merge(&keeper_server, conf.KeeperConf.Expert)
keeper_server["tcp_port"] = conf.KeeperConf.TcpPort
keeper_server["server_id"] = idx
keeper_server["log_storage_path"] = conf.KeeperConf.LogPath + "clickhouse/coordination/logs"
keeper_server["snapshot_storage_path"] = conf.KeeperConf.SnapshotPath + "clickhouse/coordination/snapshots"
keeper_server["coordination_settings"] = coordination_settings(conf.KeeperConf.Coordination)
keeper_server["raft_configuration"] = raft_configuration(conf.KeeperConf)
output["keeper_server"] = keeper_server
return output
}

// https://github.com/ClickHouse/ClickHouse/blob/master/src/Coordination/CoordinationSettings.h
func coordination_settings(coordination model.Coordination) map[string]interface{} {
output := make(map[string]interface{})
mergo.Merge(&output, coordination.Expert)
output["operation_timeout_ms"] = coordination.OperationTimeoutMs
output["session_timeout_ms"] = coordination.SessionTimeoutMs
if coordination.ForceSync {
output["force_sync"] = "true"
} else {
output["force_sync"] = "false"
}
if coordination.AutoForwarding {
output["auto_forwarding"] = "true"
} else {
output["auto_forwarding"] = "false"
}
return output
}

func keeper_logger(conf *model.CKManClickHouseConfig) map[string]interface{} {
output := make(map[string]interface{})
output["level"] = "debug"
output["size"] = "1000M"
output["count"] = 10
if !conf.NeedSudo {
output["log"] = path.Join(conf.Cwd, "log", "clickhouse-keeper", "clickhouse-keeper.log")
output["errorlog"] = path.Join(conf.Cwd, "log", "clickhouse-keeper", "clickhouse-keeper.err.log")
}
return output

}

func raft_configuration(conf *model.KeeperConf) []map[string]interface{} {
var outputs []map[string]interface{}
for idx, node := range conf.KeeperNodes {
output := make(map[string]interface{})
output["server"] = map[string]interface{}{
"id": idx + 1,
"hostname": node,
"port": conf.RaftPort,
}
outputs = append(outputs, output)
}
return outputs
}

func GenerateKeeperXML(filename string, conf *model.CKManClickHouseConfig, ipv6Enable bool, idx int) (string, error) {
xml := common.NewXmlFile(filename)
rootTag := "clickhouse"
xml.Begin(rootTag)
xml.Merge(keeper_server(conf, ipv6Enable, idx))
xml.End(rootTag)
if err := xml.Dump(); err != nil {
return filename, err
}
return filename, nil
}
37 changes: 37 additions & 0 deletions ckconfig/keeper_fake.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<clickhouse>
<keeper_server>
<coordination_settings>
<auto_forwarding>false</auto_forwarding>
<force_sync>true</force_sync>
<operation_timeout_ms>10000</operation_timeout_ms>
<raft_log_level>Information</raft_log_level>
<session_timeout_ms>30000</session_timeout_ms>
</coordination_settings>
<log_storage_path>/var/lib/clickhouse/coordination/log</log_storage_path>
<raft_configuration>
<server>
<hostname>192.168.101.102</hostname>
<id>1</id>
<port>9181</port>
</server>
<server>
<hostname>192.168.101.105</hostname>
<id>2</id>
<port>9181</port>
</server>
<server>
<hostname>192.168.101.107</hostname>
<id>3</id>
<port>9181</port>
</server>
</raft_configuration>
<server_id>2</server_id>
<snapshot_storage_path>/var/lib/clickhouse/coordination/snapshots</snapshot_storage_path>
<tcp_port>9181</tcp_port>
</keeper_server>
<listen_host>::</listen_host>
<logger>
<level>debug</level>
</logger>
<max_connections>4096</max_connections>
</clickhouse>
27 changes: 27 additions & 0 deletions ckconfig/keeper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ckconfig

import (
"testing"

"github.com/housepower/ckman/model"
"github.com/stretchr/testify/assert"
)

func TestGenerateKeeperXML(t *testing.T) {
conf := model.CKManClickHouseConfig{
KeeperConf: &model.KeeperConf{
KeeperNodes: []string{"192.168.101.102", "192.168.101.105", "192.168.101.107"},
TcpPort: 9181,
RaftPort: 9234,
LogPath: "/var/lib/clickhouse/coordination/log",
SnapshotPath: "/var/lib/clickhouse/coordination/snapshots",
Coordination: model.Coordination{
OperationTimeoutMs: 10000,
SessionTimeoutMs: 30000,
ForceSync: true,
},
},
}
_, err := GenerateKeeperXML("keeper_fake.xml", &conf, true, 2)
assert.Nil(t, err)
}
25 changes: 4 additions & 21 deletions ckconfig/metrika.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ckconfig
import (
"github.com/housepower/ckman/common"
"github.com/housepower/ckman/model"
"github.com/housepower/ckman/service/zookeeper"
)

func GenerateMetrikaXML(filename string, conf *model.CKManClickHouseConfig) (string, error) {
Expand Down Expand Up @@ -40,10 +41,11 @@ func GenZookeeperMetrika(indent int, conf *model.CKManClickHouseConfig) string {
xml := common.NewXmlFile("")
xml.SetIndent(indent)
xml.Begin("zookeeper")
for index, zk := range conf.ZkNodes {
nodes, port := zookeeper.GetZkInfo(conf)
for index, zk := range nodes {
xml.BeginwithAttr("node", []common.XMLAttr{{Key: "index", Value: index + 1}})
xml.Write("host", zk)
xml.Write("port", conf.ZkPort)
xml.Write("port", port)
xml.End("node")
}
xml.End("zookeeper")
Expand All @@ -59,25 +61,6 @@ func GenLocalMetrika(indent int, conf *model.CKManClickHouseConfig) string {
secret = false
}
if secret {
xml.Comment(`Inter-server per-cluster secret for Distributed queries
default: no secret (no authentication will be performed)

If set, then Distributed queries will be validated on shards, so at least:
- such cluster should exist on the shard,
- such cluster should have the same secret.

And also (and which is more important), the initial_user will
be used as current user for the query.

Right now the protocol is pretty simple and it only takes into account:
- cluster name
- query

Also it will be nice if the following will be implemented:
- source hostname (see interserver_http_host), but then it will depends from DNS,
it can use IP address instead, but then the you need to get correct on the initiator node.
- target hostname / ip address (same notes as for source hostname)
- time-based security tokens`)
xml.Write("secret", "foo")
}
for _, shard := range conf.Shards {
Expand Down
Loading
Loading