Updated on 2022-09-14 GMT+08:00

Compiling and Running Applications

OpenTSDB applications can run in a Linux environment where an OpenTSDB client is 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 client is installed 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 client locates. The host names and IP addresses must be mapped one by one.

Procedure

  1. Log in to the Linux environment, create a directory for running the OpenTSDB sample project, for example, /opt/opentsdb-example, and a directory for storing configuration files, for example, /opt/opentsdb-example/conf. Then, edit the /opt/opentsdb-example/conf/opentsdb.properties configuration file based on actual requirements.

    mkdir -p /opt/opentsdb-example/conf
    [root@node-master1rLqO ~]# cat /opt/opentsdb-example/conf/opentsdb.properties
    tsd_hostname = node-ana-corejnWt
    tsd_port = 4242
    tsd_protocol = https

  2. Run the mvn package command to generate a JAR file, for example, opentsdb-examples-mrs-xxx-jar-with-dependencies.jar, in which mrs-xxx indicates an MRS version. Obtain the JAR file from the target directory in the project directory, and upload it to the /opt/opentsdb-example directory.
  3. Run the JAR file.

    Load the environment variables.

    source /opt/client/bigdata_env

    Authenticate the cluster user. (Skip this step for a cluster with Kerberos disabled.)

    Human-machine user: kinit kerberos user

    Machine-machine user: kinit -kt authentication file path kerberos user

    Run the OpenTSDB sample program.
    java -cp /opt/opentsdb-example/conf:/opt/opentsdb-example/opentsdb-examples-mrs-xxx-jar-with-dependencies.jar com.huawei.bigdata.opentsdb.examples.OpentsdbExample