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

HBase 遇到的問題以及處理

這篇具有很好參考價(jià)值的文章主要介紹了HBase 遇到的問題以及處理。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

背景

目前在hbase集群中發(fā)現(xiàn)了一些問題,主要是Region 一致性的問題,和RIT問題,根據(jù)目前遇到的問題整理了以下問題fix手冊(cè)。 如果后面遇到新的問題可以再增加

Hbase hbck 處理Region一致性問題

Issue: Regions have the same start/end keys

Cause

Varies.

Resolution

手動(dòng)合并重疊的區(qū)域。 在 HBase HMaster Web UI 表詳情頁面,選擇有問題的表鏈接。 可以看到屬于該表的每個(gè)區(qū)域的開始鍵/結(jié)束鍵。 然后合并重疊的區(qū)域。 在 HBase shell 中,執(zhí)行 merge_region ‘xxxxxxxx’,‘yyyyyyy’, true。 例如:

RegionA, startkey:001, endkey:010,

RegionB, startkey:001, endkey:080,

RegionC, startkey:010, endkey:080.

在這種場景下,需要合并RegionA和RegionC,得到與RegionB相同key范圍的RegionD,再合并RegionB和RegionD。 xxxxxxx 和 yyyyyy 是每個(gè)區(qū)域名稱末尾的哈希字符串。 這里要小心不要合并兩個(gè)不連續(xù)的區(qū)域。 每次合并后,如合并 A 和 C,HBase 將開始對(duì) RegionD 進(jìn)行壓縮。 等待壓縮完成,然后再與 RegionD 進(jìn)行另一次合并。 您可以在 HBase HMaster UI 的區(qū)域服務(wù)器頁面上找到壓縮狀態(tài)。

Issue: Region overlap

Cause

很有可能是在分裂過程中Region Server 重啟,或split不徹底,導(dǎo)致重復(fù)上線,就會(huì)導(dǎo)致兩個(gè)region有重疊的部分。

Resolution

這種場景下,和以上的處理方式相同,需要注意的是這Region進(jìn)行Compact的時(shí)候不能合并成功,在hbase shell 進(jìn)行合并后,可以觀察HMaster的日志,如果最終可以合并成功,則不會(huì)出現(xiàn)error日志信息,如果遇到始終不能合并的Region,可以先嘗試將此Region下線掉(unassign region),再次上線(assign region),再執(zhí)行merge操作。例如:

merge_region 'regionA','regionB',true

在這個(gè)過程中有可能需要檢查一些hfile文件其中的數(shù)據(jù)是否已經(jīng)表中可以使用


import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.filter.KeyOnlyFilter;
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
import org.apache.hadoop.hbase.io.hfile.HFile;
import org.apache.hadoop.hbase.io.hfile.HFileScanner;
import org.apache.hadoop.hbase.io.hfile.HFileWriterImpl;
import org.apache.hadoop.hbase.regionserver.HStoreFile;
import org.apache.hadoop.hbase.regionserver.TimeRangeTracker;
import org.apache.hadoop.hbase.util.BloomFilter;
import org.apache.hadoop.hbase.util.BloomFilterFactory;
import org.apache.hadoop.hbase.util.BloomFilterUtil;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.DataInput;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Map;
import java.util.Optional;

/**
 * @author wxl
 */
@Component
public class ReadHFile {
    private static final Logger log = LoggerFactory.getLogger(ReadHFile.class);

    private final PrintStream out = System.out;
    private static final String FOUR_SPACES = "    ";

    @Value("${hbase.hfile.path:''}")
    private String hfile;

    public void run() throws Exception {
        Configuration conf = HBaseConfiguration.create();
        Connection connection = ConnectionFactory.createConnection(conf);
        Table table = connection.getTable(TableName.valueOf("LG_DEVICE_DATA:ALL_DEVICE_DATA"));
        FileSystem fs = FileSystem.get(conf);

        Path path = new Path(hfile);
        FileStatus[] dirs = fs.listStatus(path);
        for (FileStatus hfile : dirs) {
            boolean hFileFormat = HFile.isHFileFormat(fs, hfile.getPath());
            if (!hFileFormat) {
                continue;
            }

            HFile.Reader reader = HFile.createReader(fs, hfile.getPath(), CacheConfig.DISABLED, true, conf);

            //打印meta 信息
            //Map<byte[], byte[]> fileInfo = reader.loadFileInfo();
            //printMeta(reader, fileInfo);
            Optional<byte[]> firstRowKey = reader.getFirstRowKey();
            Optional<byte[]> lastRowKey = reader.getLastRowKey();
            StringBuilder sb = new StringBuilder();
            if (firstRowKey.isPresent()) {
                isExists(table, firstRowKey.get(), false, hfile.getPath().toString());
            }
            if (lastRowKey.isPresent()) {
                isExists(table, lastRowKey.get(), false, hfile.getPath().toString());
            }
            reader.close();

        }

        fs.close();
        table.close();
        connection.close();
    }

