centos 在远程Linux上运行命令不起作用

a1o7rhls  于 2022-11-07  发布在  Linux
关注(0)|答案(1)|浏览(272)

我运行的是CentOS 7,我想在远程服务器上执行如下命令:

mclaw@ALHTACSS01 /home/mclaw> 
mclaw@ALHTACSS01 /home/mclaw> 
mclaw@ALHTACSS01 /home/mclaw> ssh -q hadoop1 "ndaf-cluster-status"
ksh: ndaf-cluster-status: not found
mclaw@ALHTACSS01 /home/mclaw> 
mclaw@ALHTACSS01 /home/mclaw>

但如果我登录到远程服务器并执行命令,它就可以工作:

mclaw@ALHTACSS01.default.masterclaw [mclaw] /home/mclaw> 
mclaw@ALHTACSS01.default.masterclaw [mclaw] /home/mclaw> ssh -q hadoop1
Last login: Tue Sep 13 14:33:20 2022 from 192.168.59.53
ULP 5.0.13 Platform for MC 8.0 (ISO version 5.0.13)
Setting up the MasterClaw environment...
mclaw@ALHTAHAD01.default.masterclaw [mclaw] /home/mclaw> 
mclaw@ALHTAHAD01.default.masterclaw [mclaw] /home/mclaw> ndaf-cluster-status
2022-09-13 14:43:36,945 INFO  [main] client.RMProxy (RMProxy.java:createRMProxy(98)) - Connecting to ResourceManager at ALHTAHAD01.default.masterclaw/192.168.79.172:8032
+-------------------------------+------------+-------+-------------------------+--------+-------+-------+
| Cluster                       | HDFS State | Nodes | HDFS Used / Total Space | Proc   | Disk% | Proc% |
+-------------------------------+------------+-------+-------------------------+--------+-------+-------+
| ALHTAHAD01.default.masterclaw | ONLINE     | 10    |   8.06 TB /  15.69 TB   | 61/142 |  51%  |  43%  |
+-------------------------------+------------+-------+-------------------------+--------+-------+-------+

+-------------------------------+------------+-------------------------+------+-------+-------+
| Node                          | YARN State | HDFS Used / Total Space | Proc | Disk% | Proc% |
+-------------------------------+------------+-------------------------+------+-------+-------+
| ALHTAHAD01.default.masterclaw | RUNNING    | 825.51 GB /   1.57 TB   | 8/13 |  51%  |  62%  |
| ALHTAHAD02.default.masterclaw | RUNNING    | 832.40 GB /   1.57 TB   | 5/15 |  52%  |  33%  |
| ALHTAHAD03.default.masterclaw | RUNNING    | 830.62 GB /   1.57 TB   | 9/15 |  52%  |  60%  |
| ALHTAHAD04.default.masterclaw | RUNNING    | 826.81 GB /   1.57 TB   | 7/15 |  51%  |  47%  |
| ALHTAHAD05.default.masterclaw | RUNNING    | 831.79 GB /   1.57 TB   | 6/15 |  52%  |  40%  |
| ALHTAHAD06.default.masterclaw | RUNNING    | 826.67 GB /   1.57 TB   | 6/15 |  51%  |  40%  |
| ALHTAHAD07.default.masterclaw | RUNNING    | 823.74 GB /   1.57 TB   | 8/13 |  51%  |  62%  |
| ALHTAHAD08.default.masterclaw | RUNNING    | 824.58 GB /   1.57 TB   | 5/13 |  51%  |  38%  |
| ALHTAHAD09.default.masterclaw | RUNNING    | 823.97 GB /   1.57 TB   | 3/13 |  51%  |  23%  |
| ALHTAHAD10.default.masterclaw | RUNNING    | 816.04 GB /   1.53 TB   | 4/15 |  52%  |  27%  |
+-------------------------------+------------+-------------------------+------+-------+-------+

+-------------+---------+--------------+-----------+------+
| Queue       | State   | Jobs W/R/C/F | Capacity  | Used |
+-------------+---------+--------------+-----------+------+
| ColdStore   | RUNNING | -            |   0%- 80% |   0% |
| DWH-Summary | RUNNING | -            |   0%- 70% |   0% |
| default     | RUNNING | -            |   5%- 25% |   0% |
| eoFB-query  | RUNNING | 0/0/9/0      |  15%- 80% |   0% |
| eoSearch    | RUNNING | -            |   0%- 50% |   0% |
| eoXdr       | RUNNING | -            |   0%-100% |   0% |
| ndaf-tools  | RUNNING | -            |   5%- 25% |   0% |
| eoFB-index  | RUNNING | 1/2/8327/0   |  15%-100% |   8% |
| DWH         | RUNNING | 0/3/1664/0   |  60%-100% |  36% |
+-------------+---------+--------------+-----------+------+

mclaw@ALHTAHAD01 [mclaw] /home/mclaw>

我已尝试写入完整路径,但仍不成功:

mclaw@ALHTAHAD01 [mclaw] /home/mclaw> 
mclaw@ALHTAHAD01 [mclaw] /home/mclaw> ssh -q hadoop1 "/opt/anritsu/mclaw/bin/ndaf-cluster-status"
/opt/anritsu/mclaw/bin/ndaf-cluster-status[16]: q7java: not found [No such file or directory]
mclaw@ALHTAHAD01 [mclaw] /home/mclaw>
mspsb9vt

mspsb9vt1#

您尝试启动的命令显然需要一个环境设置,除非您以交互方式登录,否则该设置不会完成。您可以尝试以下变体:
通过交互式shell显式运行命令(我猜这里是ksh的路径,您应该检查一下):

ssh -q hadoop1 /bin/ksh -i -c ndaf-cluster-status

使用-t强制分配tty:

ssh -qt hadoop1 ndaf-cluster-status

您也可以将两者结合起来,您可以尝试删除-i,它可能足以强制它通过一个shell,而不强制它是交互式的。或者'-i'可能不够,在这种情况下,您可以尝试将-i替换为-l,使其成为登录shell。如果有,是否需要-i-l选项取决于服务器的设置方式。

编辑:从你在评论中发布的错误消息来看,似乎有了进展!“设置MasterClaw环境”的消息意味着它没有运行正确的初始化文件。我猜它也确实需要一个tty(又名终端),所以试试这个:

ssh -qt hadoop1 /bin/ksh -l -c ndaf-cluster-status

(You我不应该同时需要-i-l,我认为登录shell总是被认为是交互式的。)
如果还是不行,那我就没办法了。你设法启动了程序,但它试图查询终端的大小,结果失败了。调试需要你的程序知识,而我不知道什么是MasterClaw。

相关问题