首页 > 代码库 > hadoop学习一:hadoop安装(hadoop2.4.1,ubuntu14.04)
hadoop学习一:hadoop安装(hadoop2.4.1,ubuntu14.04)
1.创建用户
adduser hduser
修改hduser用户权限:
sudo vim /ect/sudoers ,在文件中增加 hduser ALL=(ALL:ALL) ALL 。
2.安装ssh并设置无密码登陆
1)sudo apt-get install openssh-server
2)启动服务:sudo /etc/init.d/ssh start
3)查看服务是否正确启动:ps -e | grep ssh
4)设置免密码登录,生成私钥和公钥
ssh-keygen -t rsa -P ""
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
5)免密码登陆:ssh localhost
6) exit
3.配置java 环境
1)下载:jdk-8u25-linux-x64.tar.gz
2)解压:tar -xzvf jdk-8u25-linux-x64.tar.gz
3) sudo mv jdk1.8.0_25 /usr/local/
4)设置环境变量:sudo vim /etc/profile(全局设置文件,也可以设置~/.bashrc文件,~/.bashrc文件设置只是该用户的设置文件),在末尾添加:
export JAVA_HOME=/usr/local/jdk1.8.0_25
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
5)source /etc/profile
6)测试是否成功:java -version
4.hadoop单机安装
1) 下载
2) 解压:sudo tar -xzvf hadoop-2.4.0.tar.gz
3) sudo mv hadoop-2.4.0 /usr/local/
4) sudo chmod 774 hadoop-2.4.0
5) vim .bashrc,在文件末尾添加
export JAVA_HOME=/usr/local/jdk1.8.0_25 (选择自己的java安装路径)
export HADOOP_INSTALL=/usr/local/hadoop-2.4.1 (自己的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"
6) source .bashrc
7) 进入/usr/local/hadoop-2.4.1/etc/hadoop 目录,配置hadoop-env.sh
vim hadoop-env.sh,填入自己的java路径,hadoop的配置路径(单机不修改hadoop配置路径不影响,伪分布式必须修改)
8) source hadoop-env.sh单机模式配置完
5.伪分布式配置:(进入/usr/local/hadoop-2.4.1/etc/hadoop)
1)配置core-site.xml:vim core-site.xml,添加:
在/usr/local/hadoop-2.4.1 下创建tmp文件夹: mkdir tmp
<property>
<name>hadoop.tmp.dir</name>
<value>file:/usr/local/hadoop-2.4.1/tmp</value>
<description>Abase for other temporary directories.</description>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
2)配置hdfs-site.xml: vim hdfs-site.xml,添加:
在/usr/local/hadoop-2.4.1下创建文件夹:mkdir hdfs , mkdir hdfs/name , mkdir hdfs/data
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/usr/local/hadoop-2.4.1/hdfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/usr/local/hadoop-2.4.1/hdfs/data</value>
</property>
</configuration>
3)配置yarn-site.xml:vim yarn-site.xml,添加:
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
</configuration>
4)配置mapred-site.xml: cp mapred-site.xml.template mapred-site.xml, vim mapred-site.xml ,添加:
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
5)格式化hdfs : hdfs namenode -format
6)执行启动命令: sbin/start-dfs.sh sbin/start-yarn.sh
7)jps查看和java有关的进程:
8)hadoop管理界面:http://localhost:50070/
9)hadoop进程管理界面:http://localhost:8088
hadoop学习一:hadoop安装(hadoop2.4.1,ubuntu14.04)