Hbase 学习

本文介绍了Hbase的学习过程,包括环境配置,如设置JAVA_HOME和HADOOP_HOME,配置hbase-env.sh和hbase-site.xml文件。接着讲述了如何启动和停止Hbase服务,以及管理HMaster和RegionServers。在Hbaseshell中进行表的操作,如创建、查看、描述、插入数据等。还提到了处理中文乱码的方法和IDEA连接Hbase时可能遇到的问题及解决方案,推荐添加Guava依赖来解决连接问题。

Hbase 学习

官方网站

解压-配置

#配置hbase环境
vi hbase-env.sh
============================
#!/usr/bin/env bash
export JAVA_HOME=/opt/module/jdk
export HADOOP_HOME=/opt/module/hadoop
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export HBASE_MANAGER_ZK=false
#HBASE_MANAGES_ZK=true
export HBASE_LOG_DIR=/opt/module/hbase/logs
export HBASE_PID_DIR=/opt/module/hbase/pid
==============================
#配置hbase-site.xml
==============================
vi hbase-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
/**
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-->

<configuration>
    <property>
        <name>hbase.rootdir</name>
        <value>hdfs://master:9000/hbase</value>
    </property>
    <property>
        <name>hbase.tmp.dir</name>
        <value>/opt/module/hbase/tmp</value>
    </property>
    <property>
        <name>hbase.master.info.port</name>
        <value>16010</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.clientPort</name>
        <value>2181</value>
    </property>
    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>master:2181,slave1:2181,slave2:2181</value>
    </property>
    <property>
        <name>hbase.cluster.distributed</name>
        <value>true</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.dataDir</name>
        <value>/opt/module/zookeeper/zkdata</value>
    </property>
    <property>
        <name>hbase.unsafe.stream.capability.enforce</name>
        <value>false</value>
    </property>
</configuration>
========================

使用hbase

start-hbase.sh启动hbase
stop-hbase.sh停止hbase服务
local-master-backup.sh start 2 3 5启动备份HMaster(最多9个备份,也就是10个HMaster),2 3 5表端口偏移量(每个HMaster使用三个端口,结果是端口加2 3 5)
hbase-testuser-1-master.pid |xargs kill -9不杀死集群的情况下杀死备份主机
local-regionservers.sh start 2 3 4 5启动其他regionServers
local-resionservers.sh stop 3停止其他regionServers

hbase shell 进入命令行

命令解释案例
create创建表crate ‘test’,‘info’
list查看表list或者list 'test’是否存在
describe表结构describe ‘test’
put插入数据put ‘test’,‘id1’,‘info:name’,'张三’必须有列族info
scan查看所有数据scan ‘test’
get根据id查看一条数据get ‘test’,‘id1’
disable禁用表disable ‘test’
enable启用表enable ‘test’
drop删除表drop 'test’先禁用后删除

问题:

  1. hbase中文乱码
    添加一个formatter=>‘toString’
scan 'change_state_other_to_run_agg',{FORMATER=>'toString'}
  1. idea链接hbase报错
    (解决办法)[https://blog.youkuaiyun.com/andyonlines/article/details/113621995]
    pom添加
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>24.0-jre</version>
        </dependency>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

厨 神

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值