问题现象
我这边执行的pc-ctl命令,这个是tidb的pd命令行工具
命令本地会自行的结果如下:
[root@centos7 ~]# /root/pd-ctl -u 10.226.157.132:2900 region
{
"count": 1,
"regions": [
{
"id": 2,
"start_key": "",
"end_key": "",
"epoch": {
"conf_ver": 128,
"version": 9
},
"peers": [
{
"id": 65,
"store_id": 28
},
{
"id": 66,
"store_id": 11
},
{
"id": 70,
"store_id": 31
},
{
"id": 71,
"store_id": 4
},
{
"id": 75,
"store_id": 6
}
],
"leader": {
"id": 70,
"store_id": 31
},
"approximate_size": 4986
}
]
}
[root@centos7 ~]#
但是通过ssh远程执行pd-ctl会卡住
[root@centos7 ~]# ssh root@127.0.0.1 "/root/pd-ctl -u 10.226.157.132:2900 region"
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:yWPZSs92gAknt9ycN17tNs9NBZGIF/RA0PSn9evBx7o.
ECDSA key fingerprint is MD5:00:74:b3:d5:bc:2f:14:dc:8a:e6:88:03:12:9f:7f:67.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts.
root@127.0.0.1's password: #输入密码后卡住了
^CKilled by signal 2. #通过ctrl + c停止
[root@centos7 ~]#
解决方法
是用ssh -t 就可以了
[root@centos7 ~]# ssh -t root@127.0.0.1 "/root/pd-ctl -u 10.226.157.132:2900 region"
root@127.0.0.1's password:
{
"count": 1,
"regions": [
{
"id": 2,
"start_key": "",
"end_key": "",
"epoch": {
"conf_ver": 128,
"version": 9
},
"peers": [
{
"id": 65,
"store_id": 28
},
{
"id": 66,
"store_id": 11
},
{
"id": 70,
"store_id": 31
},
{
"id": 71,
"store_id": 4
},
{
"id": 75,
"store_id": 6
}
],
"leader": {
"id": 70,
"store_id": 31
},
"approximate_size": 4986
}
]
}
Connection to 127.0.0.1 closed.
[root@centos7 ~]#
man ssh 查看-t参数的含义如下:
-t Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful,
e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.
#强制伪终端分配。 这可用于在远程机器上执行任意基于屏幕的程序,这非常有用,例如 实现菜单服务时。 多个 -t 选项强制分配 tty,即使 ssh 没有本地 tty。