k8s安装greptimedb
环境说明
类型 | 版本 |
---|---|
k8s(3节点) | 1.26.6 |
8c16g | 安装时,限制到1c1g安装,总的资源也不足 |
变配到16c24g |
在线安装
部署etcd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22[root@node3 greptime]# helm upgrade \
--install etcd oci://greptime-registry.cn-hangzhou.cr.aliyuncs.com/charts/etcd \
--create-namespace \
--version 11.3.4 \
-n etcd-cluster --values etcd-values.yaml
[root@node3 greptime]# kubectl get pod -n etcd-cluster
NAME READY STATUS RESTARTS AGE
etcd-0 1/1 Running 0 79s
etcd-1 1/1 Running 0 79s
etcd-2 1/1 Running 0 79s
[root@node3 greptime]# kubectl -n etcd-cluster exec etcd-0 -- etcdctl \
--endpoints=etcd-0.etcd-headless.etcd-cluster:2379,etcd-1.etcd-headless.etcd-cluster:2379,etcd-2.etcd-headless.etcd-cluster:2379 \
endpoint status -w table
+--------------------------------------------------------------------------------+
| Endpoint | ID | Ver | DB | Ldr | Lrn | Trm | Idx | App | Err |
|----------------|-----------|-------|-------|-----|-----|-----|-----|-----|-----|
| etcd-0...:2379 | 680910... | 3.5.21 | 20kB | ✘ | ✘ | 2 | 38 | 38 | |
| etcd-1...:2379 | d6980d... | 3.5.21 | 20kB | ✔ | ✘ | 2 | 38 | 38 | |
| etcd-2...:2379 | 12664f... | 3.5.21 | 20kB | ✘ | ✘ | 2 | 38 | 38 | |
+--------------------------------------------------------------------------------+部署minio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15[root@node3 greptime]# helm upgrade \
--install minio oci://greptime-registry.cn-hangzhou.cr.aliyuncs.com/charts/minio \
--create-namespace \
--version 16.0.10 \
-n minio \
--values minio-values.yaml
[root@node3 greptime]# kubectl get pod -n minio
NAME READY STATUS RESTARTS AGE
minio-0 1/1 Running 0 44s
minio-1 1/1 Running 0 44s
minio-2 1/1 Running 0 44s
minio-3 1/1 Running 0 44s
# 暴露端口
[root@node3 greptime]# kubectl apply -f minio-NodePort.yaml登录http://192.168.10.213:30393/login,账号密码:greptimedbadmin/greptimedbadmin
创建bucket名称为:
greptimedb-bucket
创建Create Access Keys得到key=
JffCiPPRg1CfcI4li582
,sec=IippU4XmqqIQBBPcROUi2paeABFbNwhfl6UXgOIM
部署GreptimeDB Operator
1
2
3
4
5
6
7
8
9[root@node3 greptime]# helm upgrade --install \
greptimedb-operator oci://greptime-registry.cn-hangzhou.cr.aliyuncs.com/charts/greptimedb-operator \
--version 0.2.21 \
--namespace greptimedb-admin \
--create-namespace \
--values greptimedb-operator-values.yaml
[root@node3 greptime]# kubectl get pod -n greptimedb-admin
NAME READY STATUS RESTARTS AGE
greptimedb-operator-d656cb5c-zkdq9 1/1 Running 0 43s部署db集群
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28[root@node3 greptime]# kubectl create namespace greptimedb
namespace/greptimedb created
# 创建一个secrets配置Secret: greptimedb / image-pull-secret
[root@node3 greptime]# kubectl create secret docker-registry image-pull-secret \
-n greptimedb \
--docker-server=https://greptime-registry.cn-hangzhou.cr.aliyuncs.com \
--docker-username=fxkjtkjj@1826388469660986 \
--docker-password=1P7a9v7M22
#安装greptimedb,注意k8s资源,8c16g跑不起,缺cpu,变配虚拟机到16c24g
[root@node3 greptime]# helm upgrade --install greptimedb \
--create-namespace \
oci://greptime-registry.cn-hangzhou.cr.aliyuncs.com/charts/greptimedb-cluster \
--version 0.3.18 \
-n greptimedb \
--values greptimedb-cluster-values.yaml
[root@node3 greptime]# kubectl get po -n greptimedb
NAME READY STATUS RESTARTS AGE
greptimedb-datanode-0 2/2 Running 0 2m18s
greptimedb-datanode-1 2/2 Running 0 2m18s
greptimedb-datanode-2 2/2 Running 0 2m18s
greptimedb-flownode-0 2/2 Running 0 2m1s
greptimedb-frontend-5468844cd-br4sc 2/2 Running 0 2m7s
greptimedb-frontend-5468844cd-nrhf6 2/2 Running 0 2m7s
greptimedb-frontend-5468844cd-swbxv 2/2 Running 0 2m7s
greptimedb-meta-5b74964-6m7nt 2/2 Running 3 (2m54s ago) 20m
greptimedb-meta-5b74964-7sg9p 2/2 Running 2 (2m41s ago) 20m
greptimedb-meta-5b74964-gxqn8 2/2 Running 4 (2m50s ago) 20m
greptimedb-monitor-standalone-0 1/1 Running 1 (9m44s ago) 20m部署
Dashboard
1
2
3
4
5
6
7
8
9
10
11[root@node3 greptime]# helm upgrade --install enterprise-dashboard \
--create-namespace \
oci://greptime-registry.cn-hangzhou.cr.aliyuncs.com/charts/enterprise-dashboard \
-n dashboard \
--version 0.1.1 \
--values dashboard-values.yaml
[root@node3 greptime]# kubectl get pod -n dashboard
NAME READY STATUS RESTARTS AGE
enterprise-dashboard-7d75cbff97-q7t87 1/1 Running 0 104s
# 暴露端口
[root@node3 greptime]# kubectl apply -f dashboard-NodePort.yaml验证,也可以在
dashboard
里面查询1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52# 将 Kubernetes 集群中服务的 4002 端口映射到了本地机器的 4002 端口
[root@node3 greptime]# kubectl port-forward svc/greptimedb-frontend 4002:4002 -n greptimedb > connections.out &
[2] 38905
[1] Exit 127 connections.out
[root@node3 greptime]# cat connections.out
Forwarding from 127.0.0.1:4002 -> 4002
Forwarding from [::1]:4002 -> 4002
# 安装工具
[root@node3 greptime]# yum install -y mysql
# 测试连接
[root@node3 greptime]# mysql -h 127.0.0.1 -P 4002
mysql>
CREATE TABLE monitor (
host STRING,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP() TIME INDEX,
cpu FLOAT64 DEFAULT 0,
memory FLOAT64,
PRIMARY KEY(host)
);
Query OK, 0 rows affected (0.29 sec)
mysql>
INSERT INTO monitor
VALUES
("127.0.0.1", 1702433141000, 0.5, 0.2),
("127.0.0.2", 1702433141000, 0.3, 0.1),
("127.0.0.1", 1702433146000, 0.3, 0.2),
("127.0.0.2", 1702433146000, 0.2, 0.4),
("127.0.0.1", 1702433151000, 0.4, 0.3),
("127.0.0.2", 1702433151000, 0.2, 0.4);
6 rows in set (0.01 sec)
mysql> show tables;
+---------+
| Tables |
+---------+
| monitor |
| numbers |
+---------+
2 rows in set (0.05 sec)
mysql> select * from monitor;
+-----------+---------------------+------+--------+
| host | ts | cpu | memory |
+-----------+---------------------+------+--------+
| 127.0.0.1 | 2023-12-13 02:05:41 | 0.5 | 0.2 |
| 127.0.0.1 | 2023-12-13 02:05:46 | 0.3 | 0.2 |
| 127.0.0.1 | 2023-12-13 02:05:51 | 0.4 | 0.3 |
| 127.0.0.2 | 2023-12-13 02:05:41 | 0.3 | 0.1 |
| 127.0.0.2 | 2023-12-13 02:05:46 | 0.2 | 0.4 |
| 127.0.0.2 | 2023-12-13 02:05:51 | 0.2 | 0.4 |
+-----------+---------------------+------+--------+
6 rows in set (0.04 sec)
相关配置文件
etcd-values.yaml
1 | global: |
minio-values.yaml
1 | global: |
minio-NodePort.yaml
1 | apiVersion: v1 |
greptimedb-operator-values.yaml
1 | image: |
greptimedb-cluster-values.yaml
缩减了资源,对主机进行了编配
1 | image: |
dashboard-values.yaml
1 | replicaCount: 1 |
dashboard-NodePort.yaml
1 | apiVersion: v1 |