Updated on 2024-08-10 GMT+08:00

Running Python and Viewing Results

Running Python in CLI Mode

  1. Grant the execution permission for the script of python-examples folder. Run the following command in the CLI:

    chmod +x python-examples -R.

  2. Enter the service plane IP address of the node where HiveServer is installed in the hosts array of python-examples/pyCLI_sec.py.

    When the multi-instance is enabled: In python-examples/pyCLI_sec.py, the hosts array must be modified. In addition, the port must be set according to the used instance. The port (hive.server2.thrift.port) is used for Hive to provide the Thrift service.

  3. Change hadoop.hadoop.com in the conf array of python-examples/pyCLI_sec.py and python-examples/pyline.py to hadoop.the actual domain name. To view the actual domain name, log in to FusionInsight Manager and choose System > Permission > Domain and Mutual Trust > Local Domain.
  4. Run the kinit command to obtain the cache for Kerberos authentication.

    Use the developer account created in Preparing MRS Application Development User to run the following commands to run the client program:

    kinit -kt keytabstorage path username

    cd python-examples

    python pyCLI_sec.py

  5. In the CLI, view the HQL query results in the example codes. For example:

    [['default', '']] 
     [{'comment': 'from deserializer', 'columnName': 'tab_name', 'type': 'STRING_TYPE'}] 
     ['xx']     

    If the following exception occurs:

    importError: libsasl2.so.2: cannot open shared object file: No such file or directory

    You can handle the problem as follows:

    1. Run the following command to check the LibSASL version in the installed operating system.
      ldconfig -p|grep sasl

      If the following is displayed, the current operating system only has the 3.x version.

      libsasl2.so.3 (libc6,x86-64) => /usr/lib64/libsasl2.so.3
      libsasl2.so.3 (libc6) => /usr/lib/libsasl2.so.3
    2. If only the 3. x version exists, run the following command to create a soft link.
      ln -s /usr/lib64/libsasl2.so.3.0.0 /usr/lib64/libsasl2.so.2