    public void isExists(Table table, byte[] rowKey, boolean p, String path) throws IOException {
        Get get = new Get(rowKey);
        get.setFilter(new KeyOnlyFilter());
        Result result = table.get(new Get(rowKey));
        if (p) {
            log.info("result: [{}]", result);
        }
        if (result == null || result.isEmpty()) {
            log.info("rowKey not exists: [{}] filePath: [{}]", new String(rowKey), path);
        }
//        else {
//            byte[] row = result.getRow();
//            log.info("ok: " + new String(row));
//        }
    }

    private void check(Table table, HFileScanner scanner) throws IOException {
        scanner.seekTo();
        byte[] pRowKey = null;
        int count = 0;
        while (scanner.next()) {
            Cell cell = scanner.getKey();
            byte[] rowKey = CellUtil.cloneRow(cell);
            if (!Bytes.equals(pRowKey, rowKey)) {
                boolean p = false;
                ++count;
                if (count % 1000 == 0) {
                    log.info("current count: [{}]", count);
                    //  p = true;
                }
                isExists(table, rowKey, p, "");
            }
            pRowKey = rowKey;
        }
        log.info("count rowKey: [{}]", count);
    }

    private void printMeta(HFile.Reader reader, Map<byte[], byte[]> fileInfo)
            throws IOException {
        out.println("Block index size as per heapsize: "
                + reader.indexSize());
        out.println(asSeparateLines(reader.toString()));
        out.println("Trailer:\n    "
                + asSeparateLines(reader.getTrailer().toString()));
        out.println("Fileinfo:");
        for (Map.Entry<byte[], byte[]> e : fileInfo.entrySet()) {
            out.print(FOUR_SPACES + Bytes.toString(e.getKey()) + " = ");
            if (Bytes.equals(e.getKey(), HStoreFile.MAX_SEQ_ID_KEY)
                    || Bytes.equals(e.getKey(), HStoreFile.DELETE_FAMILY_COUNT)
                    || Bytes.equals(e.getKey(), HStoreFile.EARLIEST_PUT_TS)
                    || Bytes.equals(e.getKey(), HFileWriterImpl.MAX_MEMSTORE_TS_KEY)
                    || Bytes.equals(e.getKey(), Bytes.toBytes("hfile.CREATE_TIME_TS"))
                    || Bytes.equals(e.getKey(), HStoreFile.BULKLOAD_TIME_KEY)) {
                out.println(Bytes.toLong(e.getValue()));
            } else if (Bytes.equals(e.getKey(), HStoreFile.TIMERANGE_KEY)) {
                TimeRangeTracker timeRangeTracker = TimeRangeTracker.parseFrom(e.getValue());
                out.println(timeRangeTracker.getMin() + "...." + timeRangeTracker.getMax());
            } else if (Bytes.equals(e.getKey(), Bytes.toBytes("hfile.AVG_KEY_LEN"))
                    || Bytes.equals(e.getKey(), Bytes.toBytes("hfile.AVG_VALUE_LEN"))
                    || Bytes.equals(e.getKey(), HFileWriterImpl.KEY_VALUE_VERSION)
                    || Bytes.equals(e.getKey(), HFile.FileInfo.MAX_TAGS_LEN)) {
                out.println(Bytes.toInt(e.getValue()));
            } else if (Bytes.equals(e.getKey(), HStoreFile.MAJOR_COMPACTION_KEY)
                    || Bytes.equals(e.getKey(), Bytes.toBytes("hfile.TAGS_COMPRESSED"))
                    || Bytes.equals(e.getKey(), HStoreFile.EXCLUDE_FROM_MINOR_COMPACTION_KEY)) {
                out.println(Bytes.toBoolean(e.getValue()));
            } else if (Bytes.equals(e.getKey(), Bytes.toBytes("hfile.LASTKEY"))) {
                out.println(new KeyValue.KeyOnlyKeyValue(e.getValue()).toString());
            } else {
                out.println(Bytes.toStringBinary(e.getValue()));
            }
        }

        try {
            out.println("Mid-key: " + reader.midKey().map(CellUtil::getCellKeyAsString));
        } catch (Exception e) {
            out.println("Unable to retrieve the midkey");
        }

        // Printing general bloom information
        DataInput bloomMeta = reader.getGeneralBloomFilterMetadata();
        BloomFilter bloomFilter = null;
        if (bloomMeta != null) {
            bloomFilter = BloomFilterFactory.createFromMeta(bloomMeta, reader);
        }

        out.println("Bloom filter:");
        if (bloomFilter != null) {
            out.println(FOUR_SPACES + bloomFilter.toString().replaceAll(
                    BloomFilterUtil.STATS_RECORD_SEP, "\n" + FOUR_SPACES));
        } else {
            out.println(FOUR_SPACES + "Not present");
        }

        // Printing delete bloom information
        bloomMeta = reader.getDeleteBloomFilterMetadata();
        bloomFilter = null;
        if (bloomMeta != null) {
            bloomFilter = BloomFilterFactory.createFromMeta(bloomMeta, reader);
        }

        out.println("Delete Family Bloom filter:");
        if (bloomFilter != null) {
            out.println(FOUR_SPACES
                    + bloomFilter.toString().replaceAll(BloomFilterUtil.STATS_RECORD_SEP,
                    "\n" + FOUR_SPACES));
        } else {
            out.println(FOUR_SPACES + "Not present");
        }
    }

