hdfs+在linux远程机器上运行hdfs命令

4xrmg8kj  于 2021-05-27  发布在  Hadoop
关注(0)|答案(1)|浏览(680)

我们希望执行以下简单命令
使用ssh登录到$hadoop\u机器
并以 hdfs fsck / ,来自用户hdfs
所以我们运行以下程序

ssh $hadoop_machine su hdfs -c 'hdfs fsck /'

但我们得到

Usage: hdfs [--config confdir] [--loglevel loglevel] COMMAND
       where COMMAND is one of:
  dfs                  run a filesystem command on the file systems supported in Hadoop.
  classpath            prints the classpath
  namenode -format     format the DFS filesystem
  secondarynamenode    run the DFS secondary namenode
  namenode             run the DFS namenode
  journalnode          run the DFS journalnode
  zkfc                 run the ZK Failover Controller daemon
  datanode             run a DFS datanode
  dfsadmin             run a DFS admin client
  envvars              display computed Hadoop environment variables
  haadmin              run a DFS HA admin client
  fsck                 run a DFS filesystem checking utility
  balancer             run a cluster balancing utility
  jmxget               get JMX exported values from NameNode or DataNode.
  mover                run a utility to move block replicas across
                       storage types
  oiv                  apply the offline fsimage viewer to an fsimage
  oiv_legacy           apply the offline fsimage viewer to an legacy fsimage
  oev                  apply the offline edits viewer to an edits file
  fetchdt              fetch a delegation token from the NameNode
  getconf              get config values from configuration
  groups               get the groups which users belong to
  snapshotDiff         diff two snapshots of a directory or diff the
                       current directory contents with a snapshot
  lsSnapshottableDir   list all snapshottable dirs owned by the current user
                                                Use -help to see options
  portmap              run a portmap service
  nfs3                 run an NFS version 3 gateway
  cacheadmin           configure the HDFS cache
  crypto               configure HDFS encryption zones
  storagepolicies      list/get/set block storage policies
  version              print the version

Most commands print help when invoked w/o parameters.

为什么我们不能通过用户hdfs在远程机器上执行hdfs任务?

xa9qqrwz

xa9qqrwz1#

ssh $hadoop_machine su hdfs -c 'hdfs fsck /'

运行此命令时,单引号由本地shell示例处理。命令 ssh 在远程系统上运行的请求是:

su hdfs -c hdfs fsck /
``` `su` 将“-c”后面的参数解释为要运行的命令。论点是“hdfs”,所以 `su` 调用 `hdfs` 没有任何争论。
您需要以引号传递到远程系统的方式运行ssh。这应该起作用:

ssh $hadoop_machine su hdfs -c '"hdfs fsck /"'
or
ssh $hadoop_machine 'su hdfs -c "hdfs fsck /"'

其中任何一个都会导致ssh请求调用:

su hdfs -c "hdfs fsck /"

相关问题