CentOS 6.5 伪分布式 安装 hadoop 2.6.0

安装 jdk

1 yum install java-1.7.0-openjdk*
3 检查安装:java -version

 

创建Hadoop用户,设置Hadoop用户使之可以免密码ssh到localhost

1 su - hadoop  
2 ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa    
3 cat ~/.ssh/id_dsa.pub>> ~/.ssh/authorized_keys  
4   
5 cd /home/hadoop/.ssh   
6 chmod 600 authorized_keys  

注意这里的权限问题,保证.ssh目录权限为700,authorized_keys为600

验证:

1 [hadoop@localhost .ssh]$ ssh localhost  
2 Last login: Sun Nov 17 22:11:55 2013  

 

解压hadoop,安装在/opt/hadoop

1 tar -xzvf hadoop-2.6.0.tar.gz
2 mv -i /home/erik/hadoop-2.6.0 /opt/hadoop  
3 chown -R hadoop /opt/hadoop  

 

要修改的文件有hadoop-env.sh、core-site.xml  、 hdfs-site.xml 、 yarn-site.xml 、mapred-site.xml几个文件。

1 cd /usr/opt/hadoop/etc/hadoop  

 

设置hadoop-env.sh中的java环境变量,改成这样JAVA_HOME好像没效

1 export JAVA_HOME= {你的java环境变量} 

 

core-site.xml

 1   
 2       
 3         hadoop.tmp.dir  
 4         /opt/hadoop/tmp
 5       
 6       
 7         fs.default.name  
 8         localhost:9000  
 9       
10  

 

hdfs.xml

 1  
 2 
 3         dfs.replication
 4         1
 5     
 6     
 7         dfs.namenode.name.dir
 8         /opt/hadoop/dfs/name
 9     
10     
11         dfs.datanode.data.dir
12         /opt/hadoop/dfs/data
13     
14     
15             dfs.permissions
16             false
17      
18      

 

yarn-site.xml

 1 
 2 
 3 mapreduce.framework.name
 4 yarn
 5 
 6   
 7 
 8 yarn.nodemanager.aux-services
 9 mapreduce_shuffle
10 
11 

 

mapred-site.xml

1 
2 
3 mapred.job.tracker
4 localhost:9001
5 
6 

 

配置环境变量,修改/etc/profile, 写在最后面即可。配置完要重启!!!

 1 export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.95.x86_64
 2 export JRE_HOME=$JAVA_HOME/jre
 3 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/bin
 4 export HADOOP_INSTALL=/opt/hadoop
 5 export PATH=${HADOOP_INSTALL}/bin:${HADOOP_INSTALL}/sbin${PATH}
 6 export HADOOP_MAPRED_HOME=${HADOOP_INSTALL}
 7 export HADOOP_COMMON_HOME=${HADOOP_INSTALL}
 8 export HADOOP_HDFS_HOME=${HADOOP_INSTALL}
 9 export YARN_HOME=${HADOOP_INSTALLL}
10 export HADOOP_COMMON_LIB_NATIVE_DIR=${HADOOP_INSTALL}/lib/natvie
11 export HADOOP_OPTS="-Djava.library.path=${HADOOP_INSTALL}/lib:${HADOOP_INSTALL}/lib/native"

 

之后就是见证奇迹的时候了,

1 cd /opt/hadoop/

 

格式化hdfs

1 bin/hdfs namenode -format 

 

启动hdfs

1 sbin/start-dfs.sh 
2 sbin/start-yarn.sh

 

理论上会见到

1 Starting namenodes on [localhost]  
2 localhost: starting namenode, logging to /usr/opt/hadoop-2.6.0/logs/hadoop-hadoop-namenode-.out  
3 localhost: starting datanode, logging to /usr/opt/hadoop-2.6.0/logs/hadoop-hadoop-datanode-.out  
4 Starting secondary namenodes [0.0.0.0]  
5 0.0.0.0: starting secondarynamenode, logging to /usr/opt/hadoop-2.6.0/logs/hadoop-hadoop-secondarynamenode-.out  

输入网址127.0.0.1:50070就可以看见hadoop的网页了,这就说明成功了。

 

参考:

http://www.centoscn.com/hadoop/2015/0118/4525.html

http://blog.csdn.net/yinan9/article/details/16805275

http://www.aboutyun.com/thread-10554-1-1.html

转载于:https://www.cnblogs.com/deliver/p/5295321.html

你可能感兴趣的:(CentOS 6.5 伪分布式 安装 hadoop 2.6.0)