版權聲明:本文為部落客原創文章,未經部落客允許不得轉載。 https://blog.csdn.net/SunnyYoona/article/details/53456433
1. 啟動Hadoop
如果沒有安裝Hadoop,則檢視博文:
http://blog.csdn.net/sunnyyoona/article/details/53454430啟動Hadoop并檢視Hadoop版本:
-
xiaosi@yoona:~/opt/hadoop-2.7.3$ sbin/start-dfs.sh
-
Starting namenodes on [localhost]
-
localhost: starting namenode, logging to /home/xiaosi/opt/hadoop-2.7.3/logs/hadoop-xiaosi-namenode-yoona.out
-
localhost: starting datanode, logging to /home/xiaosi/opt/hadoop-2.7.3/logs/hadoop-xiaosi-datanode-yoona.out
-
Starting secondary namenodes [0.0.0.0]
-
0.0.0.0: starting secondarynamenode, logging to /home/xiaosi/opt/hadoop-2.7.3/logs/hadoop-xiaosi-secondarynamenode-yoona.out
-
xiaosi@yoona:~/opt/hadoop-2.7.3$ bin/hadoop version
-
Hadoop 2.7.3
-
Subversion https://git-wip-us.apache.org/repos/asf/hadoop.git -r baa91f7c6bc9cb92be5982de4719c1c8af91ccff
-
Compiled by root on 2016-08-18T01:41Z
-
Compiled with protoc 2.5.0
-
From source with checksum 2e4ce5f957ea4db193bce3734ff29ff4
-
This command was run using /home/xiaosi/opt/hadoop-2.7.3/share/hadoop/common/hadoop-common-2.7.3.jar
從上可以知道Hadoop版本為2.7.3版本
2. 下載下傳與解壓
我們從官網上下載下傳:
http://www.apache.org/dyn/closer.cgi/hbase/解壓到~/opt檔案夾下:
-
xiaosi@yoona:~$ tar -zxvf hbase-1.2.4-bin.tar.gz -C opt/
重命名,便與管理:
-
xiaosi@yoona:~$ cp hbase-1.2.4-bin.tar.gz hbase-1.2.4
3. 配置
修改hbase-env.sh,配置JDK路徑以及Zookeeper:
-
# The java implementation to use. Java 1.7+ required.
-
export JAVA_HOME=/home/xiaosi/opt/jdk-1.8.0
-
# Tell HBase whether it should manage it's own instance of Zookeeper or not.
-
export HBASE_MANAGES_ZK=true
修改hbase-site.xml
-
<?xml version="1.0"?>
-
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-
<!--
-
/**
-
*
-
* Licensed to the Apache Software Foundation (ASF) under one
-
* or more contributor license agreements. See the NOTICE file
-
* distributed with this work for additional information
-
* regarding copyright ownership. The ASF licenses this file
-
* to you under the Apache License, Version 2.0 (the
-
* "License"); you may not use this file except in compliance
-
* with the License. You may obtain a copy of the License at
-
*
-
* http://www.apache.org/licenses/LICENSE-2.0
-
*
-
* Unless required by applicable law or agreed to in writing, software
-
* distributed under the License is distributed on an "AS IS" BASIS,
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
* See the License for the specific language governing permissions and
-
* limitations under the License.
-
*/
-
-->
-
<configuration>
-
<property>
-
<name>system.username</name>
-
<value>xiaosi</value>
-
</property>
-
<property>
-
<name>hbase.rootdir</name>
-
<value>hdfs://localhost:9000/hbase</value>
-
</property>
-
<property>
-
<name>hbase.cluster.distributed</name>
-
<value>true</value>
-
</property>
-
<property>
-
<name>hbase.tmp.dir</name>
-
<value>/home/${system.username}/tmp/hbase</value>
-
</property>
-
</configuration>
4. 設定環境變量
在/etc/profile配置檔案中,建立HBASE_HOME環境變量指向hbase目錄,便于以後操作:
-
# hbase
-
export HBASE_HOME=/home/xiaosi/opt/hbase-1.2.4
-
export PATH=${HBASE_HOME}/bin:$PATH
5. 啟動Hadoop
進入 Hadoop 主檔案夾,開啟NameNode和DataNode守護程序:
-
xiaosi@yoona:~/opt/hadoop-2.7.3$ cd ~
-
xiaosi@yoona:~$ cd $HADOOP_HOME
-
xiaosi@yoona:~/opt/hadoop-2.7.3$ sbin/start-dfs.sh
-
Starting namenodes on [localhost]
-
localhost: starting namenode, logging to /home/xiaosi/opt/hadoop-2.7.3/logs/hadoop-xiaosi-namenode-yoona.out
-
localhost: starting datanode, logging to /home/xiaosi/opt/hadoop-2.7.3/logs/hadoop-xiaosi-datanode-yoona.out
-
Starting secondary namenodes [0.0.0.0]
-
0.0.0.0: starting secondarynamenode, logging to /home/xiaosi/opt/hadoop-2.7.3/logs/hadoop-xiaosi-secondarynamenode-yoona.out
6. 啟動HBase
進入 HBase 主檔案夾,開啟HMaster和HRegionServer守護程序:
-
xiaosi@yoona:~/opt/hbase-1.2.4$ bin/start-hbase.sh
-
localhost: starting zookeeper, logging to /home/xiaosi/opt/hbase-1.2.4/bin/../logs/hbase-xiaosi-zookeeper-yoona.out
-
starting master, logging to /home/xiaosi/opt/hbase-1.2.4/logs/hbase-xiaosi-master-yoona.out
-
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
-
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
-
starting regionserver, logging to /home/xiaosi/opt/hbase-1.2.4/logs/hbase-xiaosi-1-regionserver-yoona.out
通過jps指令檢視啟動情況:
-
xiaosi@yoona:~/opt/hbase-1.2.4$ jps
-
1536 Jps
-
915 HQuorumPeer
-
22886 SecondaryNameNode
-
22678 DataNode
-
1117 HRegionServer
-
989 HMaster
-
22511 NameNode
7. 進入Hbase Shell
-
xiaosi@yoona:~/opt/hbase-1.2.4$ bin/hbase shell
-
SLF4J: Class path contains multiple SLF4J bindings.
-
SLF4J: Found binding in [jar:file:/home/xiaosi/opt/hbase-1.2.4/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
-
SLF4J: Found binding in [jar:file:/home/xiaosi/opt/hadoop-2.7.3/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
-
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
-
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
-
HBase Shell; enter 'help<RETURN>' for list of supported commands.
-
Type "exit<RETURN>" to leave the HBase Shell
-
Version 1.2.4, r67592f3d062743907f8c5ae00dbbe1ae4f69e5af, Tue Oct 25 18:10:20 CDT 2016
-
hbase(main):001:0>
走到這一步,我們已經确定HBase已經安裝成功。為了最終驗證,可以試試列出HBase中所有表的指令。這個動作執行了一個全程請求,從用戶端應用到HBase伺服器,然後傳回。在Shell提示符下,輸入list然後按下Enter鍵:
-
hbase(main):001:0> list
-
TABLE
-
0 row(s) in 0.1980 seconds
-
=> []
完成安裝與驗證,現在可以建立表并存儲一些資料了。
8. 初步使用HBase
建立一個有列族的表student,列族為info:
-
hbase(main):002:0> create 'student', 'info'
-
0 row(s) in 1.3580 seconds
-
=> Hbase::Table - student
再次檢視表:
-
hbase(main):003:0> list
-
TABLE
-
student
-
1 row(s) in 0.0150 seconds
-
=> ["student"]