国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Hbase數(shù)據(jù)庫(kù)完全分布式搭建以及java中操作Hbase

這篇具有很好參考價(jià)值的文章主要介紹了Hbase數(shù)據(jù)庫(kù)完全分布式搭建以及java中操作Hbase。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

1.基礎(chǔ)的環(huán)境準(zhǔn)備

基礎(chǔ)的環(huán)境準(zhǔn)備不在贅述,包括jdk安裝,防火墻關(guān)閉,網(wǎng)絡(luò)配置,環(huán)境變量的配置,各個(gè)節(jié)點(diǎn)之間進(jìn)行免密等操作等。使用的版本2.0.5.

2.完全分布式 Fully-distributed

參考官方文檔

分布式的部署,都是在單節(jié)點(diǎn)服務(wù)的基礎(chǔ)配置好配置,直接分發(fā)到其他節(jié)點(diǎn)即可。

2.1 配置文件hase-env.sh

jdk路徑的配置,以及不適用內(nèi)部自帶的zk.

export JAVA_HOME=/usr/java/default
export HBASE_MANAGES_ZK=false

2.2 hbase-site.xml

<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>hdfs://muycluster/hbase</value>
  </property>
  <property>
    <name>hbase.cluster.distributed</name>
    <value>true</value>
  </property>
  <property>
    <name>hbase.zookeeper.quorum</name>
    <value>node02,node03,node04</value>
  </property>
</configuration>

2.3 配置regionservers

配置集群regionserver的節(jié)點(diǎn)

node02
node03
node04

2.4 配置備用的master

conf/backup-masters

vi backup-masters
node03

2.5 HDFS客戶端配置

官方提供三種方式進(jìn)行配置

  • Add a pointer to your HADOOP_CONF_DIR to the HBASE_CLASSPATH environment variable in hbase-env.sh.

  • Add a copy of hdfs-site.xml (or hadoop-site.xml) or, better, symlinks, under ${HBASE_HOME}/conf, or

  • if only a small set of HDFS client configurations, add them to hbase-site.xml.
    一般我們都選擇第二種,直接將hadoop-site.xml配置拷貝到 ${HBASE_HOME}/conf即可

2.6 啟動(dòng)

[root@node01 /]# start-hbase.sh
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/bigdata/hbase-2.0.5/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/bigdata/hadoop-2.6.5/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
running master, logging to /opt/bigdata/hbase-2.0.5/logs/hbase-root-master-node01.out
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/bigdata/hbase-2.0.5/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/bigdata/hadoop-2.6.5/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
node02: running regionserver, logging to /opt/bigdata/hbase-2.0.5/bin/../logs/hbase-root-regionserver-node02.out
node04: running regionserver, logging to /opt/bigdata/hbase-2.0.5/bin/../logs/hbase-root-regionserver-node04.out
node03: running regionserver, logging to /opt/bigdata/hbase-2.0.5/bin/../logs/hbase-root-regionserver-node03.out
node04: running master, logging to /opt/bigdata/hbase-2.0.5/bin/../logs/hbase-root-master-node04.out

2.7 通過(guò)頁(yè)面查看節(jié)點(diǎn)信息

訪問(wèn)端口16010:http://node01:16010/master-status
Hbase數(shù)據(jù)庫(kù)完全分布式搭建以及java中操作Hbase

3. java中客戶端操作Hbase

3.1 引入依賴

   <!-- https://mvnrepository.com/artifact/org.apache.hbase/hbase-client -->
    <dependency>
      <groupId>org.apache.hbase</groupId>
      <artifactId>hbase-client</artifactId>
      <version>2.0.5</version>
    </dependency>
    <dependency>
      <groupId>org.apache.hbase</groupId>
      <artifactId>hbase-mapreduce</artifactId>
      <version>2.0.5</version>
    </dependency>

3.2 初始化創(chuàng)建連接

操作表Java API中主要提供了一個(gè)Admin對(duì)象進(jìn)行表的 操作。

HBase schemas can be created or updated using the The Apache HBase Shell or by using Admin in the Java API.

   Configuration conf = null;
    Connection conn = null;
    //表的管理對(duì)象
    Admin admin = null;
    Table table = null;
    //創(chuàng)建表的對(duì)象
    TableName tableName = TableName.valueOf("user");
    @Before
    public void init() throws IOException {
        //創(chuàng)建配置文件對(duì)象
        conf = HBaseConfiguration.create();
        //加載zookeeper的配置
        conf.set("hbase.zookeeper.quorum","node02,node03,node04");
        //獲取連接
        conn = ConnectionFactory.createConnection(conf);
        //獲取對(duì)象
        admin = conn.getAdmin();
        //獲取數(shù)據(jù)操作對(duì)象
        table = conn.getTable(tableName);
    }

