HBase单机版

HBase的单机版配置

(单机版在本地运行,不可以启动hdfs或者yarn或者zookeeper,要不然无法运行)

1.官网:http://hbase.apache.org/

2.下载hbase(最好查找国内的镜像网站,下载,速度要快)

3.下载 hbase-2.2.2-bin.tar.gz(bin.jar包)、
hbase-2.2.2-client-bin.tar.gz(客户端bin.jar包)、
hbase-2.2.2-src.tar.gz(源码包)

4.把 hbase-2.2.2-bin.tar.gz 上传到虚拟机中,
解压压缩包
tar -zxvf hbase-2.2.2-bin.tar.gz

5.进入hbase文件中 修改 cof 目录下的hbase-env.shhbase-site.xml

hbase-env.sh

export JAVA_HOME = linux上安装的jdk的路径

hbase-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
	<property>
		<name>hbase.rootdir</name>
		<!--
			file://表示的是本地目录
			hdfs://表示的是hdfs的目录;
			hdfs://namenode.example.org:8020/hbase
		 -->
		<value>file:///data/hbase/data</value>
	</property>
	<property>
		<name>hbase.zookeeper.property.dataDir</name>
		<!-- zookeeper的目录:data目录 -->
		<value>/data/hbase/zookeeper_data</value>
	</property>
	<property>
		<name>hbase.unsafe.stream.capability.enforce</name>
		<value>false</value>
		<description>
			检查兼容性,如果设置为false,数据有可能丢失(这是一个警告)
		  Controls whether HBase will check for stream capabilities (hflush/hsync).

		  Disable this if you intend to run on LocalFileSystem, denoted by a rootdir
		  with the 'file://' scheme, but be mindful of the NOTE below.

		  WARNING: Setting this to false blinds you to potential data loss and
		  inconsistent system state in the event of process and/or node failures. If
		  HBase is complaining of an inability to use hsync or hflush it's most
		  likely not a false positive.
		</description>
	</property>
</configuration>

6.启动hbase

bin/start-hbase.sh

停止hbase

bin/stop-hbase.sh

如果启动报错,去查看日志

7.网页访问地址

http://node7-3:16010

8.启动客户端

bin/hbase shell

9.命令
1)查看所有的命令

help

2)查看指定命令的用法

help 'create_namespace'

3)创建一张表

# create '表名','列族'(column family)
create 'test','cf'

# 创建指定namespace目录下面的表;所有的表名左边要加上namespace,如果不加,默认是default
create 'mydata:test','cf'

4)查看表结构

# list 表名
list 'test'

# 描述这张表
describe 'test'

5)插入数据

# put 表名,键(主键),列的名字,值
put 'test','01','cf:name','zhangsan'
put 'test','01','cf:age','18'

# 指定namespace的表插入记录
put 'mydata:test','01','cf:name','zhangsan'
put 'mydata:test','01','cf:age','18'

6)查询

# 查询所有记录
# scan 表名
scan 'test'

# 扫描表的记录
scan 'mydata:test'

# 查询所有记录(根据主键查询)
# get 表名,键
get 'test','01'

7)删除表(首先停止表的运行,在drop表)

# disable 表名
disable 'test'

# drop ‘表名’
drop 'test'

8)退出客户端

Quit

exit

9)存储到磁盘上

# 数据先存储到内存中,然后再刷到磁盘中
help 'flush'

10)查询所有的namespace

# 列出所有的namespace
list_namespace

11)创建namespace

create_namespace 'mydata'

10.mysql与hbase的结构对比

数据库MySQLHBase
数据库Namespace
记录记录
列族下面才有列
要在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、付费专栏及课程。

余额充值