安装HBase
cd /soft
tar -zxvf /soft/hbase-1.4.0-bin.tar.gz -C /usr/local/
cd /usr/local/ ###可以看hbase解压到该目录, 文件名称是: hbase-1.4.0
环境变量:
echo "export HBASE_HOME=/usr/local/hbase-1.4.0" >> /etc/profile
echo -e 'export PATH=$PATH:$HBASE_HOME/bin'>> /etc/profile
source /etc/profile
配置hbase-env.sh: vim /usr/local/hbase-1.4.0/conf/hbase-env.sh
设置如下参数为:
export HBASE_MANAGES_ZK=false
export JAVA_HOME=/usr/java/jdk1.8.0
export HBASE_HOME=/usr/local/hbase-1.4.0
export HBASE_CLASSPATH=/usr/local/hbase-1.4.0/conf
export HBASE_LOG_DIR=${HBASE_HOME}/logs
export HADOOP_HOME=/usr/local/hadoop-2.7.4
建立日志目录: mkdir /usr/local/hbase-1.4.0/logs
配置hbase-site.xml: vim /usr/local/hbase-1.4.0/conf/hbase-site.xml
添加配置:
<property>
<name>hbase.rootdir</name>
<value>hdfs://node1:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.master</name>
<value>node1:60000</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/usr/java/zookeeper3.4.10/temp</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>node1,node2,node3</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
配置regionservers: vim /usr/local/hbase-1.4.0/conf/regionservers
清空该文件,加入集群的节点,例如我的配置需要写入如下内容:
node2
node3
将hbase scp到node2,node3节点(也即拷贝文件夹hbase-1.4.0到目录/usr/local/下):
sudo scp -r /usr/local/hbase-1.4.0 node2:/usr/local/
sudo scp -r /usr/local/hbase-1.4.0 node3:/usr/local/
按照前面步骤,为node2和node3配置hbase的环境变量。
chown -R hadoop /usr/local/hbase-1.4.0
chgrp -R hadoop /usr/local/hbase-1.4.0
启动前检查zk启动状态:
zkServer.sh status
zk如果没有启动,则启动zk
zkServer.sh start
以hadoop用户在主节点(node1)启动hbase:
/usr/local/hbase-1.4.0/bin/start-hbase.sh
jps查看进程:
主节点:HMaster
从节点:HRegionServer
===========================================================================================
进入hbase的shell环境操作示例:
进入hbase shell命令: hbase shell
hbase(main):001:0> create 'test', 'cf' #建立test表,指定列簇cf
0 row(s) in 19.4230 seconds
=> Hbase::Table - test
hbase(main):002:0> list 'test'
TABLE
test
1 row(s) in 0.3910 seconds
=> ["test"]
hbase(main):003:0> put 'test', 'row1', 'cf:a', 'value' #插入数据
0 row(s) in 1.4090 seconds
hbase(main):004:0> put 'test', 'row2', 'cf:b', 'value2'
0 row(s) in 0.0440 seconds
hbase(main):005:0> put 'test', 'row3', 'cf:c', 'value3'
0 row(s) in 0.0280 seconds
hbase(main):006:0> put 'test', 'row4', 'cf:d', 'value4'
0 row(s) in 0.0290 seconds
hbase(main):007:0> put 'test', 'row1', 'cf:aa', 'valuea'
0 row(s) in 0.0700 seconds
hbase(main):008:0> put 'test', 'row2', 'cf:bb', 'valueb'
0 row(s) in 0.0240 seconds
hbase(main):009:0> put 'test', 'row3', 'cf:cc', 'valuec'
0 row(s) in 0.0540 seconds
hbase(main):010:0> put 'test', 'row4', 'cf:dd', 'valued'
0 row(s) in 0.0480 seconds
hbase(main):011:0> scan 'test' #扫描全表
ROW COLUMN+CELL
row1 column=cf:a, timestamp=1515398486936, value=value
row1 column=cf:aa, timestamp=1515398553829, value=valuea
row2 column=cf:b, timestamp=1515398504469, value=value2
row2 column=cf:bb, timestamp=1515398569383, value=valueb
row3 column=cf:c, timestamp=1515398523476, value=value3
row3 column=cf:cc, timestamp=1515398585233, value=valuec
row4 column=cf:d, timestamp=1515398537726, value=value4
row4 column=cf:dd, timestamp=1515398597533, value=valued
4 row(s) in 0.1100 seconds
hbase(main):012:0> get 'test', 'row1' #查询rowkey是 row1的记录
COLUMN CELL
cf:a timestamp=1515398486936, value=value
cf:aa timestamp=1515398553829, value=valuea
1 row(s) in 0.3240 seconds
退出hbase shell命令: exit
centos7 安装hbase三节点集群笔记
最新推荐文章于 2024-08-21 02:47:25 发布