HBase2.3单机本地版使用(不需要hdfs)

1、安装单机版HBase

下载hbase-2.3.0-bin.tar.gz及jdk-8u151-linux-x64.tar.gz并解压到目录/software
关闭防火墙、禁用ipv6并设置hostname为hbase,,同时需调整时区为中国时区

检查系统版本为centos7
[root@hbase ~]# cat /etc/redhat-release 
CentOS Linux release 7.8.2003 (Core)
[root@hbase ~]# uname -a
Linux hbase 3.10.0-1127.19.1.el7.x86_64 #1 x86_64 x86_64 x86_64 GNU/Linux
[root@hbase ~]# 
  • 设置jdkhbase环境变量,在/etc/profile文件末尾添加以下配置后使用source /etc/profile使其生效
export JAVA_HOME=/software/jdk1.8.0_151
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH

export HBASE_HOME=/software/hbase-2.3.0
export PATH=$HBASE_HOME/bin:$PATH

  • 检查安装情况,可查看jdk与hbase版本
[root@hbase bin]# pwd
/software/hbase-2.3.0/bin
[root@hbase bin]# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
[root@hbase bin]# ./hbase version
HBase 2.3.0
Source code repository git://35f72a441626/home/vagrant/hbase-rm/output/hbase revision=e0e1382705c59d3fb3ad8f5bff720a9dc7120fb8
Compiled by vagrant
From source with checksum (stdin)=
[root@hbase bin]# 
  • 配置hbase
可查看配置文件/software/hbase-2.3.0/conf/hbase-env.sh默认配置项HBASE_MANAGES_ZK为true(表示使用hbase内置zookeeper,启动后可使用netstat -ano|grep 2181查看端口占用情况)

编辑配置文件/software/hbase-2.3.0/conf/hbase-site.xml,添加或修改以下配置 
  <property>
    <name>hbase.cluster.distributed</name>
    <value>false</value>
  </property>

<property>
    <name>hbase.rootdir</name>
    <value>file:///data/hbase</value>
  </property>


<property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/data/zookeeper</value>
  </property>


  <property>
    <name>hbase.unsafe.stream.capability.enforce</name>
    <value>false</value>
  </property>
</configuration>
  
  • 启动hbase
[root@hbase bin]# pwd
/software/hbase-2.3.0/bin
[root@hbase bin]# ./start-hbase.sh 
running master, logging to /software/hbase-2.3.0/logs/hbase-root-master-hbase.out
[root@hbase bin]# jps
2000 Jps
1561 HMaster

可以查看到hbase已正常启动,netstat -ano|grep 2181可以看到内置zookeeper已启动,可以使用http://192.168.2.5:16010/master-status访问看到hbase控制台

2、hbase常用命令操作

