w配置Hadoop

Hadoop全分布(防火墙全部关闭)

systenctl stop firewalld

firewall-cmd   --state

修改三台虚拟机主机名,分别为master、slave1、slave2

[[email protected] ~]# hostnamectl set-hostname master
[[email protected] ~]# bash

[[email protected] ~]# hostnamectl set-hostname slave1
[[email protected] ~]# bash

[[email protected] ~]# hostnamectl set-hostname slave2
[[email protected] ~]# bash

查看IP,修改hosts文件

[[email protected] ~]# ifconfig

[[email protected] ~]# ifconfig

[[email protected] ~]# ifconfig

[[email protected] ~]# vi /etc/hosts (IP+master ip+slave1 ip+slave2)

分发hosts文件

[[email protected] ~]# scp /etc/hosts slave1:/etc/

[[email protected] ~]# scp /etc/hosts slave2:/etc/

ssh无密登录

创建密钥对

[[email protected] ~]# ssh-keygen -t rsa -P ''
[[email protected] ~]# ssh-keygen -t rsa -P ''
[[email protected] ~]# ssh-keygen -t rsa -P ''

复制公钥

[[email protected] ~]# ssh-copy-id master
[[email protected] ~]# ssh-copy-id slave1
[[email protected] ~]# ssh-copy-id slave2

测试登录

[[email protected] ~]# ssh slave1

java的安装配置

解压缩

[[email protected] ~]# tar -zxvf /h3cu/jdk-8u144-linux-x64.tar.gz -C /usr/local/src

配置环境变量

[[email protected] ~]# vi /root/.bash_profile

添加配置:

export JAVA_HOME=/usr/local/src/jdk1.8.0_144
export JRE_HOME=/usr/local/src/jdk1.8.0_144/jre
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

[[email protected] ~]# source /root/.bash_profile

[[email protected] ~]# java -version

安装配置hadoop

解压缩

[[email protected] ~]# tar -zxvf /h3cu/hadoop-2.7.1.tar.gz -C /usr/local/src

重命名hadoop

[[email protected] ~]# mv /usr/local/src/hadoop-2.7.1/ /usr/local/src/hadoop

配置环境变量

[[email protected] ~]# vi /root/.bash_profile

添加配置:

export HADOOP_HOME=/usr/local/src/hadoop
export PATH=$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH

[[email protected] ~]# source /root/.bash_profile

[[email protected] ~]# hadoop version

修改hadoop-env.sh配置文件

[[email protected] ~]# cd /usr/local/src/hadoop/etc/hadoop/

[[email protected] hadoop]# vi hadoop-env.sh

修改java路径

export JAVA_HOME=/usr/local/src/jdk1.8.0_144

修改core-site.xml配置文件

[[email protected] hadoop]# vi core-site.xml

添加配置:

<property>
           <name>fs.defaultFS</name>
           <value>hdfs://master:9000</value>
</property>

<property>
           <name>io.file.buffer.size</name>
           <value>131072</value>
</property>

<property>
           <name>hadoop.tmp.dir</name>
           <value>file:/usr/local/src/hadoop/tmp</value>
</property>

[[email protected] hadoop]# vi hdfs-site.xml

添加配置:

<property>
           <name>dfs.namenode.name.dir</name>
           <value>file:/usr/local/src/hadoop/dfs/name</value>
</property>

<property>
           <name>dfs.datanode.data.dir</name>
           <value>file:/usr/local/src/hadoop/dfs/data</value>
</property>

<property>
           <name>dfs.replication</name>  
           <value>3</value>
</property>

[[email protected] hadoop]# vi yarn-site.xml

添加配置:

<property>
           <name>yarn.resourcemanager.address</name>
           <value>master:8032</value>
</property>

<property>
           <name>yarn.resourcemanager.scheduler.address</name>
           <value>master:8030</value>
</property>

<property>
           <name>yarn.resourcemanager.resource-tracker.address</name>
           <value>master:8031</value>
</property>

<property>
           <name>yarn.resourcemanager.admin.address</name>
           <value>master:8033</value>
</property>

<property>
           <name>yarn.resourcemanager.webapp.address</name>
           <value>master:8088</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>

[[email protected] hadoop]# cp mapred-site.xml.template mapred-site.xml

[[email protected] hadoop]# vi mapred-site.xml

添加配置:

<property>
               <name>mapreduce.framework.name</name>
               <value>yarn</value>
</property>

<property>
               <name>mapreduce.jobhistory.address</name>
               <value>master:10020</value>
</property>

<property>
               <name>mapreduce.jobhistory.webapp.address</name>
               <value>master:19888</value>
</property>

[[email protected] hadoop]# vi masters

添加配置:

master

[[email protected] hadoop]# vi slaves

 添加配置:

slave1
slave2

新建目录

[[email protected] hadoop]# mkdir /usr/local/src/hadoop/tmp

[[email protected] hadoop]# mkdir /usr/local/src/hadoop/dfs/name -p

[[email protected] hadoop]# mkdir /usr/local/src/hadoop/dfs/data -p

分发环境变量文件

[[email protected] hadoop]# scp /root/.bash_profile slave1:/root
[[email protected] hadoop]# scp /root/.bash_profile slave2:/root

分发java文件和hadoop

[[email protected] hadoop]# scp -r /usr/local/src/* slave1:/usr/local/src

[[email protected] hadoop]# scp -r /usr/local/src/* slave2:/usr/local/src

格式化

[[email protected] hadoop]# hdfs namenode -format

启动集群

[[email protected] hadoop]# start-all.sh

[[email protected] hadoop]# jps

Hadoop伪分布(防火墙全部关闭)systemctl status firewalld

修改主机名

[[email protected] ~]# hostnamectl set-hostname master
[[email protected] ~]# bash

查看IP

[[email protected] ~]# ifconfig

修改hosts文件

[[email protected] ~]# vi /etc/hosts

在文件末尾添加IP与主机名映射

SSH无密登录

生成密钥对

[[email protected] ~]# ssh-keygen -t rsa -P ''

复制公钥

[[email protected] ~]# ssh-copy-id master

测试登录

[[email protected] ~]# ssh master

JDK的安装和配置

查看本机是否自带openjdk

[[email protected] ~]# rpm -qa | grep openjdk

如果有,使用命令卸载

rpm -e --nodeps +软件包

解压jdk包

[[email protected] ~]# tar -zxvf /h3cu/jdk-8u144-linux-x64.tar.gz -C /usr/local/src

配置环境变量

[[email protected] ~]# vi /root/.bash_profile

添加以下环境变量

export JAVA_HOME=/usr/local/src/jdk1.8.0_144
export JRE_HOME=/usr/local/src/jdk1.8.0_144/jre
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

使环境变量生效    如果没有生效export PATH=/usr/bin

[[email protected] ~]# source /root/.bash_profile
[[email protected] ~]# java  -version

安装配置hadoop

解压缩hadoop安装包

[[email protected] ~]# tar -zxvf /h3cu/hadoop-2.7.1.tar.gz -C /usr/local/src

重命名hadoop目录

[[email protected] ~]# mv /usr/local/src/hadoop-2.7.1/ /usr/local/src/hadoop

配置hadoop环境变量

[[email protected] ~]# vi /root/.bash_profile

添加环境变量

export HADOOP_HOME=/usr/local/src/hadoop
export PATH=$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH

[[email protected] ~]# source /root/.bash_profile

修改hadoop-env.sh文件

[[email protected] ~]# cd /usr/local/src/hadoop/etc/hadoop/

[[email protected] hadoop]# vi hadoop-env.sh

修改java路径

export JAVA_HOME=/usr/local/src/jdk1.8.0_144

修改core-site.xml文件

添加配置:

<property>
    <name>fs.defaultFS</name>
    <value>hdfs://master:9000</value>
</property>

<property>
    <name>hadoop.tmp.dir</name>
    <value>/usr/local/src/hadoop/tmp</value>
</property>

创建临时目录

[email protected] hadoop]# mkdir /usr/local/src/hadoop/tmp

修改hdfs-site.xml文件

[[email protected] hadoop]# vi hdfs-site.xml

添加配置:

<property>
   <name>dfs.datanode.ipc.address</name>
   <value>master:50020</value>
</property>

<property>
   <name>dfs.datanode.http.address</name>
   <value>master:50075</value>
</property>

<property>
   <name>dfs.replication</name>
   <value>1</value>
</property>

修改yarn-site.xml文件

[[email protected] hadoop]# vi yarn-site.xml

添加配置:

<property>
   <name>yarn.nodemanager.aux-services</name>
   <value>mapreduce_shuffle</value>
</property>

修改mapred-site.xml文件

[[email protected] hadoop]# cp mapred-site.xml.template mapred-site.xml

[[email protected] hadoop]# vi mapred-site.xml

添加配置:

<property>
    <name>mapreduce.framework.name</name>
    <value>yarn</value>
</property>

<property>
    <name>mapreduce.jobhistory.address</name>
    <value>master:10020</value>
</property>

<property>
    <name>mapreduce.jobhistory.webapp.address</name>
    <value>master:19888</value>
</property>

修改masters文件

[[email protected] hadoop]# vi masters

添加配置:

master

修改slaves文件

[[email protected] hadoop]# vi slaves

master

格式化

[[email protected] hadoop]# hdfs namenode -format

[[email protected] hadoop]# start-all.sh

[[email protected] hadoop]# jps

Hive配置

基于hadoop集群+mysql5.7

解压缩

[[email protected] ~]# tar -zxvf /h3cu/apache-hive-1.1.0-bin.tar.gz -C /usr/local/src

重命名Hive目录

[[email protected] ~]# mv /usr/local/src/apache-hive-1.1.0-bin/ /usr/local/src/hive

设置环境变量

[[email protected] ~]# vi /root/.bash_profile

添加:

export HIVE_HOME=/usr/local/src/hive
export PATH=$HIVE_HOME/bin:$PATH

[[email protected] ~]# source /root/.bash_profile

修改配置文件

[[email protected] ~]# cd /usr/local/src/hive/conf/

[[email protected] conf]# cp hive-default.xml.template hive-site.xml

[[email protected] conf]# vi hive-site.xml

通过vi编辑器修改hive-site.xml文件实现Hive连接MySQL数据库,并设定Hive临时文件存储路径。

[[email protected] ~]# vi /usr/local/src/hive/conf/hive-site.xml

1)设置MySQL数据库连接。

<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://master:3306/hive?createDatabaseIfNotExist=true&useSSL=false</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>

2)配置MySQL数据库root的密码。

<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>Password123$</value>
<description>password to use against s database</description>
</property>

3)配置数据库驱动。

<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>

4)配置数据库用户名javax.jdo.option.ConnectionUserName为root。

<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>Username to use against metastore database</description>
</property>

5)将以下位置的${system:java.io.tmpdir}/${system:user.name}替换为“/usr/local/src/hive/tmp”目录及其子目录。

需要替换以下4处配置内容:

  <name>hive.querylog.location</name>
  <value>/usr/local/src/hive/tmp</value>

  <name>hive.exec.local.scratchdir</name>
  <value>/usr/local/src/hive/tmp</value>

  <name>hive.downloaded.resources.dir</name>
  <value>/usr/local/src/hive/tmp/resources</value>

  <name>hive.server2.logging.operation.log.location</name>
  <value>/usr/local/src/hive/tmp/operation_logs</value>

6)在Hive安装目录中创建临时文件夹tmp。

[[email protected] ~]# mkdir /usr/local/src/hive/tmp

至此,Hive组件安装和配置完成。

初始化hive元数据

将mysql驱动拷贝到hive目录下的lib

[[email protected] ~]# cp /h3cu/mysql-connector-java-5.1.46.jar /usr/local/src/hive/lib/

[[email protected] ~]# schematool -initSchema -dbType mysql

进入hive终端

Sqoop配置

基于hadoop集群和mysql数据库start-all.sh

解压缩安装包

[[email protected] ~]# tar -zxvf /h3cu/sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz -C /usr/local/src

重命名sqoop目录

[[email protected] ~]# mv /usr/local/src/sqoop-1.4.7.bin__hadoop-2.6.0/ /usr/local/src/sqoop

配置sqoop环境变量

[[email protected] ~]# vi /root/.bash_profile

添加配置:

export SQOOP_HOME=/usr/local/src/sqoop
export PATH=$SQOOP_HOME/bin:$PATH

[[email protected] ~]# source /root/.bash_profile

[[email protected] ~]# cd /usr/local/src/sqoop/conf/

[[email protected] conf]# cp sqoop-env-template.sh sqoop-env.sh

[[email protected] conf]# vi sqoop-env.sh

添加配置:

export HADOOP_COMMON_HOME=/usr/local/src/hadoop
export HADOOP_MAPRED_HOME=/usr/local/src/hadoop
export HBASE_HOME=/usr/local/src/hbase
export HIVE_HOME=/usr/local/src/hive

[[email protected] conf]# cp /h3cu/mysql-connector-java-5.1.46.jar /usr/local/src/sqoop/lib/

[[email protected] conf]# sqoop list-databases --connect jdbc:mysql://127.0.0.1:3306/ --username root -P

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
下一篇>>