3.3 操作Hbase數(shù)據(jù)庫(kù)

3.3.1 創(chuàng)建表

 /**
     * 創(chuàng)建表 主要使用Admin對(duì)象進(jìn)行表的創(chuàng)建
     * @throws IOException
     */
    @Test
    public void createTable() throws IOException {
        //定義表描述對(duì)象
        TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(tableName);
        //定義列族描述對(duì)象
        ColumnFamilyDescriptorBuilder columnFamilyDescriptorBuilder = ColumnFamilyDescriptorBuilder.newBuilder("cf".getBytes());
        //添加列族信息給表
        tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptorBuilder.build());
        if(admin.tableExists(tableName)){
            //禁用表
            admin.disableTable(tableName);
            admin.deleteTable(tableName);
        }
        //創(chuàng)建表
        admin.createTable(tableDescriptorBuilder.build());
    }

3.3.2 往創(chuàng)建的user表插入數(shù)據(jù)

  @Test
    public void insert() throws IOException {
        Put put = new Put(Bytes.toBytes("row1"));
        put.addColumn(Bytes.toBytes("cf"),Bytes.toBytes("name"),Bytes.toBytes("elite"));
        put.addColumn(Bytes.toBytes("cf"),Bytes.toBytes("age"),Bytes.toBytes("22"));
        put.addColumn(Bytes.toBytes("cf"),Bytes.toBytes("address"),Bytes.toBytes("gz"));
        table.put(put);
    }

Hbase數(shù)據(jù)庫(kù)完全分布式搭建以及java中操作Hbase文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-438516.html

3.3.3 使用get 查詢單條數(shù)據(jù)

 @Test
    public void get() throws IOException {
        Get get = new Get(Bytes.toBytes("row1"));
        //在服務(wù)端做數(shù)據(jù)過(guò)濾,挑選出符合需求的列
        get.addColumn(Bytes.toBytes("cf"),Bytes.toBytes("name"));
        get.addColumn(Bytes.toBytes("cf"),Bytes.toBytes("age"));
        get.addColumn(Bytes.toBytes("cf"),Bytes.toBytes("address"));
        Result result = table.get(get);
        Cell cell1 = result.getColumnLatestCell(Bytes.toBytes("cf"),Bytes.toBytes("name"));
        Cell cell2 = result.getColumnLatestCell(Bytes.toBytes("cf"),Bytes.toBytes("age"));
        Cell cell3 = result.getColumnLatestCell(Bytes.toBytes("cf"),Bytes.toBytes("address"));
        System.out.print(Bytes.toString(CellUtil.cloneValue(cell1))+" ");
        System.out.print(Bytes.toString(CellUtil.cloneValue(cell2))+" ");
        System.out.print(Bytes.toString(CellUtil.cloneValue(cell3)));

    }

3.3.4 scan 查詢數(shù)據(jù)

  /**
     * 獲取表中所有的記錄
     */
    @Test
    public void scan() throws IOException {
        Scan scan = new Scan();
        ResultScanner rss = table.getScanner(scan);
        for (Result rs: rss) {
            Cell cell1 = rs.getColumnLatestCell(Bytes.toBytes("cf"),Bytes.toBytes("name"));
            Cell cell2 = rs.getColumnLatestCell(Bytes.toBytes("cf"),Bytes.toBytes("age"));
            Cell cell3 = rs.getColumnLatestCell(Bytes.toBytes("cf"),Bytes.toBytes("address"));
            System.out.print(Bytes.toString(CellUtil.cloneValue(cell1))+" ");
            System.out.print(Bytes.toString(CellUtil.cloneValue(cell2))+" ");
            System.out.println(Bytes.toString(CellUtil.cloneValue(cell3)));
        }
    }

3.3.5 刪除數(shù)據(jù)

 /**
     * 刪除數(shù)據(jù)
     * @throws IOException
     */
    @Test
    public void delete() throws IOException {
        Delete delete = new Delete("row2".getBytes());
        table.delete(delete);
    }

