三节点安装
1、准备工作
1.1、安装jdk
解压
配置环境变量
export JAVA_HOME=/usr/local/jdk1.8.0_91
export PATH=$PATH:$JAVA_HOME/bin
1.2、配置hosts
192.100.3.205 node-1
192.100.3.206 node-2
192.100.3.207 node-3
1.3、配置免密登录
以上步骤在三个节点执行
下面hadoop的配置步骤可以在一台机器上执行,之后直接拷贝到另外两个节点上
2、下载hadoop包、解压
使用的版本为:hadoop-2.9.2
3、修改配置文件
vim etc/hadoop/core-site.xml
<configuration>
<!-- 指定集群的文件系统类型:分布式文件系统 -->
<property>
<name>fs.defaultFS</name>
<value>hdfs://node-1:8020</value>
</property>
<!-- 指定临时文件存储目录 -->
<property>
<name>hadoop.tmo.dir</name>
<value>/usr/local/hadoop-2.9.2/data/tmpData</value>
</property>
<!-- 缓冲区大小 -->
<property>
<name>io.file.buffer.size</name>
<value>4096</value>
</property>
<!-- 开启hdfs的垃圾桶机制,删除掉的数据可以从垃圾桶中回收,单位分钟 -->
<property>
<name>fs.trash.interval</name>
<value>10080</value>
</property>
</configuration>
vim etc/hadoop/hdfs-site.xml
<configuration>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>node-1:50090</value>
</property>
<!-- 指定namenode的访问地址和端口 -->
<property>
<name>dfs.namenode.http-address</name>
<value>node-1:50070</value>
</property>
<!-- 指定namanode元数据的存放位置 -->
<property>
<name>dfs.namenode.name.dir</name>
<value>file:///usr/local/hadoop-2.9.2/data/namenodeData,file:///usr/local/hadoop-2.9.2/data/namenodeData2</value>
</property>
<!-- 指定datanode数据存储位置 -->
<property>
<name>dfs.datanode.data.dir</name>
<value>file:///usr/local/hadoop-2.9.2/data/datanodeData,file:///usr/local/hadoop-2.9.2/data/datanodeData2</value>
</property>
<!-- 指定namenode日志文件的存放目录 -->
<property>
<name>dfs.namenode.edits.dir</name>
<value>file:///usr/local/hadoop-2.9.2/data/nn/edits</value>
</property>
<property>
<name>dfs.namenode.checkpoint.dir</name>
<value>file:///usr/local/hadoop-2.9.2/data/snn/name</value>
</property>
<property>
<name>dfs.namenode.checkpoint.edits.dir</name>
<value>file:///usr/local/hadoop-2.9.2/data/dfs/snn/edits</value>
</property>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
<property>
<name>dfs.permissions</name>
<value>false</value>
</property>
<!-- 设置一个文件切片的大小:128M -->
<property>
<name>dfs.blocksize</name>
<value>134217728</value>
</property>
</configuration>
cat etc/hadoop/mapred-site.xml
<configuration>
<!-- 开启mr小任务模式 -->
<property>
<name>mapreduce.job.ubertask.enable</name>
<value>true</value>
</property>
<!-- 设置历史任务的主机和端口 -->
<property>
<name>mapreduce.jobhistory.address</name>
<value>node-1:10020</value>
</property>
<!-- 设置网页访问历史任务的主机和端口 -->
<property>
<name>mapreduce.jobhistory.webapp.address</name>
<value>node-1:19888</value>
</property>
</configuration>
cat etc/hadoop/yarn-site.xml
<configuration>
<!-- 配置yarn主界节点的位置 -->
<property>
<name>yarn.resourcemanager.hostname</name>
<value>node-1</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<!-- 开启日志聚合功能 -->
<property>
<name>yarn.log-aggregation-enable</name>
<value>true</value>
</property>
<!-- 设置聚合日志在hdfs上的保存时间 -->
<property>
<name>yarn.log-aggregation.retain-seconds</name>
<value>604800</value>
</property>
<!-- 设置yarn集群内存分配方案 -->
<property>
<name>yarn.nodemanager.resource.memory-mb</name>
<value>20480</value>
</property>
<property>
<name>yarn.scheduler.minimum-allocation-mb</name>
<value>2048</value>
</property>
<property>
<name>yarn.nodemanager.vmem-pmem-ratio</name>
<value>2.1</value>
</property>
</configuration>
cat etc/hadoop/hadoop-env.sh
#export JAVA_HOME=${JAVA_HOME}
export JAVA_HOME=/usr/local/jdk1.8.0_91
cat etc/hadoop/mapred-env.sh
export JAVA_HOME=/usr/local/jdk1.8.0_91
cat etc/hadoop/slaves
node-1
node-2
node-3
4、创建文件目录
mkdir -p /usr/local/hadoop-2.9.2/data/tmpData
mkdir -p /usr/local/hadoop-2.9.2/data/namenodeData
mkdir -p /usr/local/hadoop-2.9.2/data/namenodeData2
mkdir -p /usr/local/hadoop-2.9.2/data/datanodeData
mkdir -p /usr/local/hadoop-2.9.2/data/datanodeData2
mkdir -p /usr/local/hadoop-2.9.2/data/nn/edits
mkdir -p /usr/local/hadoop-2.9.2/data/snn/name
mkdir -p /usr/local/hadoop-2.9.2/data/dfs/snn/edits
5、将其复制到其他节点
scp -r /usr/local/hadoop-2.9.2/ node-2:/usr/local/
scp -r /usr/local/hadoop-2.9.2/ node-3:/usr/local/
6、配置环境变量
export HADOOP_HOME=/usr/local/hadoop-2.9.2
export PATH=$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH
7、启动集群
# 格式化 执行一次
bin/hdfs namenode -format
sbin/start-dfs.sh
sbin/start-yarn.sh
sbin/mr-jobhistory-daemon.sh start historysever
# 查看
[root@node-1 hadoop-2.9.2]# jps
4320 SecondaryNameNode
3985 NameNode
5265 JobHistoryServer
4883 ResourceManager
4132 DataNode
5453 Jps
27199 QuorumPeerMain
[root@node-2 hadoop-2.9.2]# jps
18289 QuorumPeerMain
19556 DataNode
19693 NodeManager
19887 Jps
[root@node-3 hadoop-2.9.2]# jps
19394 DataNode
19531 NodeManager
18156 QuorumPeerMain
19724 Jps
8、访问
http//node-1:50070 # 查看hdfs
http//node-1:8088 # 查看yarn集群
http//node-1:19888 # 查看历史完成任务