概述
hadoop的前置条件是jdk和ssh,所有这些都放在hadoop用户的空间下,故创建用户hadoop;
1.创建hadoop用户
- 安装sudo
yum install -y sudo
- 创建hadoop用户
useradd hadoop
- 设置hadoop用户的密码
passwd hadoop
- 让hadoop用户拥有sudo权限
chmod u+w /etc/sudoers
vi /etc/sudoers
hadoop ALL=(ALL) ALL
chmod u-w /etc/sudoers
- 切换到hadoop用户
su hadoop
cd
2. 安装JDK
- 解压jdk
tar -zxvf jdk-7u51-linux-x64.tar.gz -C ~/app/
- 配置环境变量
vi ~/.bash_profile
export JAVA_HOME=/home/hadoop/app/jdk1.7.0_51
export PATH=$JAVA_HOME/bin:$PATH
source ~/.bash_profile
- 检验安装结果
[hadoop@hadoop001 .ssh]$ java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
3. 安装ssh
sudo yum -y install openssh-clients
4. 机器参数设置
- 设置hostname
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=hadoop001
- 设置IP和hostname的映射关系
vi /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2 hadoop001
- 设置ssh免密码登录
ssh-keygen -t rsa
cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
ssh hadoop001