通过 Vitess
自带的 docker-compose
在本地拉起 Vitess
环境倒是很方便,但是调试起来很痛苦,本地编译的vtgate
可以跑起来,连接到 compose
运行的 consul
,但因为 vttablet
注册到counsul
的地址是容器内的hostname
,宿主机运行的vtgate
会连接不上。同理,调试vttablet
会更痛苦。于是尝试在服务器linux
上local
运行(参照这里,在 MacOS 上用vscode
远程调试。
Linux 运行 Vitess
参考官方文档一步步执行,不过还是会踩到坑,和本地运行的kubernetes
的etcd
组件有端口冲突,尝试通过修改etcd
启动端口绕过,修改了 env.sh
和scripts/etcd-up.sh
,这里是diff
:
diff --git a/env.sh b/env.sh
index c0b982a..b0c6b9e 100644
--- a/env.sh
+++ b/env.sh
@@ -62,7 +62,8 @@ elif [ "${TOPO}" = "k8s" ]; then
# shellcheck disable=SC2034
TOPOLOGY_FLAGS="-topo_implementation k8s -topo_k8s_kubeconfig ${K8S_KUBECONFIG} -topo_global_server_address ${K8S_ADDR}:${K8S_PORT} -topo_global_root /vitess/global"
else
- ETCD_SERVER="localhost:2379"
+ ETCD_SERVER="localhost:22379"
+ ETCD_PEERS="localhost:22380"
TOPOLOGY_FLAGS="-topo_implementation etcd2 -topo_global_server_address $ETCD_SERVER -topo_global_root /vitess/global"
mkdir -p "${VTDATAROOT}/etcd"
diff --git a/scripts/etcd-up.sh b/scripts/etcd-up.sh
index d8c0a86..1dc15d6 100755
--- a/scripts/etcd-up.sh
+++ b/scripts/etcd-up.sh
@@ -24,7 +24,7 @@ export ETCDCTL_API=2
# Check that etcd is not already running
curl "http://${ETCD_SERVER}" > /de