3.4 關(guān)閉連接

 @After
    public void close(){
        try {
            table.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            admin.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            conn.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

到了這里,關(guān)于Hbase數(shù)據(jù)庫(kù)完全分布式搭建以及java中操作Hbase的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 大數(shù)據(jù)開(kāi)源框架環(huán)境搭建(五)——Hbase完全分布式集群的安裝部署

    大數(shù)據(jù)開(kāi)源框架環(huán)境搭建(五)——Hbase完全分布式集群的安裝部署

    目錄 實(shí)驗(yàn)環(huán)境: 實(shí)驗(yàn)步驟: 〇、Zookeeper安裝配置: 一、安裝前注意事項(xiàng) 二、HBase安裝 ?三、Hbase集群配置 1.配置hbase-env.sh文件,位于Hbase安裝目錄/conf/ 2.配置hbase-site.xml文件,位于Hbase安裝目錄/conf/ 3.配置regionservers 4.新建 backup-masters文件,添加備份HMaster機(jī)器名 四、將配置好

    2024年02月08日
    瀏覽(31)
  • HBase集群搭建記錄 | 云計(jì)算[CentOS7] | HBase完全分布式集群搭建

    HBase集群搭建記錄 | 云計(jì)算[CentOS7] | HBase完全分布式集群搭建

    本系列文章索引以及一些默認(rèn)好的條件在 傳送門 默認(rèn)使用master節(jié)點(diǎn)并用root用戶登錄終端進(jìn)行操作 文章難免會(huì)有點(diǎn)小bug,如果有顯而易見(jiàn)的錯(cuò)誤,比如沒(méi)有創(chuàng)建文件夾時(shí)就已經(jīng)開(kāi)始在該文件夾下操作,還請(qǐng)讀者自行創(chuàng)建~ 官網(wǎng)下載地址 博主因?yàn)檎n程需要以及版本問(wèn)題,下載的

    2023年04月23日
    瀏覽(31)
  • 解釋什么是分布式數(shù)據(jù)庫(kù),列舉幾種常見(jiàn)的分布式數(shù)據(jù)庫(kù)系統(tǒng)

    敏感信息和隱私保護(hù)是指在收集、存儲(chǔ)和使用個(gè)人數(shù)據(jù)時(shí),需要采取一系列措施來(lái)保護(hù)這些數(shù)據(jù)的安全和機(jī)密性,防止數(shù)據(jù)被未經(jīng)授權(quán)的第三方訪問(wèn)、使用或泄露。這些措施包括加密、訪問(wèn)控制、數(shù)據(jù)脫敏、數(shù)據(jù)加密、隱私政策等。 在隱私保護(hù)的技術(shù)手段方面,常用的技術(shù)包

    2024年02月08日
    瀏覽(32)
  • Hadoop3.x完全分布式環(huán)境搭建Zookeeper和Hbase

    Hadoop3.x完全分布式環(huán)境搭建Zookeeper和Hbase

    集群規(guī)劃 IP地址 主機(jī)名 集群身份 192.168.138.100 hadoop00 主節(jié)點(diǎn) 192.168.138.101 hadoop01 從節(jié)點(diǎn) 192.168.138.102 hadoop02 從節(jié)點(diǎn) Hadoop完全分布式環(huán)境搭建請(qǐng)移步傳送門 先在主節(jié)點(diǎn)上進(jìn)行安裝和配置,隨后分發(fā)到各個(gè)從節(jié)點(diǎn)上。 1.1 解壓zookeeper并添加環(huán)境變量 1)解壓zookeeper到/usr/local文件夾

    2024年02月04日
    瀏覽(29)
  • HBase完全分布式配置(下)hbase篇 保姆級(jí)教程(近乎零基礎(chǔ)跟著配也能配對(duì))

    HBase完全分布式配置(下)hbase篇 保姆級(jí)教程(近乎零基礎(chǔ)跟著配也能配對(duì))

    配置前也是要確保前面都配置正確,把多余的jdk都刪掉(不會(huì)刪看筆者第一篇文章) 上傳不再贅述 解壓: 改名: 環(huán)境變量: 應(yīng)用: 要修改jdk和設(shè)置zookeeper外部使用 由于hbase對(duì)hdfs有依賴關(guān)系,則需要將hadoop下的core-site.xml和hdfs-site.xml復(fù)制到hbase中的conf目錄下 zookeeper-hadoop-

    2024年04月17日
    瀏覽(18)
  • VMware創(chuàng)建Linux虛擬機(jī)之(四)ZooKeeper&HBase完全分布式安裝

    VMware創(chuàng)建Linux虛擬機(jī)之(四)ZooKeeper&HBase完全分布式安裝

    Hello,world! ?? ??本篇博客使用到的工具有:VMware16 ,Xftp7 若不熟悉操作命令,推薦使用帶GUI頁(yè)面的CentOS7虛擬機(jī) 我將使用帶GUI頁(yè)面的虛擬機(jī)演示 虛擬機(jī)(Virtual Machine) 指通過(guò)軟件模擬的具有完整硬件系統(tǒng)功能的、運(yùn)行在一個(gè)完全隔離環(huán)境中的完整計(jì)算機(jī)系統(tǒng)。在實(shí)體計(jì)算

    2024年02月07日
    瀏覽(25)
  • 分布式數(shù)據(jù)庫(kù)架構(gòu)

    分布式數(shù)據(jù)庫(kù)架構(gòu)

    對(duì)于mysql架構(gòu),一定會(huì)使用到讀寫分離,在此基礎(chǔ)上有五種常見(jiàn)架構(gòu)設(shè)計(jì):一主一從或多從、主主復(fù)制、級(jí)聯(lián)復(fù)制、主主與級(jí)聯(lián)復(fù)制結(jié)合。 1.1、主從復(fù)制 這種架構(gòu)設(shè)計(jì)是使用的最多的。在讀寫分離的基礎(chǔ)上,會(huì)存在一臺(tái)master作為寫機(jī),一個(gè)或多個(gè)slave作為讀機(jī)。因?yàn)樵趯?shí)際的

    2024年02月10日
    瀏覽(31)
  • 分析型數(shù)據(jù)庫(kù):分布式分析型數(shù)據(jù)庫(kù)

    分析型數(shù)據(jù)庫(kù):分布式分析型數(shù)據(jù)庫(kù)

    分析型數(shù)據(jù)庫(kù)的另外一個(gè)發(fā)展方向就是以分布式技術(shù)來(lái)代替MPP的并行計(jì)算,一方面分布式技術(shù)比MPP有更好的可擴(kuò)展性,對(duì)底層的異構(gòu)軟硬件支持度更好,可以解決MPP數(shù)據(jù)庫(kù)的幾個(gè)關(guān)鍵架構(gòu)問(wèn)題。本文介紹分布式分析型數(shù)據(jù)庫(kù)。 — 背景介紹— 目前在分布式分析型數(shù)據(jù)庫(kù)領(lǐng)域,

    2023年04月14日
    瀏覽(51)
  • 分布式數(shù)據(jù)庫(kù)-事務(wù)一致性

    分布式數(shù)據(jù)庫(kù)-事務(wù)一致性

    version: v-2023060601 author: 路__ 分布式數(shù)據(jù)庫(kù)的“強(qiáng)一致性”應(yīng)該包含兩個(gè)方面: serializability(串行) and linearizability(線性一致) ,上述圖為“Highly Available Transactions: Virtues and Limitations”論文中對(duì)于一致性模型的介紹。圖中箭頭表示一致性模型之間的關(guān)系。對(duì)于異步網(wǎng)絡(luò)上的分

    2024年02月08日
    瀏覽(28)
  • 分布式數(shù)據(jù)庫(kù)NoSQL(二)——MongoDB 數(shù)據(jù)庫(kù)基本操作

    分布式數(shù)據(jù)庫(kù)NoSQL(二)——MongoDB 數(shù)據(jù)庫(kù)基本操作

    MongoDB 是一個(gè)基于分布式文件存儲(chǔ)的數(shù)據(jù)庫(kù)。由 C++ 語(yǔ)言編寫。旨在為 WEB 應(yīng)用提供可擴(kuò)展的高性能數(shù)據(jù)存儲(chǔ)解決方案。 MongoDB 是一個(gè)介于關(guān)系數(shù)據(jù)庫(kù)和非關(guān)系數(shù)據(jù)庫(kù)之間的產(chǎn)品,是非關(guān)系數(shù)據(jù)庫(kù)當(dāng)中功能最豐富,最像關(guān)系數(shù)據(jù)庫(kù)的。它支持的數(shù)據(jù)結(jié)構(gòu)非常松散,是類似 json 的

    2024年02月06日
    瀏覽(33)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包