【问题标题】:Adding ec2-user to use hadoop添加 ec2-user 以使用 hadoop
【发布时间】:2014-06-05 00:12:51
【问题描述】:

我已设置 AWS EMR。我通过 SSH 连接到主节点。我想将文件复制到 hdfs 系统中。我的程序中执行此操作的那一小行代码是:

os.system('/home/hadoop/bin/hdfs dfs -put %s PATH_to_HADOOP' % tmp_output)

我想输入我的 hdfs 文件系统的路径。

我愿意

   [ec2-user@ip-172-31-0-185 input]$ /home/hadoop/bin/hdfs dfs -ls /
Found 2 items
drwxr-xr-x   - hadoop supergroup          0 2014-04-14 22:21 /hbase
drwxrwx---   - hadoop supergroup          0 2014-04-14 22:19 /tmp

我试试

    [ec2-user@ip-172-31-0-185 input]$ /home/hadoop/bin/hdfs dfs -mkdir /tmp/stockmarkets
mkdir: Permission denied: user=ec2-user, access=EXECUTE, inode="/tmp":hadoop:supergroup:drwxrwx---

所以,要添加 ec2-user 以使用 hadoop,我按照以下说明操作:

http://cloudcelebrity.wordpress.com/2013/06/05/handling-permission-denied-error-on-hdfs/

但是在我写完之后(我用 ubuntu 他们代替了 ec2-user)

sudo adduser ec2-user hadoop

我得到的不是添加消息,而是:

Usage: useradd [options] LOGIN
Options:
  -b, --base-dir BASE_DIR       base directory for the home directory of the
                                new account
  -c, --comment COMMENT         GECOS field of the new account
  -d, --home-dir HOME_DIR       home directory of the new account
  -D, --defaults                print or change default useradd configuration
  -e, --expiredate EXPIRE_DATE  expiration date of the new account
  -f, --inactive INACTIVE       password inactivity period of the new account
  -g, --gid GROUP               name or ID of the primary group of the new
                                account
  -G, --groups GROUPS           list of supplementary groups of the new
                                account
  -h, --help                    display this help message and exit
  -k, --skel SKEL_DIR           use this alternative skeleton directory
  -K, --key KEY=VALUE           override /etc/login.defs defaults
  -l, --no-log-init             do not add the user to the lastlog and
                                faillog databases
  -m, --create-home             create the user's home directory
  -M, --no-create-home          do not create the user's home directory
  -N, --no-user-group           do not create a group with the same name as
                                the user
  -o, --non-unique              allow to create users with duplicate
                                (non-unique) UID
  -p, --password PASSWORD       encrypted password of the new account
  -r, --system                  create a system account
  -s, --shell SHELL             login shell of the new account
  -u, --uid UID                 user ID of the new account
  -U, --user-group              create a group with the same name as the user
  -Z, --selinux-user SEUSER     use a specific SEUSER for the SELinux user mapping

所以我很困惑和搞砸了..请帮助>....

【问题讨论】:

    标签: hadoop amazon-ec2 hdfs mkdir


    【解决方案1】:

    如果查看 HDFS 目录 /tmp 的权限,可以看到 /tmp 归用户 hadoop 所有,ec2-user 无权访问 /tmp 中创建的文件/目录

    为目录/tmp分配适当的权限,使用以下命令

    [ec2-user@ip-172-31-0-185 input]$ sudo -su hadoop /home/hadoop/bin/hdfs dfs -chmod 777 /tmp
    

    现在尝试在 /tmp HDFS 位置创建目录

    [ec2-user@ip-172-31-0-185 input]$ /home/hadoop/bin/hdfs dfs -mkdir /tmp/stockmarkets
    

    【讨论】:

    • 嗨,我试过了,我收到了这条消息:Sorry, user ec2-user is not allowed to execute '/bin/bash -c /home/hadoop/bin/hdfs dfs -chmod 777 /tmp' as hadoop on ip-172-31-0-185.us-west-2.compute.internal
    • 你能执行命令并发布它的输出“cat /etc/passwd | grep hadoop”
    • 当然是hadoop:x:220:501::/home/hadoop:/bin/bash
    • 按照Todd的建议切换到hadoop用户,然后通过消除sudo -su hadoop执行上述命令
    • 不,他的建议非常有效。之后我不需要更改权限等,只需创建目录并继续我的工作。 :)
    【解决方案2】:

    SSH 作为 Amazon EMR 的 hadoop@(publicIP)。

    从那里您可以使用 HDFS 做任何您喜欢的事情,而无需“su”。我刚刚做了一个 mkdir 并运行了 distcp 和一个流式作业。根据 EMR 说明,我以 hadoop@ 做所有事情。

    【讨论】:

    • 这个简单的解决方案确实让我开始工作。虽然很高兴了解如何以 ec2 用户的身份完成它。所以我要等待几天的洗脱,然后接受你的回答..谢谢你..
    • 在他们的文档中,亚马逊竟然说:重要连接到亚马逊 EMR 集群节点时必须使用登录名 hadoop,否则会出现类似于 Server 的错误拒绝我们的关键错误可能会发生。 docs.aws.amazon.com/ElasticMapReduce/latest/DeveloperGuide/…
    猜你喜欢
    • 2015-12-25
    • 1970-01-01
    • 2019-04-01
    • 2013-03-10
    • 2018-01-23
    • 1970-01-01
    • 2021-12-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多