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’先禁用后删除 |
问题:
- hbase中文乱码
添加一个formatter=>‘toString’
scan 'change_state_other_to_run_agg',{FORMATER=>'toString'}
- 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>
本文介绍了Hbase的学习过程,包括环境配置,如设置JAVA_HOME和HADOOP_HOME,配置hbase-env.sh和hbase-site.xml文件。接着讲述了如何启动和停止Hbase服务,以及管理HMaster和RegionServers。在Hbaseshell中进行表的操作,如创建、查看、描述、插入数据等。还提到了处理中文乱码的方法和IDEA连接Hbase时可能遇到的问题及解决方案,推荐添加Guava依赖来解决连接问题。
1017

被折叠的 条评论
为什么被折叠?



