TiDB执行部署集群命令时报错

【 TiDB 使用环境】
【概述】: 按照官方文档步骤,使用 TiUP 部署 TiDB 集群
【背景】:使用以下命令部署和检查:
tiup cluster template > topology.yaml
tiup cluster deploy test-cluster v4.0.9 ./topology.yaml --user xxx-deploy -p
tiup cluster check topology.yaml --user xxx-deploy -p
【现象】:文档上说:通常推荐使用 TiUP 部署工具会自动配置 SSH 互信及免密登录。不需要手动配置 SSH 互信及 sudo 免密码
【问题】:部署不成功,报了以下错误:
xxx-deploy@xxx-dash-3-01:~/tidb-ansible$ tiup cluster check topology.yaml --user xxx-deploy -p
Starting component cluster: /home/xxx-deploy/.tiup/components/cluster/v1.8.1/tiup-cluster check topology.yaml --user xxx-deploy -p
Input SSH password:

  • Detect CPU Arch
  • Detect CPU Arch
  • Detect CPU Arch
    • Detecting node 10.0.0.83 … Error
    • Detecting node 10.0.0.84 … Error
    • Detecting node 10.0.0.85 … Error
    • Detecting node 10.0.0.93 … Error
    • Detecting node 10.0.0.94 … Error
    • Detecting node 10.0.0.95 … Error
    • Detecting node 10.0.0.53 … Error

Error: failed to fetch cpu arch: executor.ssh.execute_failed: Failed to execute command over SSH for ‘xxx-deploy@10.0.0.83:22’ {ssh_stderr: sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
, ssh_stdout: , ssh_command: export LANG=C; PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin /usr/bin/sudo -H bash -c “uname -m”}, cause: Process exited with status 1

Verbose debug logs has been written to /home/xxx-deploy/.tiup/logs/tiup-cluster-debug-2021-12-24-01-48-10.log.
Error: run /home/xxx-deploy/.tiup/components/cluster/v1.8.1/tiup-cluster (wd:/home/xxx-deploy/.tiup/data/SsTHdkR) failed: exit status 1
【业务影响】:
【TiDB 版本】: v4.0.9
【附件】:

1 个赞

参考这里 https://docs.pingcap.com/zh/tidb/stable/check-before-deployment#手动配置-ssh-互信及-sudo-免密码

1 个赞

你看这个文档的第一句:通常推荐使用 TiUP 部署工具会自动配置 SSH 互信及免密登录,可忽略本段内容。:joy:

https://asktug.com/t/topic/95777
看看这个

1 个赞

这个文章写得真不错。我看完了,我这边用的2个账号,ti-ctr和admin是同一个,集群节点上的高权限账户。完全符合上面提到的情况。可怎么还是报错了呢?

你各个节点之间的端口都通着吗?或者是防火墙关了吗?

可能ssh有地方没设置好。
其实ssh的问题有两种方式,
1.tiup可以自动创建tidb用户,并建立ssh互信进行部署
2.手动创建tidb用户,手动建立互信,部署的时候 --user 记得指向tidb用户,或者-i 指向互信的文件,就可以部署成功

1 个赞

我也大概知道是ssh没好,可到底哪没好。表妹你这两条我已经在别的帖子看过了,不起作用。

建议先参照帖子做ssh互信的验证~之前有类似问题都是在验证阶段就能确定问题了。
可以参照贴子中的引用帖

我这边用的是ubuntu20.04系统。全部机器在内网,中控机可以ssh到各个节点。sudo ufw status verbose结果 是Status: inactive

ssh是使用 xxx-deploy 用户做的么?ssh之后测试免密了么?

你的会不会和这位同学的情况一样?

1 个赞

中控机及所有节点都存在xxx-deploy 用户。可以ssh xxx-deploy@10.0.0.xx至任一节点(要输密码)。我没有做免密,deploy使用参数-p的。所有机子的/etc/sudoers 都加了xxx-deploy ALL=(ALL) NOPASSWD:ALL

额。。。需要输密码就是免密没做好吧,你发的报错信息很明显是需要密码

a terminal is required to read the password;

可是这里说不需要免密的啊。

引用

你可能觉得有点少,但是确实不需要更多了。

  • 不需要 ti-ctr 在中控机上有高权限。对中控机来说, ti-ctr 可以是一个普普通通的账户,因为使用 tiup 不需要高权限。
  • 不需要 ti-ctr 能免密码登录集群节点

关于 ssh 认证和登录,社区里很多人说,要提前配置好密钥对认证,让 ti-ctr 可以免密码登录集群节点。其实完全没必要。执行一下 tiup cluster deploy -h 就能看到,你可以在部署的时候,命令行指定如何认证(密钥对认证 or 密码认证)。

引用

通常推荐使用 TiUP 部署工具会自动配置 SSH 互信及免密登录

tiup cluster deploy tidb-test v5.3.0 ./topology.yaml --user root [-p] [-i /home/root/.ssh/gcp_rsa]

-p 是目标服务器的密码,中控机和集群服务器的密码都是一致的么?

嗯嗯,1台中控及6台集群机,用户名都叫xxx-deploy,密码都是一样的。

我这边是建议先按标准文档手工配置一下,然后验证是否是这里的问题。

1 个赞

其实sudo 免密码我已经配置了。我还是觉得官方的标准文档不会有错的,不应该要手工配置SSH免密,也不需要手工创建tidb用户的。

配置成功了吗?
在目标节点上,xxx-deploy 用户执行 sudo -ll 是什么样子的,截图分享一下

你说的对