kind+tidb

官网介绍:在 Kubernetes 上快速上手 TiDB | PingCAP 文档中心

下面是具体细节:

一、安装

1.安装kind,一定要使用最新版本!!!

kind官网:kind -- Quick Start

复制代码
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.18.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind

2.安装docker

更换国内源

安装依赖

复制代码
sudo apt-get install apt-transport-https ca-certificates software-properties-common curl

安装阿里源gpg密钥

复制代码
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
 
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

安装Docker-ce(社区版)

复制代码
sudo apt-get update
sudo apt-get install docker-ce

测试

复制代码
sudo docker run hello-world

3.安装kubelet

复制代码
snap install kubectl --classic
 
# 查看kubectl版本
kubectl version --client

4.安装helm,官网:Helm | Installing Helm

复制代码
wget https://get.helm.sh/helm-v3.11.3-linux-amd64.tar.gz
tar -zxvf helm-v3.0.0-linux-amd64.tar.gz
mv linux-amd64/helm /usr/local/bin/helm

二、操作,具体可参考tidb官网在 Kubernetes 上快速上手 TiDB | PingCAP 文档中心

复制代码
#安装 TiDB Operator CRDs
kubectl create -f https://raw.githubusercontent.com/pingcap/tidb-operator/v1.4.4/manifests/crd.yaml
#安装 Helm 3 并使用 Helm 3 部署 TiDB Operator。
helm repo add pingcap https://charts.pingcap.org/
#为 TiDB Operator 创建一个命名空间,使用阿里云上的镜像。
helm install --namespace tidb-admin tidb-operator pingcap/tidb-operator --version v1.4.4 \
    --set operatorImage=registry.cn-beijing.aliyuncs.com/tidb/tidb-operator:v1.4.4 \
    --set tidbBackupManagerImage=registry.cn-beijing.aliyuncs.com/tidb/tidb-backup-manager:v1.4.4 \
    --set scheduler.kubeSchedulerImageName=registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler
#检查 TiDB Operator 组件是否正常运行起来:等待到都是running情况
kubectl get pods --namespace tidb-admin -l app.kubernetes.io/instance=tidb-operator
#部署 TiDB 集群
kubectl create namespace tidb-cluster && \
    kubectl -n tidb-cluster apply -f https://raw.githubusercontent.com/pingcap/tidb-operator/v1.4.4/examples/basic-cn/tidb-cluster.yaml
#部署独立的 TiDB Dashboard
kubectl -n tidb-cluster apply -f https://raw.githubusercontent.com/pingcap/tidb-operator/v1.4.4/examples/basic-cn/tidb-dashboard.yaml
#查看POD运行状态,等待都是running状态:
watch kubectl get po -n tidb-cluster
#获取 tidb-cluster 命名空间中的服务列表:
kubectl get svc -n tidb-cluster
#使用以下命令转发本地端口到集群
kubectl port-forward -n tidb-cluster svc/basic-tidb 14000:4000 > pf14000.out &
#连接tidb
mysql --comments -h 127.0.0.1 -P 14000 -u root
#暴露grafana端口
kubectl port-forward -n tidb-cluster svc/basic-grafana 3000 > pf3000.out &
#通过http://localhost:3000访问,admin admin
#暴露tidb dashboard
kubectl port-forward -n tidb-cluster svc/basic-tidb-dashboard-exposed 12333 > pf12333.out &
#通过 http://localhost:12333 访问,无密码

遇到坑:

1.basic-tidb-0 一直启动失败 :CrashLoopBackOff

去了tidb社区提问:basic-tidb-0 一直启动失败 :CrashLoopBackOff - TiDB 的问答社区

复制代码
kubectl logs -n tidb-cluster -f basic-tidb-0 -c tidb 执行结果:
start tidb-server ...
/tidb-server --store=tikv --advertise-address=basic-tidb-0.basic-tidb-peer.tidb-cluster.svc --host=0.0.0.0 --path=basic-pd:2379 --config=/etc/tidb/tidb.toml
--log-slow-query=/var/log/tidb/slowlog
[2023/04/24 01:34:12.357 +00:00] [INFO] [cpuprofile.go:113] ["parallel cpu profiler started"]
[2023/04/24 01:34:12.357 +00:00] [FATAL] [terror.go:300] ["unexpected error"] [error="path "/docker/2e800829730d53f792c9ac0b32a64ff153094e9b7df0208d2bc9a14d31f4526b" is not a descendant of mount point root "/docker/2e800829730d53f792c9ac0b32a64ff153094e9b7df0208d2bc9a14d31f4526b/kubelet" and cannot be exposed from "/sys/fs/cgroup/rdma/kubelet""] [stack="github.com/pingcap/tidb/parser/terror.MustNil\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/parser/terror/terror.go:300\nmain.setGlobalVars\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/tidb-server/main.go:615\nmain.main\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/tidb-server/main.go:208\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:250"] [stack="github.com/pingcap/tidb/parser/terror.MustNil\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/parser/terror/terror.go:300\nmain.setGlobalVars\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/tidb-server/main.go:615\nmain.main\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/tidb-server/main.go:208\nruntime.main\n\t/usr/local/go/src/runtime/proc.go:250"]

解决办法:将kind从0.10升级到最新版本1.8版本,重新开始操作

复制代码
kind delete cluster
升级kind
然后重新操作

2.Temporary failure in name resolution(域名解析暂时失败)

vm连接网络来回切换下,或者重启下虚拟机,暂时原因还没找到

相关推荐
退役小学生呀9 天前
三、kubectl使用详解
云原生·容器·kubernetes·k8s
程序员小潘10 天前
Kubernetes多容器Pod实战
云原生·容器·kubernetes
奔跑的蜗牛AZ10 天前
TiDB 字符串行转列与 JSON 数据查询优化知识笔记
笔记·json·tidb
编码如写诗10 天前
【信创-k8s】银河麒麟V10国防版+鲲鹏/飞腾(arm64架构)在线/离线部署k8s1.30+kubesphere
容器·架构·kubernetes
ZVAyIVqt0UFji10 天前
K8s集群多租户管理
java·linux·docker·容器·kubernetes
CloudPilotAI11 天前
弹性伸缩从可用到好用,中间差了这 8 个关键点——CloudPilot AI 如何补齐?
容器·kubernetes·云计算·云成本
云上小朱11 天前
问题处理-containerd拉取镜像失败,containerd镜像加速
kubernetes
来一杯龙舌兰11 天前
【Kubernetes】从零搭建K8s集群:虚拟机环境配置全指南(DNS/网络/防火墙/SELinux全解析一站式配置图文教程)
linux·网络·kubernetes
heart000_112 天前
如何用 eBPF 实现 Kubernetes 网络可观测性?实战指南
网络·云原生·容器·kubernetes