安装hadoop伪分布式
修改hosts
cat /etc/hosts
127.0.0.1 mo.don.com
创建用户
useradd hadoop
passwd hadoop
sudo授权
visudo
hadoop ALL=(ALL) NOPASSWD: ALL
切换用户
su - hadoop
下载解压
wget http://mirror.bit.edu.cn/apache/hadoop/common/hadoop-3.1.2/hadoop-3.1.2.tar.gz
tar xf hadoop-3.1.2.tar.gz
创建工作目录
mkdir moudles && mv hadoop-3.1.2 moudles
mkdir -p moudles/data/{datanode,namenode,tmp}
cd moudles/hadoop-3.1.2
添加环境变量
cat /etc/profile
## add hadoop
export HADOOP_HOME=/home/hadoop/moudles/hadoop-3.1.2
export PATH=$HADOOP_HOME/bin/:$HADOOP_HOME/sbin:$PATH
修改配置文件
cat /home/hadoop/moudles/hadoop-3.1.2/etc/hadoop/hadoop-env.sh
export JAVA_HOME=/usr/local/jdk1.8.0
cat /home/hadoop/moudles/hadoop-3.1.2/etc/hadoop/core-site.xml
<configuration>
<!-- HDFS资源路径 -->
<property>
<name>fs.defaultFS</name>
<value>hdfs://mo.do.com:9820</value>
</property>
<!-- 在见面界面访问数据使用的用户名 -->
<property>
<name>hadoop.http.staticuser.user</name>
<value>heron</value>
</property>
<!-- Hadoop临时文件存放目录 -->
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hadoop/moudles/data/tmp</value>
</property>
<!-- 垃圾文件保留时间(秒) -->
<property>
<name>fs.trash.interval</name>
<value>7200</value>
</property>
</configuration>
cat /home/hadoop/moudles/hadoop-3.1.2/etc/hadoop/hdfs-site.xml
<configuration>
<!-- 是否进行权限检查 -->
<property>
<name>dfs.permissions.enabled</name>
<value>false</value>
</property>
<!-- 副本数 -->
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<!-- namenode元数据存储路径 -->
<property>
<name>dfs.namenode.name.dir</name>
<value>/home/hadoop/moudles/data/namenode</value>
</property>
<!-- 数据存储路径 -->
<property>
<name>dfs.datanode.data.dir</name>
<value>/home/hadoop/moudles/data/datanode</value>
</property>
</configuration>
cat /home/hadoop/moudles/hadoop-3.1.2/etc/hadoop/yarn-site.xml
<configuration>
<!-- resourceManager在哪台机器 -->
<property>
<name>yarn.resourcemanager.hostname</name>
<value>mo.do.com</value>
</property>
<!-- 在nodemanager中运行mapreduce服务 -->
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<!-- 配置日志的聚集功能 -->
<property>
<name>yarn.log-aggregation-enable</name>
<value>true</value>
</property>
<property>
<name>yarn.log-aggregation.retain-seconds</name>
<value>604800</value>
</property>
</configuration>
cat /home/hadoop/moudles/hadoop-3.1.2/etc/hadoop/mapred-site.xml
<configuration>
<!-- mapreduce运行在yarn上面 -->
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>yarn.app.mapreduce.am.env</name>
<value>HADOOP_MAPRED_HOME=/home/hadoop/moudles/hadoop-3.1.2</value>
</property>
<property>
<name>mapreduce.map.env</name>
<value>HADOOP_MAPRED_HOME=/home/hadoop/moudles/hadoop-3.1.2</value>
</property>
<property>
<name>mapreduce.reduce.env</name>
<value>HADOOP_MAPRED_HOME=/home/hadoop/moudles/hadoop-3.1.2</value>
</property>
</configuration>
格式化hdfs
hdfs namenode -format
启动hdfs/ Yarn
hdfs --daemon start namenode
hdfs --daemon start datanode
yarn --daemon start resourcemanager
yarn --daemon start nodemanager
yarn --daemon start timelineserver
查看启动状态
jps
浏览器查看
赵客缦胡缨,吴钩霜雪明。
银鞍照白马,飒沓如流星。