命令说明命令语法
status查看hbase状态信息-
tools查看所有工具命令-
version查看hbase版本信息-
list_namespace查看命名空间(支持正则)查看所有list_namespace
正则匹配list_namespace 'ioe.*'
create_namespace创建命名空间create_namespace <namespace>
create_namespace 'ioe'
alter_namespace修改命名空间如修改namespace的创建人 alter_namespace 'ioe', {METHOD=>'set', 'create'=>'xiaopang'}
list_namespace_tables查看命名空间下的表list_namespace_tables<namespace>
list_namespace_tables 'ioe'
describe_namespace查看命名空间详细信息-
drop_namespace删除命名空间需先清除表drop_namespace <namespace>
create创建表(指定namespace)create <namespace>:<tableName>,<columnFamily1>,<columnFamily2>
create 'ioe:user','a','b'
create创建表(默认namespace)create <tableName>,<columnFamily1>,<columnFamily2>
create 'user','name','address'用户有中文名、英文名、小名,地址有家庭地址、办公地址、户籍地址
list查看所有表list
列出其他namespace表list 'ioe.*'
describe查看表详细信息describe <tableName>
describe 'user'
查看其他namespace表describe 'ioe:user'
exists判断表是否存在exists <tableName>
enable启用表enable <tableName>
disable停用表disable <tableName>
disable_all批量停用表disable '.*
is_enabled判断是否启用is_enabled <tableName>
is_disabled判断是否停用is_disabled <tableName>
count统计表中行数count <tableName>
put新增记录put <tableName>,<rowkey>,<columnFamily>:<column>,<value>
put 'user','xiaopang','name:en','michael'
put 'user','xiaopang','name:ch','胖子'
put 'user','xiaopang','address:office','北京'
get查询记录get <tableName>,<rowkey>
get 'user','xiaopang'
获取多个版本数据get 'user','xiaopang',{COLUMN=>'phone:a',VERSIONS=>3}
delete删除记录delete <tableName>,<rowkey>,<columnfamily>:<column>
delete 'user','xiaopang','name:ch'
deleteall删除整行记录deleteall <tableName> <rowkey>
deleteall 'user','xiaopang'
drop删除表(必须先disable)drop <tableName>
drop 'user'
drop_all批量删除表(必须先disable)drop_all '.*'
alter增加、修改、删除列簇增加alter <table>,<columnfamily>
修改alter <table>,<columnfamily>
删除alter <table>,{NAME=><columnfamily>,METHOD=>'delete'}
alter 'user','phone'
alter 'user',{NAME=>'phone',METHOD=>'delete'}
或alter 'user', 'delete' => 'phone'
修改为最多获取5个版本alter 'user', NAME=>'phone',VERSIONS=>5
incr字段自增incr 'user','xiaopang','age',9
truncate清除表数据-
scan扫描所有记录scan <tableName>
scan 'user'
exit退出-
shutdown关闭集群-

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Kubernetes上部署HBase单机,可以使用StatefulSet。以下是一个简单的步骤: 1. 创建一个配置文件hbase-config.yaml: ``` apiVersion: v1 kind: ConfigMap metadata: name: hbase-config data: hbase-site.xml: | <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>hbase.rootdir</name> <value>file:///hbase</value> </property> <property> <name>hbase.zookeeper.property.clientPort</name> <value>2181</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>hbase-zookeeper-0.hbase-zookeeper.default.svc.cluster.local,hbase-zookeeper-1.hbase-zookeeper.default.svc.cluster.local,hbase-zookeeper-2.hbase-zookeeper.default.svc.cluster.local</value> </property> </configuration> ``` 2. 创建一个Headless Service: ``` apiVersion: v1 kind: Service metadata: name: hbase-headless spec: clusterIP: None selector: app: hbase ports: - name: thrift port: 9090 - name: rest port: 8080 ``` 3. 创建一个StatefulSet: ``` apiVersion: apps/v1 kind: StatefulSet metadata: name: hbase spec: serviceName: hbase-headless replicas: 1 selector: matchLabels: app: hbase template: metadata: labels: app: hbase spec: containers: - name: hbase image: hbase:2.2.4 command: - sh - -c - "echo 'deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse' >> /etc/apt/sources.list && apt-get update && apt-get install -y netcat && /opt/hbase/bin/start-hbase.sh && tail -f /opt/hbase/logs/*" ports: - containerPort: 9090 name: thrift - containerPort: 8080 name: rest volumeMounts: - name: hbase-data mountPath: /hbase - name: hbase-config mountPath: /opt/hbase/conf/hbase-site.xml subPath: hbase-site.xml volumes: - name: hbase-data persistentVolumeClaim: claimName: hbase-data - name: hbase-config configMap: name: hbase-config ``` 4. 创建一个PersistentVolumeClaim: ``` apiVersion: v1 kind: PersistentVolumeClaim metadata: name: hbase-data spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi ``` 上述配置文件中,假设已经有一个Zookeeper集群,名称为hbase-zookeeper,并且已经部署在Kubernetes中。在上述配置文件中,使用HBase 2.2.4本的镜像。在容器启动时,首先安装netcat,然后启动HBase,并保持日志输出。注意,hbase-site.xml文件被挂载到容器中。 以上是一个简单的部署HBase单机的示例。根据实际情况,可能需要进行一些修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值