Giter VIP home page Giter VIP logo

sparksql-hbase-example's Introduction

SPARKSQL-HBASE-EXAMPLE

集群的搭建和启动

部署

在虚拟机上部署了三个节点的Hadoop和Hbase集群,如下:

主机名\应用 HDFS YARN HBASE Zookeeper
centos03 NameNode,DataNode NodeManager HMaster QuorumPeerMain
centos04 DataNode ResourceManager,NodeManager HRegionServer QuorumPeerMain
centos05 NameNode,DataNode ResourceManager,NodeManager HRegionServer QuorumPeerMain

步骤

搭建集群的步骤可以参考:Zookeeper集群搭建Hadoop集群搭建Hbase集群搭建

启动

启动Zookeeper、HDFS、YARN和HBASE。

为了更加方便的启动和关闭集群,我写了几个简要的脚本(src/resources/shells中的三个脚本)

只需要在一台机子上分别执行:

./zookeeper-cluster.sh start

./hadoop-cluster.sh start

./myhbase.sh start

就能快速的启动集群了。

数据迁移

使用sqoop将数据从mysql中迁移到Hbase中

客户端连接HBase集群

1.需要创建一个_org.apache.hadoop.conf.Configuration_对象:

val conf: Configuration = HBaseConfiguration.create()

2.需要获取到zookeeper的参数,有两种方法:

第一种方法是获取获取Linux中的Hbase安装目录中的hbase-site.xml这个配置文件的路径,可以这样获取:

conf.addResource(new Path(System.getenv("HBASE_CONF_DIR"), "hbase-site.xml"))

其中"HBASE_CONF_DIR"是环境变量中设置的参数。

即_cat /etc/profile_中的_export HBASE_CONF_DIR=/opt/hbase-1.1.2/conf_

第二种方法在代码中直接设置_hbase.zookeeper.quorum_的值,如下:

conf.set("hbase.zookeeper.quorum", "centos03:2181,centos04:2181,centos05:2181")

测试

使用scalatest对每个关键方法进行自测

sparksql-hbase-example's People

Contributors

luciuschina avatar zj-lingxin avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.