Help Center/ MapReduce Service/ Component Operation Guide (LTS) (Paris Region)/ Using Hive/ Common Issues About Hive/ How Do I Delete UDFs on Multiple HiveServers at the Same Time?
Updated on 2022-12-14 GMT+08:00

How Do I Delete UDFs on Multiple HiveServers at the Same Time?

Question

How can I delete permanent user-defined functions (UDFs) on multiple HiveServers at the same time?

Answer

Multiple HiveServers share one MetaStore database. Therefore, there is a delay in the data synchronization between the MetaStore database and the HiveServer memory. If a permanent UDF is deleted from one HiveServer, the operation result cannot be synchronized to the other HiveServers promptly.

In this case, you need to log in to the Hive client to connect to each HiveServer and delete permanent UDFs on the HiveServers one by one. The operations are as follows:

  1. Log in to the node where the Hive client is installed as the Hive client installation user.
  2. Run the following command to go to the client installation directory:

    cd Client installation directory

    For example, if the client installation directory is /opt/client, run the following command:

    cd /opt/client

  3. Run the following command to configure environment variables:

    source bigdata_env

  4. Run the following command to authenticate the user:

    kinit Hive service user

    The login user must have the Hive admin rights.

  5. Run the following command to connect to the specified HiveServer:

    beeline -u "jdbc:hive2://10.39.151.74:21066/default;sasl.qop=auth-conf;auth=KERBEROS;principal=hive/hadoop.<system domain name>@<system domain name>"

    • 10.39.151.74 is the IP address of the node where the HiveServer is located.
    • 21066 is the port number of the HiveServer. The HiveServer port number ranges from 21066 to 21070 by default. Use the actual port number.
    • hive is the username. For example, if the Hive1 instance is used, the username is hive1.
    • You can log in to FusionInsight Manager, choose System > Permission > Domain and Mutual Trust, and view the value of Local Domain, which is the current system domain name.
    • hive/hadoop.<system domain name> is the username. All letters in the system domain name contained in the username are lowercase letters.

  6. Run the following command to enable the Hive admin rights:

    set role admin;

  7. Run the following command to delete the permanent UDF:

    drop function function_name;

    • function_name indicates the name of the permanent function.
    • If the permanent UDF is created in Spark, the permanent UDF needs to be deleted from Spark and then from HiveServer by running the preceding command.

  8. Check whether the permanent UDFs are deleted from all HiveServers.

    • If yes, no further action is required.
    • If no, go to 5.