Install Hbase in CentOS and Ubuntu

created at 08-06-2021 views: 12

It is recommended to install the new version of the small partners to look at the corresponding relationship first, so as to avoid incompatibility between jdk and hbase

Compatibility between jdk and Hbase:

Compatibility between jdk and Hbase

1. Download and unzip the installation file

wget http://ftp.mirror.tw/pub/apache/hbase/2.2.5/hbase-2.2.5-bin.tar.gz

tar xvfz hbase-2.2.5-bin.tar.gz

2. Start HBase

/usr/hbase-2.2.7/bin/start-hbase.sh

If an error is reported like:

+=========================================================+
| Error: JAVA_HOME is not set and Java could not be found |
+----------------------------------------------------------------------+
| Please download the latest Sun JDK from the Sun Java web site |
| > http://java.sun.com/javase/downloads/ < |
| |
| Hadoop requires Java 1.6 or later. |
| NOTE: This script will find Sun Java whether you install using the |
| binary or the RPM based installer. |
+=========================================================+

Need to modify the HBase configuration file, the configuration file is in the conf/ folder

vi conf/hbase-env.sh

Add the location of the JDK, take my machine as an example, the JDK is placed under /usr/lib/jdk:

exportJAVA_HOME=/usr/lib/jdk/jdk1.8.0_301/

It should be noted that the JDK needs to be installed by yourself. If the system already has its own JDK, it is better to delete it and install it again. Otherwise, it is useless to modify the configuration file to start!

Uninstall openjdk under CentOS

1. View the java version

[root@CFDB2 ~]# java -version

openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-b10)
OpenJDK 64-Bit Server VM (build 25.171-b10, mixed mode)

2. View the java installation software

[root@CFDB2 ~]# rpm -qa|grep java

tzdata-java-2018e-3.el7.noarch
java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64
java-1.7.0-openjdk-headless-1.7.0.181-2.6.14.8.el7_5.x86_64
java-1.7.0-openjdk-1.7.0.181-2.6.14.8.el7_5.x86_64
javapackages-tools-3.4.1-11.el7.noarch
python-javapackages-3.4.1-11.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.171-8.b10.el7_5.x86_64

[root@CFDB2 ~]#

3. Uninstall openjdk

# .noarch does not need to be deleted
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_64

Uninstall openjdk under Ubuntu

sudo apt-get remove openjdk*

install jdk

The steps to install jdk are the same

step 1. Download the corresponding jdk version

go to oracle 

step 2. Copy the decompressed folder to the /usr/lib/jdk/ directory, if there is no jdk folder here, create the folder under /usr/lib

cd /usr/lib
mkdir jdk
tar zxvf ./jdk-8u301-linux-x64.tar.gz -C /usr/lib/jdk
cd /cd ./jdk1.8.0_301

step 3. Set environment variables

Open the /etc/profile file

vim /etc/profile

You can add the following two types at the end of the file:

export JAVA_HOME=/usr/lib/jdk/jdk1.8.0_301
export JRE_HOME=/usr/lib/jdk/jdk1.8.0_301/jre
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

export JAVA_HOME=/usr/lib/jdk/jdk1.8.0_301
export JRE_HOME=/usr/lib/jdk/jdk1.8.0_301/jre
export PATH=$PATH:$JAVA_HOME/bin/
export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

4. Modify the default JDK of the system (if you have not installed other JDKs before, you can skip this step)

update-alternatives --install /usr/bin/java java /usr/lib/jdk/jdk1.8.0_161/bin/java 300

update-alternatives --install /usr/bin/javac javac /usr/lib/jdk/jdk1.8.0_161/bin/javac 300

update-alternatives --config java

update-alternatives --config javac

5. Re-check the java version

java -version

Restart HBase after configuring jdk

/usr/hbase-2.2.7/bin/start-hbase.sh

If the startup is successful, there will be the following prompt message:

running master, logging to /home/lyl/taiji/hbase/hbase-2.2.7/bin/../logs/hbase-root-master-lyl-ThinkServer-TS80X.out

The browser enters the following URL to open the hbase client

http://xx.xx.xx.xx:16010

xx.xx.xx.xx is the ip address of the server installed by yourself, each server is different

hbase client

If hbase is started successfully, the browser cannot access the client, please turn off the server firewall and visit again

  • CentOS turns off the firewall: systemctl stop firewalld.service
  • Ubuntu turns off the firewall: sudo ufw disable
created at:08-06-2021
edited at: 08-06-2021: