页面树结构
转至元数据结尾
转至元数据起始

正在查看旧版本。 查看 当前版本.

与当前比较 查看页面历史

« 前一个 版本 3 当前 »

图比较多,下载附件看。Ubuntu hadoop 2.2+hive 0.12安装配置流程.docx

在\\192.168.1.9\10.虚拟机备份 中有安装好的虚拟机。

---------------------------------------

Ubuntu hadoop 2.2+hive 0.12安装配置流程

 

环境 ubuntu linux 12.04 32位桌面版,默认linux用户hu。

1.安装java

下载JDK压缩包,解压到/usr/java目录

修改环境变量; /etc/environment;   /etc/profile

 

 

命令行 source /etc/environment  / source /etc/profile使配置生效。

命令行 java –version ,确认java环境配置好。

 

2.安装hadoop

  1. 下载hadoop2.2版本。创建目录 /home/hduser。
  2.  执行tar zxf hadoop-2.2.0.tar.gz解压至当前目录/home/hduser目录下。

 

 

3:配置hadoop:

  1. 编辑/home/hduser/hadoop/etc/hadoop/hadoop-env.sh,如下。

 

  1. 编辑/home/hduser/hadoop/etc/hadoop/core-site.xml,在<configuration>中添加如下:

<property>

  <name>hadoop.tmp.dir</name>

 <value>/home/hduser/hadoop/tmp/hadoop-${user.name}</value>

 <description>A base for other temporarydirectories.</description>

</property>

<property>

 <name>fs.default.name</name>

 <value>hdfs://localhost:8010</value>

 <description>The name of the default file system.  A URI whose

 scheme and authority determine the FileSystem implementation.  The

 uri's scheme determines the config property (fs.SCHEME.impl) naming

 the FileSystem implementation class. The uri's authority is used to

 determine the host, port, etc. for a filesystem.</description>

</property>

备注:配置了/home/hduser/hadoop/tmp/这个目录,必须执行mkdir /home/hduser/hadoop/tmp/创建它,否则后面运行会报错。

 

 

 

编辑/home/hduser/hadoop/etc/hadoop/mapred-site.xml:

(1) mv /home/hduser/hadoop/etc/hadoop/mapred-site.xml.template/ home/hduser/hadoop/etc/hadoop/mapred-site.xml

(2)   在<configuration>中添加如下:

<property>

 <name>mapred.job.tracker</name>

 <value>localhost:54311</value>

 <description>The host and port that the MapReduce job tracker runs  at.  If "local", thenjobs are run in-process as a single map and reduce task.

  </description>

</property>

<property>

 <name>mapred.map.tasks</name>

 <value>10</value>

 <description>As a rule of thumb, use 10x the number of slaves(i.e., number of tasktrackers).  </description>

</property>

<property>

 <name>mapred.reduce.tasks</name>

 <value>2</value>

 <description>As a rule of thumb, use 2x the number of slaveprocessors (i.e., number of tasktrackers).

  </description>

</property>

 

 

 

编辑/home/hduser/hadoop/etc/hadoop/hdfs-site.xml,在<configuration>中添加如下:

<property>

 <name>dfs.replication</name>

 <value>1</value>

 <description>Default block replication.

 The actual number of replications can be specified when the file iscreated.

 The default is used if replication is not specified in create time.

  </description>

</property>

 

 

 

4:运行Hadoop

在初次运行Hadoop的时候需要初始化Hadoop文件系统,命令如下:

$cd /home/hduser/hadoop/bin

$./hdfs namenode -format

如果执行成功,你会在日志中(倒数几行)找到如下成功的提示信息:

common.Storage: Storage directory/home/hduser/hadoop/tmp/hadoop-hduser/dfs/name has been successfully formatted.

运行命令如下:

$cd /home/hduser/hadoop/sbin/

$./start-dfs.sh

注:该过程需要多次输入密码, 如果不想多次输入密码,可先用ssh建立信任。

hduser@ubuntu:~/hadoop/sbin$ jps

4266 SecondaryNameNode

4116 DataNode

4002 NameNode

注:用jps查看启动了三个进程。

$./start-yarn.sh

hduser@ubuntu:~/hadoop/sbin$ jps

4688 NodeManager

4266 SecondaryNameNode

4116 DataNode

4002 NameNode

4413 ResourceManager

 

5:查看Hadoop资源管理器

http://192.168.128.129:8088/,将其中的192.168.128.129替换为你的实际IP地址。

6:测试Hadoop

cd /home/hduser

$wget http://www.gutenberg.org/cache/epub/20417/pg20417.txt

$cd hadoop

$ bin/hdfs dfs -mkdir /tmp

$ bin/hdfs dfs -copyFromLocal /home/hduser/pg20417.txt /tmp

bin/hdfs dfs -ls /tmp

$bin/hadoop jar./share/hadoop/mapreduce/hadoop-mapreduce-examples-2.2.0.jar wordcount /tmp//tmp-output

如果一切正常的话,会输入相应的结果,可以从屏幕输出看到。

 八:停止Hadoop

若停止hadoop,依次运行如下命令:

$./stop-yarn.sh

$./stop-dfs.sh

安装Hive

 

Hive解压到 /home/hduser/hive-0.12.0目录。

 

修改环境变量 /etc/profile

 

 

Source /etc/profile ,使环境变量生效。

 

3、配置文件

在目录 <HIVE_HOME>/conf 目录下有4个模板文件:

1

hive-default.xml.template

2

hive-env.sh.template

3

hive-exec-log4j.properties.template

4

hive-log4j.properties.template

copy 生成四个配置文件然后既可自定义相关属性:

 

       $ copy hive-default.xml.template hive-site.xml

       $ copy hive-env.sh.template hive-env.sh

       $ copy hive-exec-log4j.properties.template hive-exec-log4j.properties

       $ copy hive-log4j.properties.template hive-log4j.properties

 

 

 

不过官方0.12.0的发布版本中的 hive-default.xml.template 中有 bug,在 2000行:

<value>auth</auth>  修改为:<value>auth</value>

 

 

命令行 schematool -dbType derby –initSchema,初始化知识库。

查看初始化后的信息: schematool -dbType derby –info

 

修改配置文件

第一次运行前先将 hive.metastore.schema.verification 设为false

1     ......

2     <!-- 设为false 不做验证-->

3     <name>hive.metastore.schema.verification</name>

4     <value>false</value>

 

 

知识库创业完成后,修改ConnectionURL,将create=true改为create=false,避免每次启动hive都要重建一次元数据库。

 

修改bind.host,原值为localhost,修改为ip地址。

 

 

配置hdfs中得目录和权限

 

1     $ hdfs dfs -mkdir       /tmp

2     $ hdfs dfs -mkdir       /user/hive

2     $ hdfs dfs -mkdir       /user/hive/warehouse

3     $ hdfs dfs -chmod g+w   /tmp

4     $ hdfs dfs -chmod g+w   /user/hive/warehouse

这里不是在linux下建立的目录,而是hadoop hdfs下的目录。

 

 

测试Hive,命令行 hive。

 

 

启动hiveserver2

Hive –service hiveserver2

 

 

用hive自带的beeline工具查询数据

 

 

在Smartbi中连接hive

首先替换lib中的hive jdbc驱动。

 

 

  • 无标签