Ubuntu上使用Hadoop 2.x 一 用户权限设置

本文介绍安装Hadoop 2.2.0 single node。

首先准备一个虚拟机,Ubuntu 12.04.4

Java环境:

[plain]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. root@hm1:~# mvn --version  
  2. Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 15:22:22+0000)  
  3. Maven home: /usr/apache-maven-3.1.1  
  4. Java version: 1.7.0_51, vendor: Oracle Corporation  
  5. Java home: /usr/lib/jvm/java-7-oracle/jre  
  6. Default locale: en_US, platform encoding: UTF-8  
  7. OS name: "linux", version: "3.2.0-59-virtual", arch: "amd64", family: "unix"  


安装过程参考了

http://codesfusion.blogspot.com/2013/10/setup-hadoop-2x-220-on-ubuntu.html?m=1


创建hadoop的用户以及组, 组hadoop, 用户名hduser, 密码hduser

[plain]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. root@hm1:~# addgroup hadoop  
  2. Adding group `hadoop' (GID 1001) ...  
  3. Done.  
  4. root@hm1:~# adduser --ingroup hadoop hduser  
  5. Adding user `hduser' ...  
  6. Adding new user `hduser' (1001) with group `hadoop' ...  
  7. Creating home directory `/home/hduser' ...  
  8. Copying files from `/etc/skel' ...  
  9. Enter new UNIX password:   
  10. Retype new UNIX password:   
  11. passwd: password updated successfully  
  12. Changing the user information for hduser  
  13. Enter the new value, or press ENTER for the default  
  14.     Full Name []:   
  15.     Room Number []:   
  16.     Work Phone []:   
  17.     Home Phone []:   
  18.     Other []:   
  19. Is the information correct? [Y/n] y  

添加到sudo组中

[plain]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. root@hm1:~# adduser hduser sudo  
  2. Adding user `hduser' to group `sudo' ...  
  3. Adding user hduser to group sudo  
  4. Done.  

为了防止以后用hduser使用sudo时候遇到如下错误:

[plain]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. hduser is not in the sudoers file.  This incident will be reported.  
需要用visudo命令编辑文件/etc/sudoers, 添加一行

[plain]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. # Uncomment to allow members of group sudo to not need a password  
  2. # %sudo ALL=NOPASSWD: ALL  
  3. hduser ALL=(ALL) ALL  

退出root用户,用hduser登录。

[plain]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. ssh hduser@192.168.1.70  

为了避免安装脚本提示认证,下面的命令将建立localhost访问的证书文件

[plain]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. hduser@hm1:~$ ssh-keygen -t rsa -P ''  
  2. Generating public/private rsa key pair.  
  3. Enter file in which to save the key (/home/hduser/.ssh/id_rsa):   
  4. Created directory '/home/hduser/.ssh'.  
  5. Your identification has been saved in /home/hduser/.ssh/id_rsa.  
  6. Your public key has been saved in /home/hduser/.ssh/id_rsa.pub.  
  7. The key fingerprint is:  
  8. b8:b6:3d:c2:24:1f:7b:a3:00:88:72:86:76:5a:d8:c2 hduser@hm1  
  9. The key's randomart image is:  
  10. +--[ RSA 2048]----+  
  11. |                 |  
  12. |                 |  
  13. |                 |  
  14. |ooo    .         |  
  15. |=E++  . S        |  
  16. |oo=.. o.         |  
  17. | .  .=oo         |  
  18. |     o=o+        |  
  19. |      o+.o       |  
  20. +-----------------+  
  21. hduser@hm1:~$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys  
  22. hduser@hm1:~$ ssh localhost  
  23. The authenticity of host 'localhost (127.0.0.1)' can't be established.  
  24. ECDSA key fingerprint is fb:a8:6c:4c:51:57:b2:6d:36:b2:9c:62:94:30:40:a7.  
  25. Are you sure you want to continue connecting (yes/no)? yes  
  26. Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.  
  27. Welcome to Ubuntu 12.04.4 LTS (GNU/Linux 3.2.0-59-virtual x86_64)  
  28.   
  29.  * Documentation:  https://help.ubuntu.com/  
  30. Last login: Fri Feb 21 07:59:05 2014 from 192.168.1.5  
ssh localhost 如果没有遇到询问密码, 第一次回答一下Yes。就说明上面的设置成功了。

现在下载hadoop,下载网址:http://apache.mirrors.lucidnetworks.net/hadoop/common/

现在运行下面的命令下载和修改文件权限

[plain]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. $ cd ~  
  2. $ wget http://www.trieuvan.com/apache/hadoop/common/hadoop-2.2.0/hadoop-2.2.0.tar.gz  
  3. $ sudo tar vxzf hadoop-2.2.0.tar.gz -C /usr/local  
  4. $ cd /usr/local  
  5. $ sudo mv hadoop-2.2.0 hadoop  
  6. $ sudo chown -R hduser:hadoop hadoop  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值