1.jdk1.8环境搭建
2.下载hadoop2.7.7
3.创建hadoop文件夹
sudo mkdir /usr/share/hadoop
4.解压hadoop
sudo tar -zxvf hadoop-2.7.7.tar.gz -C /usr/share/hadoop
5.配置环境变量
sudo vim /etc/profile
# hadoop2.7.7 environment
export HADOOP_HOME=/usr/share/hadoop/hadoop-2.7.7
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
保存退出:wq
6.配置hadoop
cd /usr/share/hadoop/hadoop-2.7.7/etc/hadoop
配置core-site.xml
sudo vim core-site.xml
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/usr/share/hadoop/tmp</value>
<description>Abase for other temporary directories.</description>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
配置hdfs-site.xml
sudo vim hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/usr/share/hadoop/tmp/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/usr/share/hadoop/tmp/dfs/data</value>
</property>
</configuration>
配置mapred-site.xml
cp mapred-site.xml.template mapred-site.xml
sudo vim mapred-site.xml
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
</configuration>
或者
sudo vim mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
配置yarn-site.xml
sudo 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>
7.创建临时文件夹tmp
cd /usr/share/hadoop
sudo mkdir tmp
sudo chmod -R 777 tmp
8.修改hadoop-env.sh
cd /usr/share/hadoop/hadoop-2.7.7/etc/hadoop
sudo vim hadoop-env.sh
#将export JAVA_HOME=${JAVA_HOME} 修改成
export JAVA_HOME=/usr/local/java/jdk1.8.0_151
9.启动hadoop
cd /usr/share/hadoop/hadoop-2.7.7
sudo ./sbin/start-all.sh
10.在HDFS建立目录为了给hive使用
cd /usr/share/hadoop/hadoop-2.7.7/bin
hadoop fs -mkdir /tmp
hadoop fs -mkdir -p /user/hive/warehouse
hadoop fs -chmod g+w /tmp
hadoop fs -chmod g+w /user/hive/warehouse
网友评论