https://blog.csdn.net/m0_59186440/article/details/122170209https://blog.csdn.net/m0_59186440/article/details/122170209icon-default.png?t=LA92https://blog.csdn.net/m0_59186440/article/details/122170209前文链接

前面一节我们完成了虚拟机的安装,下面我们进行配置

 

 

 

 

vi /etc/sysconfig/network-scripts/ifcfg-eth0

 

DEVICE=eth0
HWADDR=00:0C:29:16:AB:34
TYPE=Ethernet
#UUID=07c5088c-f83e-4e84-b2cb-32ae75117085
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static

IPADDR=192.168.106.131
NETMASK=255.255.255.0
GATEWAY=192.168.106.2
DNS1=192.168.106.2

 

 

 重启网络

service network restart

连接xshell

 

 二、安装yum软件

1. 进入yum配置文件夹

cd /etc/yum.repos.d/

修改之前的文件名

mv CentOS-Base.repo CentOS-Base.repo.bak

2.下载最新网络源

(注:如果命令运行失败,请自行搜索另外找一个运行)

curl -o /etc/yum.repos.d/CentOS-Base.repo  http://file.kangle.odata.cc/repo/Centos-6.repo

3.挂载镜像

mount /dev/dvd /media/

4.安装上传软件

yum install lrzsz –y

5.安装vim软件

yum install vim -y

 

 三、安装JDK

 1.上传jdk-8u121-linux-x64.tar.gz文件到/opt目录

jdk下载地址

https://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.htmlicon-default.png?t=LA92https://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html

 

 2.解压jdk文件

tar -zxvf jdk-8u121-linux-x64.tar.gz -C /usr/local

 

3.配置环境变量

vim /etc/profile

export JAVA_HOME=/usr/local/jdk1.8.0_121

export PATH=$JAVA_HOME/bin:$PATH

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

 

 4.环境变量生效

source /etc/profile

 5.检查jdk是否安装成功

java -version

四、搭建hadoop

1. 上传hadoop-2.7.4.tar.gz文件到/opt目录

下载地址版本2.7.4

https://archive.apache.org/dist/hadoop/common/https://archive.apache.org/dist/hadoop/common/icon-default.png?t=LA92https://archive.apache.org/dist/hadoop/common/

2. 解压缩hadoop-2.7.4.tar.gz 文件

tar -zxvf hadoop-2.7.4.tar.gz -C /usr/local

解压后即可,看到/usr/local/hadoop-2.7.4文件夹

3.配置环境变量

vim /etc/profile

export HADOOP_HOME=/export/servers/hadoop-2.7.4
export PATH=$PATH:$HADOOP_HOME/bin:
$HADOOP_HOME/sbin

 

初始化环境变量

source /etc/profile

验证Hadoop是否成功安装配置,命令如下

hadoop version

 

hadoop-env.sh

配置Hadoop运行所需的环境变量

yarn-env.sh

配置Yarn运行所需的环境变量

core-site.xml

集群全局参数,用于定义系统级别的参数,如HDFS URLHadoop的临时目录

hdfs-site.xml

HDFS参数,如名称节点和数据节点的存放位置、文件副本的个数文件读取的权限

mapred-site.xml

MapReduce参数,包括JobHistory Server和应用程序参数两部分,如reduce任务的默认个数、任务所能够使用内存的默认上下限等

yarn-site.xml

集群资源管理系统参数,配置ResourceManagerNodeManager的通信端口,web监控端口等

 

 

  (在底部Configuration标签内添加以下Configuration标签内的内容,其他文件也是)

1.core-site.xml配置·

<configuration>
    <property>
    	<name>fs.defaultFS</name>  
        <value>hdfs://master:8020</value>  
      </property>  
    <property>
      <name>hadoop.tmp.dir</name>
      <value>/var/log/hadoop/tmp</value>
    </property>
</configuration>

 

2.hadoop-env.sh配置

export JAVA_HOME=/usr/local/jdk1.8.0_121

 

 

3.yarn-env.sh配置

export JAVA_HOME=/usr/local/jdk1.8.0_121

 

 

4.mapred-site.xml配置

复制cp mapred-site.xml.template mapred-site.xml

<configuration>
<property>
    <name>mapreduce.framework.name</name>
    <value>yarn</value>
</property>
<!-- jobhistory properties -->
<property>
    <name>mapreduce.jobhistory.address</name>
    <value>master:10020</value>
</property>
<property>
     <name>mapreduce.jobhistory.webapp.address</name>
     <value>master:19888</value>
</property>
</configuration>

5.yarn-site.xml配置

<configuration>
  <property>
    <name>yarn.resourcemanager.hostname</name>
    <value>master</value>
  </property>    
  <property>
    <name>yarn.resourcemanager.address</name>
    <value>${yarn.resourcemanager.hostname}:8032</value>
  </property>
  <property>
    <name>yarn.resourcemanager.scheduler.address</name>
    <value>${yarn.resourcemanager.hostname}:8030</value>
  </property>
  <property>
    <name>yarn.resourcemanager.webapp.address</name>
    <value>${yarn.resourcemanager.hostname}:8088</value>
  </property>
  <property>
    <name>yarn.resourcemanager.webapp.https.address</name>
    <value>${yarn.resourcemanager.hostname}:8090</value>
  </property>
  <property>
    <name>yarn.resourcemanager.resource-tracker.address</name>
    <value>${yarn.resourcemanager.hostname}:8031</value>
  </property>
  <property>
    <name>yarn.resourcemanager.admin.address</name>
    <value>${yarn.resourcemanager.hostname}:8033</value>
  </property>
  <property>
    <name>yarn.nodemanager.local-dirs</name>
    <value>/data/hadoop/yarn/local</value>
  </property>
  <property>
    <name>yarn.log-aggregation-enable</name>
    <value>true</value>
  </property>
  <property>
    <name>yarn.nodemanager.remote-app-log-dir</name>
    <value>/data/tmp/logs</value>
  </property>
<property> 
 <name>yarn.log.server.url</name> 
 <value>http://master:19888/jobhistory/logs/</value>
 <description>URL for job history server</description>
</property>
<property>
   <name>yarn.nodemanager.vmem-check-enabled</name>
    <value>false</value>
  </property>
 <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>
<property>  
        <name>yarn.nodemanager.resource.memory-mb</name>  
        <value>2048</value>  
 </property>  
 <property>  
        <name>yarn.scheduler.minimum-allocation-mb</name>  
        <value>512</value>  
 </property>   
 <property>  
        <name>yarn.scheduler.maximum-allocation-mb</name>  
        <value>4096</value>  
 </property> 
 <property> 
    <name>mapreduce.map.memory.mb</name> 
    <value>2048</value> 
 </property> 
 <property> 
    <name>mapreduce.reduce.memory.mb</name> 
    <value>2048</value> 
 </property> 
 <property> 
    <name>yarn.nodemanager.resource.cpu-vcores</name> 
    <value>1</value> 
 </property>
</configuration>

 

6.hdfs-site.xml配置

<configuration>
<property>
    <name>dfs.namenode.name.dir</name>
    <value>file:///data/hadoop/hdfs/name</value>
</property>
<property>
    <name>dfs.datanode.data.dir</name>
    <value>file:///data/hadoop/hdfs/data</value>
</property>
<property>
     <name>dfs.namenode.secondary.http-address</name>
     <value>master:50090</value>
</property>
<property>
     <name>dfs.replication</name>
     <value>3</value>
</property>
</configuration>

 

---------------- 以上master节点配置完成  -------------

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