Hadoop Hbase installation and configuration

Hadoop HBase installation and configuration

1. Make sure Hadoop is installed/configured

Before installing and configuring HBase, first make sure that Hadoop is installed/configured and can run successfully:

If you haven’t configured Hadoop yet, please refer to: Hadoop Pseudo-Distributed Installation Based on Linux

1.1 Start Hadoop

cd /usr/local/hadoop/sbin # 进入该目录
start-all.sh # 启动服务

jps # 查看进程(6个为正常启动)

1.2 View Hadoop version (to be compatible with Hbase)

hadoop version

Go to Apache official website to check version compatibility: https://hbase.apache.org/book.html#hadoop

The above checked Hadoop version is 3.2.4, so you can install Hbase-2.3.x or Hbase-2.4.x

2. HBase installation

2.1 Download Hbase-2.4.14

Mirror station of Tsinghua University: https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/

The download speed in Linux is slow, you can download the file in Windows first, and then use Xshell to drag it into Linux: Windows files are directly uploaded to Linux

2.2 Unzip and rename

Unzip the installation package hbase-2.4.14-bin.tar.gz to the path /usr/local, the command is as follows:

sudo tar -zxf ~/下载/hbase-2.4.14-bin.tar.gz -C /usr/local

Change the decompressed file name hbase-2.4.14-bin.tar.gz to hbase for convenience, the command is as follows:

sudo mv /usr/local/hbase-2.4.14 /usr/local/hbase

2.3 Configure environment variables

Add the bin directory under hbase to the path, so that you don’t need to go to the /usr/local/hbase directory to start hbase, which greatly facilitates the use of hbase.

2.3.1 Edit ~/.bashrc file

sudo vi ~/.bashrc

Please ~/.bashrcadd the following at the end of the file:

After editing, execute sourcethe command to make the above configuration take effect immediately on the current terminal. The command is as follows:

source ~/.bashrc

2.3.2 Add HBase permissions

cd /usr/local
sudo chown -R hadoop ./hbase       #将hbase下的所有文件的所有者改为hadoop,hadoop是当前用户的用户名。

2.3.3 Check the HBase version to determine whether the installation is successful

/usr/local/hbase/bin/hbase version

It should be a success, right?

3. HBase pseudo-distributed mode configuration

HBase has three operating modes, stand-alone mode, pseudo-distributed mode , and distributed mode. The following prerequisites are very important. If they are not configured properly, an error will be reported:

jdk
Hadoop(伪分布式模式需要)
SSH

3.1 Configure hbase-env.sh

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

Configure JAVA_HOME , HBASE_CLASSPATH , HBASE_MANAGES_ZK .
HBASE_CLASSPATH is set to the conf directory under the local Hadoop installation directory (ie /usr/local/hadoop/conf)

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export HBASE_CLASSPATH=/usr/local/hadoop/conf 
export HBASE_MANAGES_ZK=true

3.2 Configure hbase-site.xml

Open and edit hbase-site.xml with vi, the command is as follows:

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

  • Modify hbase.rootdir to specify the storage path of HBase data on HDFS;

  • Set property hbase.cluter.distributed to true;

  • Assume that the current Hadoop cluster is running in pseudo-distributed mode, running on the local machine, and the NameNode is running on port 9000.

<configuration>
        <property>
                <name>hbase.rootdir</name>
                <value>hdfs://localhost:9000/hbase</value>
        </property>
        <property>
                <name>hbase.cluster.distributed</name>
                <value>true</value>
        </property>
</configuration>

hbase.rootdir specifies the storage directory of HBase; hbase.cluster.distributed sets the cluster to be in distributed mode.

3.3 Test running HBase

The first step: first log in to ssh, and set up a passwordless login before, so no password is required here;

Step 2: Switch to the directory again /usr/local/hadoop;

Step 3: Start hadoop (skip this step if you have already started hadoop).

ssh localhost
cd /usr/local/hadoop
./sbin/start-dfs.sh

Enter the command jps , and you can see that the NameNode, DataNode and SecondaryNameNode have all been successfully started, indicating that hadoop has started successfully, as follows:

Switch directory to /usr/local/hbase, start HBase:

cd /usr/local/hbase
bin/start-hbase.sh

The startup is successful, enter the command jps , and the following interface shows that Hbase starts successfully:

Enter the Shell interface:

Stop HBase running :

bin/stop-hbase.sh

4、Bug 1

Reference blog: https://blog.csdn.net/weixin_42181264/article/details/112168270

The error is as follows :

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-reload4j-1.7.35.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/client-facing-thirdparty/slf4j-reload4j-1.7.33.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.Reload4jLoggerFactory]

Explain that this is a jar package conflict, respectively:

SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-reload4j-1.7.35.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/client-facing-thirdparty/slf4j-reload4j-1.7.33.jar!/org/slf4j/impl/StaticLoggerBinder.class]

Just remove one of the jar packages:

cd /usr/local/hadoop/share/hadoop/common/lib
rm slf4j-reload4j-1.7.35.jar

operation result:

problem solved! ! !

5、Bug 2

Reference blog: https://blog.csdn.net/Software_E/article/details/121390033

The error is as follows :

/usr/local/hadoop/libexec/hadoop-functions.sh: 行 2366: HADOOP_ORG.APACHE.HADOOP.HBASE.UTIL.GETJAVAPROPERTY_USER:无效的变量名
/usr/local/hadoop/libexec/hadoop-functions.sh: 行 2461: HADOOP_ORG.APACHE.HADOOP.HBASE.UTIL.GETJAVAPROPERTY_OPTS:无效的变量名

Solution :

Open the hbase-env.sh file in the ~/hbase-2.3.7/conf (directory is modified according to your own directory) directory for editing:

Uncomment!

operation result:

problem solved! ! !

6、Bug 3

Reference blog: https://blog.csdn.net/qq_44642612/article/details/104379893

The error is as follows :

2022-10-12 16:28:02,575 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable

Solution :

Enter /usr/local/hadoop/etc/hadoop/log4j.propertiesthe file and add the command at the end of the file:

cd /usr/local/hadoop/etc/hadoop
sudo vi log4j.properties

log4j.logger.org.apache.hadoop.util.NativeCodeLoader=ERROR

operation result:

Doesn't seem to be resolved and warnings don't get in the way?

Guess you like

Origin blog.csdn.net/m0_70885101/article/details/127291209