一、在Ubuntu下创建hadoop用户组合hadoop用户
1、创建hadoop用户组 addgroup hadoop 2、创建hadoop用户 adduser -ingroup hadoop hadoop 3、为hadoop用户添加权限 vim /etc/sudoers 4、切换到hadoop用户 su - hadoop二、ssh安装与设置1、安装ssh sudo apt-get install openssh-server2、启动服务 sudo /etc/init.d/ssh start3、查看启动 ps -e | grep ssh4、设置免密码登录,生成私钥与公钥 ssh-keygen -t rsa -P "" 此时会在/home/hadoop/.ssh下生成两个文件:id_rsa和id_rsa.pub,前者为私钥,后者为公钥。 将公钥追加到authorized_keys中,它用户保存所有允许以当前用户身份登录到ssh客户端用户的公钥内容。 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys5、ssh登录 ssh localhost6、退出登录 exit三、安装java环境1、安装javasudo apt-get install openjdk-7-jdk2、查看java版本 java -version3、查看java安装路径
update-alternative --config java四、安装hadoop2.7.1 1、下载hadoop2.7.1.tar.gz 2、解压:sudo tar xzf hadoop-2.7.1.tar.gz 3、复制到:sudo mv hadoop-2.7.1 /usr/local/hadoop 4、权限设置:sudo chmod 774 /usr/local/hadoop 5、配置.bashrc文件
#HADOOP VARIABLES START6、环境变量生效 source ~/.bashrc 7、编辑/usr/local/hadoop/etc/hadoop/hadoop-env.sh 五、验证测试 1、/usr/local/hadoop路径下创建input文件夹 2、拷贝README.txt到input 3、执行WordCount bin/hadoop jar share/hadoop/mapreduce/sources/hadoop-mapreduce-examples-2.4.0-sources.jar org.apache.hadoop.examples.WordCount input output 六、结果演示
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export HADOOP_INSTALL=/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
export YARN_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib"
#HADOOP VARIABLES END