增加如下环境变量
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75-2.5.4.2.el7_0.x86_64
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export HADOOP_PREFIX=/opt/hadoop/current
export HADOOP_MAPRED_HOME=${HADOOP_PREFIX}
export HADOOP_COMMON_HOME=${HADOOP_PREFIX}
export HADOOP_HDFS_HOME=${HADOOP_PREFIX}
export HADOOP_YARN_HOME=${HADOOP_PREFIX}
export HTTPS_CATALINA_HOME=${HADOOP_PREFIX}/share/hadoop/httpfs/tomcat
export HADOOP_CONF_DIR=/etc/hadoop/conf
export YARN_CONF_DIR=/etc/hadoop/conf
export HTTPS_CONFIG=/etc/hadoop/conf
export PATH=$PATH:$HADOOP_PREFIX/bin:$HADOOP_PREFIX/sbin
我们将Hadoop安装在/opt/hadoop目录下面,建立如下软连接,配置文件放在/etc/hadoop/conf目录下面
[root@hadoop1 hadoop]# ll current
lrwxrwxrwx 1 root root 21 Oct 29 11:02 current -> hadoop-2.6.0-cdh5.8.2
做好如下授权
[root@hadoop1 hadoop]# chown -R hadoop.hadoop hadoop-2.6.0-cdh5.8.2
[root@hadoop1 hadoop]# chown -R hadoop.hadoop /etc/hadoop/conf
CDH5新版本的Hadoop启动服务脚步位于$HADOOP_HOME/sbin目录下面,启动服务有如下
namenode
secondarynamenode
datanode
resourcemanger
nodemanager
这里以Hadoop用户来进行管理和启动Hadoop的各种服务
[root@hadoop1 etc]# cd /etc/hadoop/conf/
[root@hadoop1 conf]# vim core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop1</value>
</property>
</configuration>
格式化namenode
[root@hadoop1 conf]# cd /opt/hadoop/current/bin
[root@hadoop1 bin]# hdfs namenode -format
启动namenode服务
[root@hadoop1 bin]# cd /opt/hadoop/current/sbin/
[root@hadoop1 sbin]# ./hadoop-daemon.sh start namenode
[hadoop@hadoop1 sbin]$ ./hadoop-daemon.sh start datanode
查看服务启动情况
namenode启动完成后,就可以通过web界面查看状态了,默认端口是50070,我们访问测试下
下面关于Hadoop的文章您也可能喜欢,不妨看看:
Ubuntu14.04下Hadoop2.4.1单机/伪分布式安装配置教程