更新时间:2023-09-14 GMT+08:00

编译并运行程序

OpenTSDB应用程序支持在安装OpenTSDB客户端的Linux环境中运行。在程序代码完成开发后,您可以上传Jar包至Linux环境中运行应用。

前提条件

  • Linux环境已安装JDK,版本号需要和Eclipse导出Jar包使用的JDK版本一致。
  • 当客户端所在主机不是集群中的节点时,需要在客户端所在节点的hosts文件中设置主机名和IP地址映射。主机名和IP地址请保持一一对应。

操作步骤

  1. 登录linux环境,创建运行OpenTSDB样例的工作目录,比如“/opt/opentsdb-example”,配置文件存放目录,比如“/opt/opentsdb-example/conf”,并编辑配置文件“/opt/opentsdb-example/conf/opentsdb.properties”使其对应于实际环境中的信息。

    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. 执行mvn package生成jar包,在工程目录target目录下获取,比如:opentsdb-examples-mrs-xxx-jar-with-dependencies.jar,其中mrs-xxx表示MRS的版本号,将获取的包上传到“/opt/opentsdb-example”目录下。
  3. 执行Jar包。

    加载环境变量。

    source /opt/client/bigdata_env

    认证集群用户(未启用kerberos的集群可跳过此步骤)。

    人机用户:kinit kerberos用户

    机机用户: kinit -kt 认证文件路径 kerberos用户

    运行opentsdb样例程序。
    java -cp /opt/opentsdb-example/conf:/opt/opentsdb-example/opentsdb-examples-mrs-xxx-jar-with-dependencies.jar com.huawei.bigdata.opentsdb.examples.OpentsdbExample