Install Hbase database on Ubuntu

1. Download, decompress and install Hbase

Download the Hbase version yourself (1.1.2 used in the experiment)

Hbase official website: Index of /dist/hbase

Baidu cloud disk extraction code: hoa0

1. Unzip Hbase and modify its name

sudo tar -zxf hbase-1.1.2-bin.tar.gz -C /usr/local
cd /usr/local
sudo mv hbase-2.2.2/ hbase
sudo chown -R hadoop hbase/

2. Configure environment variables

Edit the ~/.bashrc file and add the following code

vim ~/.bashrc

export PATH=$PATH:/usr/local/hbase/bin

#保存退出后记得source ~/.bashrc

 

Use hbase version to view the hbase version

Second, configure the Hbase environment

HBase has three operating modes, stand-alone mode, pseudo-distributed mode, and distributed mode. The following prerequisites are very important. For example, if the JAVA_HOME environment variable is not configured, an error will be reported. – jdk – Hadoop (not required for stand-alone mode, required for pseudo-distributed mode and distributed mode) – SSH

If the above three are not installed, please return to the Hadoop installation experiment to refer to how to install.

1. Configuration /usr/local/hbase/conf/hbase-env.sh, the command is as follows:

vim /usr/local/hbase/conf/hbase-env.sh

#配置JAVA_HOME,HBASE_CLASSPATH,HBASE_MANAGES_ZK.
HBASE_CLASSPATH设置为本机HBase安装目录下的conf目录(即/usr/local/hbase/conf)

export JAVA_HOME=/usr/lib/jdk/jdk1.8.0_121
export HBASE_CLASSPATH=/usr/local/hbase/conf 
export HBASE_MANAGES_ZK=true

2. Configuration/usr/local/hbase/conf/hbase-site.xml

vim /usr/local/hbase/conf/hbase-site.xml

#修改hbase.rootdir,指定HBase数据在HDFS上的存储路径
#将属性hbase.cluter.distributed设置为true。
#假设当前Hadoop集群运行在伪分布式模式下,在Master上运行,且NameNode运行在9000端口

<configuration>
        <property>
                <name>hbase.rootdir</name>  #指定HBase的存储目录
                <value>hdfs://Master:9000/hbase</value>
        </property>
        <property>
                <name>hbase.cluster.distributed</name>  #设置集群处于分布式模式
                <value>true</value>
        </property>
        <property>
        <name>hbase.unsafe.stream.capability.enforce</name>
        <value>false</value>
    </property>
</configuration>

 In the above configuration file, the property hbase.unsafe.stream.capability.enforce is set to avoid startup errors. That is to say, if hbase.unsafe.stream.capability.enforce is not set to false, then after starting HBase, there will be an error that the HMaster process cannot be found. After starting, check the system startup log (/usr/local/hbase/logs /hbase-hadoop-master-ubuntu.log), the following errors will be found:

2022-05-25 23:14:22,933 ERROR [master/localhost:16000:becomeActiveMaster] master.HMaster: Failed to become active master
java.lang.IllegalStateException: The procedure WAL relies on the ability to hsync for proper operation during component failures, but the underlying filesystem does not support doing so. Please check the config value of 'hbase.procedure.store.wal.use.hsync' to set the desired level of robustness and ensure the config value of 'hbase.wal.dir' points to a FileSystem mount that can provide it.

3. Test run Hbase

1. First open the Hadoop cluster and ensure that the Hadoop cluster is running normally

2. Go to the hbase installation directory and use the following command to start Hbase:

./bin/start-hbase.sh

 

3. Enter the Hbase shell interface

./bin/hbase shell


输入exit即可退出shell命令行

 

 4. Stop Hbase using the following command:

bin/stop-hbase.sh

 

Guess you like

Origin blog.csdn.net/weixin_56814370/article/details/125265917