Help Center/
MapReduce Service/
Developer Guide (Normal_Earlier Than 3.x)/
HBase Development Guide/
Commissioning an HBase Application/
Commissioning an HBase Application on Linux/
Compiling and Running an HBase Application When No Client Is Installed
Updated on 2024-08-16 GMT+08:00
Compiling and Running an HBase Application When No Client Is Installed
HBase applications can run in a Linux environment where an HBase client is not installed. After application code development is complete, you can upload a JAR file to the Linux environment to run applications.
Prerequisites
- You have installed a JDK in the Linux environment. The version of the JDK must be consistent with that of the JDK used by Eclipse to export the JAR file.
- If the host where the Linux environment resides is not a node in the cluster, the mapping between the host name and the IP address must be set in the hosts file on the node where the Linux environment resides. The host names and IP addresses must be mapped one by one.
Procedure
- Modify the sample by following instructions in Compiling and Running an HBase Application When a Client Is Installed.
- Run the mvn package command to generate a JAR file, for example, hbase-examples-2.0.jar, and obtain it from the target directory in the project directory.
- Prepare the dependency JAR file and configuration file.
- In the Linux environment, create a directory, for example, /opt/test, and create subdirectories lib and conf. Upload the JAR packages in the /opt/client/HBase/hbase/lib directory on any master node in the cluster and the JAR packages exported in 2 to the lib directory in the new /opt/test directory in the Linux environment. Copy the hbase-site.xml, hdfs-site.xml, and core-site.xml files in the /opt/client/HBase/hbase/conf directory of any master node in the cluster to the conf directory in /opt/test.
- Copy the krb5.conf and user.keytab files obtained in Preparing an HBase Application Development User to the /opt/test/conf directory, and create the hbaseclient.properties file. In the file, user.name corresponds to the new user hbaseuser, the userKeytabName and krb5ConfName paths correspond to the names of the authentication-related files obtained in Preparing an HBase Application Development User (skip this step if Kerberos authentication is not enabled for the cluster).
user.name=hbaseuser userKeytabName=user.keytab krb5ConfName=krb5.conf
- In the /opt/test root directory, create the run.sh script, modify the following content, and save the file.
com.huawei.bigdata.hbase.examples.TestMain is used as an example. Use the actual code instead.
#!/bin/sh BASEDIR=`pwd` cd ${BASEDIR} for file in ${BASEDIR}/lib/*.jar do i_cp=$i_cp:$file echo "$file" done if [ -d ${BASEDIR}/lib/client-facing-thirdparty ]; then for file in ${BASEDIR}/lib/client-facing-thirdparty/*.jar do i_cp=$i_cp:$file done fi java -cp ${BASEDIR}/conf:${i_cp} com.huawei.bigdata.hbase.examples.TestMain
- Go to /opt/test and run the following command to run the JAR file:
sh run.sh
Parent topic: Commissioning an HBase Application on Linux
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot