【Hbase學習筆記】1.Hbase單機安裝Standalone Mode

今年來以爲數據還蠻有意思的,打算往這個方向努力了

這裏主要仍是以manjaro爲案例進行安裝,用了很長時間這個系統,逐漸以爲這個發行版確實是比Ubuntu要舒服。html

安裝JDK

其實shell命令也不重要,主要是安裝JDK,而後設置JAVA_HOME環境變量,雖然在manjaro中默承認以使用java命令,可是安裝並無設置JAVA_HOME環境變量,hbase啓動腳步仍是經過環境獲取java的目錄。因此只要在當前執行目錄中能獲取JAVA_HOME就能夠成功啓動hbase。java

這個我感受很多程序員都沒有真正理解環境變量這玩意,環境變量在平常開發中仍是比較有用的一個東西,在Linux下能夠用 env獲取當前所有的環境,或者使用echo ${name}, {name}指你須要的獲取環境變量名,如 echo $JAVA_HOME,使用echo打印環境變量是一個很基本的操做。
sudo pacman -S jdk8-openjdk

# 在添加java到環境變量中
echo 'export JAVA_HOME=/usr/lib/jvm/java-8-openjdk' >>  conf/hbase-env.sh

下載hbase的二進制壓縮包

hbase官方下載地址程序員

下載的話能夠根據須要,我以爲我的學習仍是下最新的吧,哈哈哈shell

通常來講都是下載帶有releasebin的連接,src表明源碼,至於sha512/asc這種就是校驗下載是否是完整的。express

下載完成能夠解壓到你想放的目錄,我習慣放在home目錄下apache

tar -C $HOME/Bin/ -zxvf hbase-2.2.2-bin.tar.gz

修改配置

進入解壓的目錄,找到conf/hbase-site.xml的文件,原來的文件應該是app

<?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>
</configuration>

在<configuration>中添加less

<property>
        <name>hbase.rootdir</name>
        <value>file://{pathname}</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.dataDir</name>
        <value>{zookeeper-pathname}</value>
    </property>
    <property>
        <name>hbase.unsafe.stream.capability.enforce</name>
        <value>false</value>
    </property>
講解下參數
  • hbase.rootdir:hbase寫入數據的位置,默認是在/tmp目錄下新建,不過這樣開關機就會消失,因此須要你指定一個路徑,我通常指定home目錄下的某個位置,這樣啓動時不須要目錄的權限什麼的。
  • hbase.zookeeper.property.dataDir: 這個是zookeeper寫入數據的位置
  • hbase.unsafe.stream.capability.enforce: 在local模式下禁用stream.capability (hflush/hsync)的功能,反正單機部署不須要嚴格數據保證就禁用吧

啓動

啓動hbase:jvm

./bin/start-hbase.sh

啓動shell:oop

➜  bin ./hbase shell
2019-12-15 22:38:39,788 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.2.2, re6513a76c91cceda95dad7af246ac81d46fa2589, Sat Oct 19 10:10:12 UTC 2019
Took 0.0019 seconds                                                                                           
hbase(main):001:0>

關閉hbase:

./bin/stop-hbase.sh

這裏就已經能夠算是完成了。

相關文章
相關標籤/搜索