    /**
     * Format a string of the form "k1=v1, k2=v2, ..." into separate lines
     * with a four-space indentation.
     */
    private static String asSeparateLines(String keyValueStr) {
        return keyValueStr.replaceAll(", ([a-zA-Z]+=)",
                ",\n" + FOUR_SPACES + "$1");
    }
}

Issue: ERROR: Found lingering reference file xxxx

Cause

這很可能是由于 RegionServer 崩潰或 VM 重啟時(shí)region 沒有刪除完全導(dǎo)致的。

Resolution

hbase hbck -fixReferenceFiles month_hotstatic

檢測hbase 的Region是否健康

使用hbase hbck 命令檢測,如果發(fā)現(xiàn)>=1個(gè)問題檢測到,則表示Region出現(xiàn)了問題文章來源地址http://www.zghlxwxcb.cn/news/detail-581646.html

0 inconsistencies detected.
Status: OK

特別注意

  • 以上問題處理完后需要重啟Phoenix Query Server 因其內(nèi)部有緩存,可能會(huì)導(dǎo)致查詢問題

到了這里,關(guān)于HBase 遇到的問題以及處理的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(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ù)】分布式數(shù)據(jù)庫HBase

    【大數(shù)據(jù)】分布式數(shù)據(jù)庫HBase

    目錄 1.概述 1.1.前言 1.2.數(shù)據(jù)模型 1.3.列式存儲(chǔ)的優(yōu)勢(shì) 2.實(shí)現(xiàn)原理 2.1.region 2.2.LSM樹 2.3.完整讀寫過程 2.4.master的作用 本文式作者大數(shù)據(jù)系列專欄中的一篇文章,按照專欄來閱讀,循序漸進(jìn)能更好的理解,專欄地址: https://blog.csdn.net/joker_zjn/category_12631789.html?spm=1001.2014.3001.5482 當(dāng)

    2024年04月27日
    瀏覽(29)
  • 使用IDEA連接hbase數(shù)據(jù)庫

    ? Hbase是安裝在另一臺(tái)LINUX服務(wù)器上的,需要本地通過JAVA連接HBase數(shù)據(jù)庫進(jìn)行操作。由于是第一次接觸HBase,過程當(dāng)中百度了很多資料,也遇到了很多的問題。耗費(fèi)了不少時(shí)間才成功連接上。特記錄下過程當(dāng)中遇到的問題。 JAVA連接HBase代碼如下: 首先通過POM將需要的JAR包導(dǎo)入。

    2024年02月03日
    瀏覽(23)
  • HBase的數(shù)據(jù)庫與HadoopEcosyste

    HBase是一個(gè)分布式、可擴(kuò)展、高性能、高可用性的列式存儲(chǔ)系統(tǒng),基于Google的Bigtable設(shè)計(jì)。HBase是Hadoop生態(tài)系統(tǒng)的一個(gè)重要組成部分,與Hadoop HDFS、MapReduce、ZooKeeper等產(chǎn)品密切相關(guān)。本文將從以下幾個(gè)方面進(jìn)行深入探討: 背景介紹 核心概念與聯(lián)系 核心算法原理和具體操作步驟

    2024年02月20日
    瀏覽(17)
  • 大數(shù)據(jù)NoSQL數(shù)據(jù)庫HBase集群部署

    大數(shù)據(jù)NoSQL數(shù)據(jù)庫HBase集群部署

    目錄 1.? 簡介 2.? 安裝 1. HBase依賴Zookeeper、JDK、Hadoop(HDFS),請(qǐng)確保已經(jīng)完成前面 2. 【node1執(zhí)行】下載HBase安裝包 3. 【node1執(zhí)行】,修改配置文件,修改conf/hbase-env.sh文件 4. 【node1執(zhí)行】,修改配置文件,修改conf/hbase-site.xml文件 5. 【node1執(zhí)行】,修改配置文件,修改conf/regi

    2024年02月08日
    瀏覽(19)
  • HBase的數(shù)據(jù)庫容量規(guī)劃與優(yōu)化

    HBase的數(shù)據(jù)庫容量規(guī)劃與優(yōu)化 HBase是一個(gè)分布式、可擴(kuò)展、高性能的列式存儲(chǔ)系統(tǒng),基于Google的Bigtable設(shè)計(jì)。它是Hadoop生態(tài)系統(tǒng)的一部分,可以與HDFS、MapReduce、ZooKeeper等組件集成。HBase適用于大規(guī)模數(shù)據(jù)存儲(chǔ)和實(shí)時(shí)數(shù)據(jù)訪問場景,如日志處理、實(shí)時(shí)統(tǒng)計(jì)、搜索引擎等。 在實(shí)際

    2024年02月20日
    瀏覽(26)
  • HBase的數(shù)據(jù)庫備份與恢復(fù)策略

    HBase是一個(gè)分布式、可擴(kuò)展、高性能的列式存儲(chǔ)系統(tǒng),基于Google的Bigtable設(shè)計(jì)。它是Hadoop生態(tài)系統(tǒng)的一部分,可以與HDFS、MapReduce、ZooKeeper等組件集成。HBase具有高可用性、高可擴(kuò)展性和高性能等優(yōu)勢(shì),適用于大規(guī)模數(shù)據(jù)存儲(chǔ)和實(shí)時(shí)數(shù)據(jù)處理。 在實(shí)際應(yīng)用中,數(shù)據(jù)備份和恢復(fù)是

    2024年02月19日
    瀏覽(28)
  • HBase的數(shù)據(jù)庫安全與權(quán)限管理

    HBase是一個(gè)分布式、可擴(kuò)展、高性能的列式存儲(chǔ)系統(tǒng),基于Google的Bigtable設(shè)計(jì)。它是Hadoop生態(tài)系統(tǒng)的一部分,可以與HDFS、MapReduce、ZooKeeper等組件集成。HBase具有高可靠性、高性能和高可擴(kuò)展性等特點(diǎn),適用于大規(guī)模數(shù)據(jù)存儲(chǔ)和實(shí)時(shí)數(shù)據(jù)處理。 在現(xiàn)代企業(yè)中,數(shù)據(jù)安全和權(quán)限管

    2024年02月20日
    瀏覽(21)
  • 大數(shù)據(jù)NoSQL數(shù)據(jù)庫HBase集群部署——詳細(xì)講解~

    HBase 是一種分布式、可擴(kuò)展、支持海量數(shù)據(jù)存儲(chǔ)的 NoSQL 數(shù)據(jù)庫。 和Redis一樣,HBase是一款KeyValue型存儲(chǔ)的數(shù)據(jù)庫。 不過和Redis設(shè)計(jì)方向不同 Redis設(shè)計(jì)為少量數(shù)據(jù),超快檢索 HBase設(shè)計(jì)為海量數(shù)據(jù),快速檢索 HBase在大數(shù)據(jù)領(lǐng)域應(yīng)用十分廣泛,現(xiàn)在我們來在node1、node2、node3上部署H

    2024年02月11日
    瀏覽(22)
  • HBase的數(shù)據(jù)庫設(shè)計(jì)模式與實(shí)踐

    HBase是一個(gè)分布式、可擴(kuò)展、高性能的列式存儲(chǔ)系統(tǒng),基于Google的Bigtable設(shè)計(jì)。它是Hadoop生態(tài)系統(tǒng)的一部分,可以與HDFS、MapReduce、ZooKeeper等組件集成。HBase適用于大規(guī)模數(shù)據(jù)存儲(chǔ)和實(shí)時(shí)數(shù)據(jù)訪問的場景,如日志記錄、實(shí)時(shí)數(shù)據(jù)分析、實(shí)時(shí)搜索等。 在現(xiàn)實(shí)應(yīng)用中,HBase的數(shù)據(jù)庫設(shè)

    2024年02月20日
    瀏覽(22)
  • 客戶端讀寫HBase數(shù)據(jù)庫的運(yùn)行原理

    客戶端讀寫HBase數(shù)據(jù)庫的運(yùn)行原理

    1.HBase的特點(diǎn) HBase是一個(gè)數(shù)據(jù)庫,與RDMS相比,有以下特點(diǎn): ① 它不支持SQL ② 不支持事務(wù) ③ 沒有表關(guān)系,不支持JOIN ④ 有列族,列族下可以有上百個(gè)列 ⑤ 單元格,即列值,可以存儲(chǔ)多個(gè)版本的值,每個(gè)版本都有對(duì)應(yīng)時(shí)間戳 ⑥ 行鍵按照字典序升序排列 ⑦ 元數(shù)據(jù) 和 數(shù)據(jù) 分

    2024年02月10日
    瀏覽(25)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

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

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包