Updated on 2022-06-01 GMT+08:00

Compiling and Running Applications

Scenario

You can run applications in the Windows development environment after application code is developed.

Procedure

  1. Configure a mapping between the cluster IP address and host name on Windows. Log in to the cluster background, run the cat /etc/hosts command, and copy the mapping between IP addresses and host names in the hosts file to C:\Windows\System32\drivers\etc\hosts.

    xx.xx.xx.xx node-ana-corejnWt
    xx.xx.xx.xx node-ana-coreddlI

    You can use either of the following method to access an MRS cluster to operate OpenTSDB on Windows.

    • Apply for a Windows ECS to access the MRS cluster to operate OpenTSDB. Run the sample code after the development environment is installed. To apply for ECS to access the MRS cluster, perform the following steps:
      1. On the Active Clusters page, click the name of an existing cluster.

        On the cluster details page, record the AZ, VPC, Cluster Manager IP Address of the cluster, and Default Security Group of the Master node.

      2. On the ECS management console, create a new ECS.

        The AZ, VPC, and security group of ECS must be the same as those of the cluster to be accessed.

        Select a Windows public image.

        For details about other configuration parameters, see Elastic Cloud Server > Quick Start > Purchasing and Logging In to a Windows ECS.

    • Use the local host to access the MRS cluster to operate OpenTSDB. Bind an EIP to the TSD instance that OpenTSDB in the MRS cluster accesses. When configuring the mapping between the IP address and host name of the cluster on the local Windows host, replace the IP address with the EIP corresponding to the host name. Run the sample code. To bind an EIP, perform the following steps:
      1. On the VPC management console, apply for an EIP and bind it to ECS.

        For details, see Virtual Private Cloud > User Guide > Elastic IP Address > Assigning an EIP and Binding It to an ECS.

      2. Open security group rules for the MRS cluster.

        Add security group rules to the security groups of Master and Core nodes in the cluster so that ECS can access the cluster. For details, see Virtual Private Cloud > User Guide > Security > Security Group > Adding a Security Group Rule.

  2. Copy the /opt/Bigdata/jdk1.8.0_212/jre/lib/security/cacerts file on the master node in the cluster to the JDK directory on Windows, for example, C:\Program Files\Java\jdk1.8.0_73\jre\lib\security.
  3. Modify related configurations. Modify the opentsdb.properties file in the resources directory of the sample project and configure the OpenTSDB properties.

    tsd_hostname = node-ana-corejnWt
    tsd_port = 4242
    tsd_protocol = https
    • tsd_hostname: name of the connected TSD instance host for accessing OpenTSDB
    • tsd_port: port for accessing OpenTSDB. The default port number is 4242.
    • tsd_protocol: request protocol for accessing OpenTSDB. The default value is https.

  4. Run the sample project.

    In the development environment (for example, Eclipse), right-click OpentsdbExample.java and choose Run as > Java Application from the shortcut menu to run the corresponding application project.