0%

1.下载jkd( http://www.oracle.com/technetwork/java/javase/downloads/index.html)

  • 对于32位的系统可以下载以下两个Linux x86版本(uname -a 查看系统版本)

  • 264位系统下载Linux x64版本

2.安装jdk(这里以.tar.gz版本,32位系统为例)

安装方法参考http://docs.oracle.com/javase/7/docs/webnotes/install/linux/linux-jdk.html

  • 选择要安装java的位置,如/usr/目录下,新建文件夹java(mkdir java)

  • 将文件jdk-7u40-linux-i586.tar.gz移动到/usr/java

  • 解压:tar -zxvf jdk-7u40-linux-i586.tar.gz

  • 删除jdk-7u40-linux-i586.tar.gz(为了节省空间)

至此,jkd安装完毕,下面配置环境变量

3.打开

1
/etc/profile(vim /etc/profile)

在最后面添加如下内容:

1
2
3
4
JAVA_HOME=/usr/java/jdk1.7.0_40
CLASSPATH=.:$JAVA_HOME/lib.tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH

4.生效

1
source /etc/profile

5.验证是否安装成功:java -version

一、hostname 修改详解

  1. 暂时性修改使用命令:
    1
    hostname ******
    此命令不用重启,重新打开一个终端,即可看到修改。但是重启后失效(本人red hat5竟然不会)
  2. 永久性修改
在1之后,修改 /etc/sysconfig/network

二、配置ssh

本节参考:网址

  1. 生成公钥
    1
    $ssh-keygen 
  2. 公钥分发到远程主机
    1
    $ ssh-copy-id user@host

1
2
3
4
5
6
7
8
9
10
11
12
13
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
df:a8:ff:b2:0d:f8:1c:a9:d9:f9:fa:39:29:9d:6f:42.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:13
RSA host key for lab3 has changed and you have requested strict checking.
Host key verification failed.

问题解决:
删除/root/.ssh/known_hosts:13行中的信息即可


1.Hbase web整合报以下错误
SEVERE: Servlet.service() for servlet [jsp] in context with path [] threw exception [java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;] with root cause
java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;
解决方案
pom文件中排出冲突jar

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 <!-- hbase -->
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>1.0.0-cdh5.4.0</version>
<exclusions>
<exclusion>
<artifactId>jasper-compiler</artifactId>
<groupId>tomcat</groupId>
</exclusion>
<exclusion>
<artifactId>jasper-runtime</artifactId>
<groupId>tomcat</groupId>
</exclusion>
</exclusions>
</dependency>

2.Hbase jar引入,pom报错误Missing artifact jdk.tools:jdk.tools:jar:1.7
** 解决方案**
eclipse.ini (before -vmargs!):


-vm
C:/{your_path_to_jdk170}/jre/bin/server/jvm.dll

出现该错误的原因是eclipse bug ,eclipse打开使用的是jre 不是jdk下面的jre ,因此未找到tools.jar


3.eclipse java api 访问hbase 失败
** 解决方案**

  • zookeeper工作是否正常
  • 防火墙是否关闭

背景

&emsp;hadoop体系中许多数据是存放在hbase中,为了便捷实用其中的数据,可以将数据迁移到hive中,通过hive sql 可以迅速便捷的获取并操作相应的数据,同时还可以实用hive sql实现一些mapreduce 操作。具体hive优势详见官网

目的

将hbase已存在的表数据迁移到hive中

操作步骤

版本环境

soft version
hive hive-1.1.0-cdh5.4.0
hbase hbase-1.0.0-cdh5.4.0

准备

首先要确保HIVE_HOME/lib 下HBase的jar包的版本要和实际环境中HBase的版本一致,需要用HBASE_HOME/lib/目录下得jar包:


hbase-client-1.0.0-cdh5.4.0.jar 
hbase-common-1.0.0-cdh5.4.0-tests.jar
hbase-common-1.0.0-cdh5.4.0.jar
hbase-protocol-1.0.0-cdh5.4.0.jar
hbase-server-1.0.0-cdh5.4.0.jar
htrace-core-3.0.4.jar
htrace-core-3.1.0-incubating.jar 

复制到HIVE_HOME/lib 下

操作及测试

  1. hbase现有数据表如下:
    
    hbase(main):002:0> scan 'truman'
    ROW                        COLUMN+CELL

row2 column=personal:city, timestamp=1458635086205, value=beijing
row2 column=personal:name, timestamp=1458635086189, value=reason2
row2 column=professional:designation, timestamp=1458635086210, value=test
1 row(s) in 0.5910 seconds

2. 新建hive与hbase关联表hbase_table_1


[root@127.0.0.1 hive-1.1.0-cdh5.4.0]$ bin/hive
Logging initialized using configuration in jar:file:/data/bigdata/hive-1.1.0-cdh5.4.0/lib/hive-common-1.1.0-cdh5.4.0.jar!/hive-log4j.properties
WARNING: Hive CLI is deprecated and migration to Beeline is recommended.
hive> CREATE external TABLE hbase_table_1(key int, value string) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,personal:name") TBLPROPERTIES ("hbase.table.name" = "truman");
OK
Time taken: 0.857 seconds
  1. 即可在关联表中查询hbase中truman表的数据
    
    hive> show tables;
    OK
    hbase_table_1
    Time taken: 0.272 seconds, Fetched: 1 row(s)
    hive> select * from hbase_table_1;
    OK
    NULL    reason2
    Time taken: 0.625 seconds, Fetched: 1 row(s)

总结

&emsp;可以通过关联表实现hbase数据迁移到hive中,同理,hive中数据也可以通过该表迁移到hbase中。
在新建关联表一定要注意,hbase表存在则使用external。如果不存在则可以不需要该关键字

参考

http://www.micmiu.com/bigdata/hive/hive-hbase-integration/

问题1

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. org/apach e/hadoop/hbase/mapreduce/TableInputFormatBase

** 解决方法:**


将hbase/lib下
hbase-common-1.0.0-cdh5.4.0-tests.jar
hbase-common-1.0.0-cdh5.4.0.jar
copy到hive/lib下面

问题2

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaExcep tion(message:MetaException(message:java.io.IOException: java.lang.reflect.InvocationTargetExc eption
** 解决方法:**


将hbase/lib下
htrace-core-3.0.4.jar
htrace-core-3.1.0-incubating.jar
copy到hive/lib下面

问题3

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:MetaException(message:Table truman already exists within HBase; use CREATE EXTERNAL TABLE instead to register it in Hive.)
** 解决方法:**


使用 external
例如:


 create external table hive(id string,name string ,ct string)stored by   'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with serdeproperties ("hbase.columns.mapping"= ":key,cf:name,cf:ct") tblproperties ("hbase.table.name" = "hbase");

问题4 hive中建hbase关联表失败

** 解决方法:**


首先要确保

HIVE_HOME/lib 
下HBase的jar包的版本要和实际环境中HBase的版本一致,需要用
HBASE_HOME/lib/
目录下得jar包:


hbase-client-1.0.0-cdh5.4.0.jar 
hbase-common-1.0.0-cdh5.4.0-tests.jar
hbase-common-1.0.0-cdh5.4.0.jar
hbase-protocol-1.0.0-cdh5.4.0.jar
hbase-server-1.0.0-cdh5.4.0.jar
htrace-core-3.0.4.jar
htrace-core-3.1.0-incubating.jar 

复制到

HIVE_HOME/lib 
下。

搭建hbase单机版

目的

&emsp;本教程为了搭建一个hbas单机版本,搭建好可以便于练习使用hbase,选用的版本不是最新的,但搭建原理都是一样的。单机版数据存储在本地文件上,使用自带的zookeeper。

准备

1.下载hbase-0.94.27

安装与部署

Markdown语法学习

第一节:章节 项目

  • 部署
  • 实验
  • 测试

1.开发

2.发布

第二节:杂乱

分割线



代码


private byte[] row;
    private byte[] family;
    private byte[] column;
    private byte[] data;
    
    /**
     * @return the row
     */
    public byte[] getRow() {
        return row;
    }


链接

对我的额非非医用氨基酸S耗时

[医用]:http:www.baidu.com “百度无所不能”

强调

斜体 强调呢哦荣挨打的好多

粗体 强调呢哦荣挨打的好多

引用

&emsp;一盏灯, 一片昏黄; 一简书, 一杯淡茶。 守着那一份淡定, 品读属于自己的寂寞。 保持淡定, 才能欣赏到最美丽的风景! 保持淡定, 人生从此不再寂寞。

表格

Tables Are Cool
col 3 is right-aligned $1600
col 2 is centered $12
zebra stripes are neat $1

原始代码



#Markdown语法学习
##第一节:章节 项目
- 部署
- 实验
- 测试

 1.开发

 2.发布


##第二节:杂乱
**分割线**
___
***
**代码**


private byte[] row;
    private byte[] family;
    private byte[] column;
    private byte[] data;
    
    /**
     * @return the row
     */
    public byte[] getRow() {
        return row;
    }


链接

对我的额非非医用氨基酸S耗时

[医用]:http:www.baidu.com"百度无所不能

强调

斜体 强调呢哦荣挨打的好多

粗体 强调呢哦荣挨打的好多

引用

&emsp;一盏灯, 一片昏黄; 一简书, 一杯淡茶。 守着那一份淡定, 品读属于自己的寂寞。 保持淡定, 才能欣赏到最美丽的风景! 保持淡定, 人生从此不再寂寞。

表格

Tables Are Cool
col 3 is right-aligned $1600
col 2 is centered $12
zebra stripes are neat $1