Hbase

1.同步时间

yum -y install chrony
vi /etc/chrony.conf
pool time1.aliyun.com iburst
保存
systemctl enable --now chronyd
systemctl status chronyd

2.安装hbase

tar xf /opt/software/hbase-1.2.1-bin.tar.gz -C /usr/local/src/
cd /usr/local/src/
mv hbase-1.2.1 hbase
vi /etc/profile.d/hbase.sh
export HBASE_HOME=/usr/local/src/hbase
export PATH=${HBASE_HOME}/bin:$PATH

保存以上配置后执行以下命令

source /etc/profile.d/hbase.sh
echo $PATH

3.在master上配置hbase

配置环境变量
cd /usr/local/src/hbase/conf/
vi hbase-env.sh
export JAVA_HOME=/usr/local/src/jdk
export HBASE_MANAGES_ZK=true
export HBASE_CLASSPATH=/usr/local/src/hadoop/etc/hadoop/

写配置文件
vi hbase-site.xml

<configuration>
<property>
        <name>hbase.rootdir</name>
        <value>hdfs://master:9000/hbase</value>
</property>
<property>
        <name>hbase.master.info.port</name>
        <value>60010</value>
</property>
<property>
        <name>hbase.zookeeper.property.clientPort</name>
        <value>2181</value>
</property>
<property>
        <name>zookeeper.session.timeout</name>
        <value>10000</value>
</property>
<property>
        <name>hbase.zookeeper.quorum</name>
        <value>master,slave1,slave2</value>
</property>
<property>
        <name>hbase.tmp.dir</name>
        <value>/usr/local/src/hbase/tmp</value>
</property>
<property>
        <name>hbase.cluster.distributed</name>
        <value>true</value>
</property>
</configuration>

创建文件夹
mkdir -p /usr/local/src/hbase/tmp
vi regionservers
192.168.3.139
192.168.3.140

4.同步配置文件至每个节点

scp -r /usr/local/src/hbase slave1:/usr/local/src/
scp -r /usr/local/src/hbase slave2:/usr/local/src/
scp /etc/profile.d/hbase.sh slave1:/etc/profile.d/
scp /etc/profile.d/hbase.sh slave2:/etc/profile.d/
并修改文件权限
chown -R hadoop.hadoop /usr/local/src
ssh slave1 'chown -R hadoop.hadoop /usr/local/src'
ssh slave2 'chown -R hadoop.hadoop /usr/local/src'
ll /usr/local/src/
su - hadoop

hadoop之间得
做相互免密登录

hbase基本命令
hbase shell  打开数据库
hbase(main):003:0* create 'scores','grade','course'
0 row(s) in 1.4550 seconds     #第一个为表名  后面的都是列
hbase(main):004:0> status
1 active master, 0 backup masters, 2 servers, 0 dead, 1.5000 average load   #查看hbase状态
hbase(main):011:0> version
1.2.1, r8d8a7107dc4ccbf36a92f64675dc60392f85c015, Wed Mar 30 11:19:21 CDT 2016   #查看hbase版本
hbase(main):006:0> list
TABLE                                                                                                   
mqy                                                                                                     
scores                                                                                                  
2 row(s) in 0.0070 seconds

=> ["mqy", "scores"]
hbase(main):007:0>     #查看表
# 插入记录 1:jie,grade: 143cloud
hbase(main):005:0> put 'scores','jie','grade:','146cloud'
# 插入记录 2:jie,course:math,86
hbase(main):006:0> put 'scores','jie','course:math','86'
# 插入记录 3:jie,course:cloud,92
hbase(main):007:0> put 'scores','jie','course:cloud','92'
# 插入记录 4:shi,grade:133soft
hbase(main):008:0> put 'scores','shi','grade:','133soft'
# 插入记录 5:shi,grade:math,87
hbase(main):009:0> put 'scores','shi','course:math','87'
# 插入记录 6:shi,grade:cloud,96
hbase(main):010:0>  put 'scores','shi','course:cloud','96'
# 读取jie的记录
hbase(main):011:0> get 'scores','jie'
# 读取jie的班级
hbase(main):012:0> get 'scores','jie','grade'
# 查看整个表记录
hbase(main):013:0> scan 'scores'
# 按例查看表记录
hbase(main):014:0> scan 'scores',{COLUMNS=>'course'}
# 删除指定记录
hbase(main):016:0> delete 'scores','shi','grade'
# 增加新的名为age的列簇
hbase(main):019:0> alter 'scores',NAME=>'age'
# 查看表结构
hbase(main):021:0> describe 'scores'
# 删除名为age的列簇
hbase(main):023:0> alter 'scores',NAME=>'age',METHOD=>'delete'
# 删除表
hbase(main):025:0> disable 'scores'
hbase(main):026:0> drop 'scores'
hbase(main):027:0> list
# 退出hbase
hbase(main):028:0> quit
# 关闭hbase
stop-hbase.sh
jps
posted @ 2022-04-24 22:11  supermao12  阅读(8)  评论(0编辑  收藏  举报