Hadoop-3.1.2完全分布式环境搭建过程图文详解(W(3)

  6.配置系统环境  

vi ~/.bash_profile
添加:
export JAVA_HOME=/bigdata/jdk1.8.0_221
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export HADOOP_HOME=/bigdata/hadoop-3.1.2
export HADOOP_INSTALL=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin<br><br>保存退出,让环境变量生效: 
source ~/.bash_profile 

 7.配置免密登录(重要)

ssh-keygen -t rsa (直接回车3次)
cd ~/.ssh/
ssh-copy-id -i id_rsa.pub root@Master 
ssh-copy-id -i id_rsa.pub root@Slave1 
ssh-copy-id -i id_rsa.pub root@Slave2 

测试是否成功配置(在配置完Slave之后测试):
ssh Slave1
可以登录到Slave1节点

五、配置Hadoop

  Hadoop-3.1.2中有许多坑,在2X版本中有些默认的不需要特别配置,但在Hadoop-3.1.2中需要。

  hadoop-env.sh配置:

cd /bigdata/hadoop-3.1.2/etc/hadoop/
vi hadoop-env.sh
添加:
export JAVA_HOME=/bigdata/jdk1.8.0_221
export HADOOP_HOME=/bigdata/hadoop-3.1.2
export PATH=$PATH:/bigdata/hadoop-3.1.2/bin
export HADOOP_OPTS="-Djava.library.path=${HADOOP_HOME}/lib/native" 
export HADOOP_PID_DIR=/bigdata/hadoop-3.1.2/pids //PID存放目录,若没有此配置则默认存放在tmp临时文件夹中,在启动和关闭HDFS时可能会报错
#export HADOOP_ROOT_LOGGER=DEBUG,console //先注释掉,有问题可以打开,将调试信息打印在console上

  hdfs-site.xml:

<configuration>
    <property>
   <name>dfs.replication</name>    //冗余度,默认为3
    <value>1</value>
 </property>
 <property>
 <name>dfs.datanode.data.dir</name>
 <value>/bigdata/hadoop-3.1.2/dfs/tmp/data</value>
 </property>
 <property>
 <name>dfs.namenode.name.dir</name>
 <value>/bigdata/hadoop-3.1.2/dfs/tmp/name</value>
 </property>
 <property>
 <name>dfs.permissions</name>
 <value>false</value>
 </property>
</configuration>

  mapred.site.xml:

<configuration>
 <property>
 <name>mapreduce.framework.name</name>
 <value>yarn</value>
 </property>
 <property>
 <name>mapred.job.tracker</name>
 <value>Master:9001</value>
 </property>
</configuration>

  yarn-site.xml:

<configuration>
 <property>
 <name>yarn.nodemanager.aux-services</name>
 <value>mapreduce_shuffle</value>
 </property>
 <property>
 <name>yarn.resourcemanager.hostname</name>
 <value>Master</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>
      

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/1506.html