c语言sscanf函数的用法是什么
322
2022-11-20
杨校老师课堂之分布式数据库HBase的部署和基本操作
部署分布式数据库——HBase
学习背景: 以下采用伪分布式方式搭建HBase 故而采用内置的Zookeeper协调处理,不再搭建外置ZooKeeper,因此会存在单点故障问题,若需要解决这个情况,可采用Zookeeper部署一个HA(高可用)的Habse集群解决。
(1) 安装JDK、Hadoop,这里采用的JDK1.8,Hadoop2.7.4,CentOS7.6
(2)下载HBase安装包。官网地址:相关大数据框架下载整理
(3) 安装
3.1 上传并完成解压HBase安装包
[root@hadoop1 ~]# tar -zxvf hbase-1.2.1-bin.tar.gz
(4) 准备配置文件
4.1 拷贝配置文件
[root@hadoop1 ~]# cp /usr/local/hadoop/hadoop-2.7.4/etc//hadoop/{hdfs-site.xml,core-site.xml} /usr/local/hbase/hbase-1.2.1/conf/
4.2 修改配置文件hbase-env.sh
# 加入jdk的安装路径到JAVA_HOME[root@hadoop1 ~]# vim hbase-env.sh
4.3 设置HBase的环境变量
[root@hadoop1 ~]# vim /etc/profile#HBase environment variableexport HBASE_HOME=/usr/local/hbase/hbase-1.2.1export PATH=$PATH:$HBASE_HOME/bin:#更新配置文件profile生效[root@hadoop1 ~]# source /etc/profile
# 查看hbase的版本[root@hadoop1 ~]# hbase version
运行HBase数据库
[root@hadoop1 conf]# start-hbase.sh
运行成功后,已通过浏览器访问:可以通过修改hosts来实现访问主机名进入web界面 具体路径: C:\Windows\System32\drivers\etc\hosts 在hosts文件内的最后一行加入: 192.168.6.166 hadoop1
HBase的基本操作
方式一:HBase的Shell操作
#启动交互界面[root@hadoop1 ~]# hbase shell
# 创建表hbase(main):001:0> create 'student','info'0 row(s) in 3.1630 seconds=> Hbase::Table - student# 查询表hbase(main):002:0> listTABLE student 1 row(s) in 0.5240 seconds=> ["student"]
插入数据
# 插入数据hbase(main):003:0> put 'student','1001','info:name','zhangsan'0 row(s) in 3.0910 secondshbase(main):004:0> put 'student','1001','info:age','19'0 row(s) in 0.1290 secondshbase(main):005:0> put 'student','1001','info:gender','male'0 row(s) in 0.2760 secondshbase(main):006:0> put 'student','1002','info:name','lisi'0 row(s) in 0.0090 secondshbase(main):007:0> put 'student','1002','info:age','21'0 row(s) in 0.0800 secondshbase(main):008:0> put 'student','1002','info:gender','female'0 row(s) in 0.0150 seconds
扫描数据
hbase(main):009:0> scan 'student' ROW COLUMN+CELL 1001 column=info:age, timestamp=1650086163620, value=19 1001 column=info:gender, timestamp=1650086205652, value=male 1001 column=info:name, timestamp=1650085979553, value=zhangsan 1002 column=info:age, timestamp=1650086249277, value=21 1002 column=info:gender, timestamp=1650086265874, value=female 1002 column=info:name, timestamp=1650086227559, value=lisi 2 row(s) in 0.1450 seconds
查看表结构
hbase(main):010:0> describe 'student'Table student is ENABLED student COLUMN FAMILIES DESCRIPTION {NAME => 'info', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'} 1 row(s) in 0.2190 seconds
更新语句
hbase(main):011:0> put 'student','1002','info:age','22'0 row(s) in 0.1000 seconds# 修改后查询验证是否修改成功hbase(main):016:0> scan 'student' ROW COLUMN+CELL 1001 column=info:age, timestamp=1650086163620, value=19 1001 column=info:gender, timestamp=1650086205652, value=male 1001 column=info:name, timestamp=1650085979553, value=zhangsan 1002 column=info:age, timestamp=1650086635741, value=22 1002 column=info:gender, timestamp=1650086265874, value=female 1002 column=info:name, timestamp=1650086227559, value=lisi 2 row(s) in 0.0330 seconds
获取指定字段的操作
hbase(main):002:0> get 'student','1001' COLUMN CELL info:age timestamp=1650086163620, value=19 info:gender timestamp=1650086205652, value=male info:name timestamp=1650085979553, value=zhangsan 3 row(s) in 0.0420 seconds
删除语句
hbase(main):008:0> delete 'student','1002','info:gender'0 row(s) in 0.0900 seconds# 删除后查询验证是否修改成功hbase(main):009:0> scan 'student' ROW COLUMN+CELL 1001 column=info:age, timestamp=1650086163620, value=19 1001 column=info:gender, timestamp=1650086205652, value=male 1001 column=info:name, timestamp=1650085979553, value=zhangsan 1002 column=info:age, timestamp=1650086635741, value=22 1002 column=info:name, timestamp=1650086227559, value=lisi 2 row(s) in 0.0530 seconds
方式二: 利用Java API操作HBase
1.创建Maven项目
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~