[Yandex Cloud documentation](../../../index.md) > [Yandex MetaData Hub](../../index.md) > Apache Hive™ Metastore > Step-by-step guides > Maintenance

# Apache Hive™ Metastore cluster maintenance

You can manage [maintenance](../../concepts/metastore-maintenance.md) of a Apache Hive™ Metastore cluster.


## Getting a list of maintenance jobs {#list-maintenance}

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), navigate to the relevant folder.
  1. [Navigate](../../../console/operations/select-service.md#select-service) to **Yandex MetaData Hub**.
  1. In the left-hand panel, select ![image](../../../_assets/console-icons/database.svg) **Metastore**.
  1. Click the name of your cluster and select the ![image](../../../_assets/console-icons/bars-play.svg) **Maintenance** tab.

      To view maintenance jobs with a specific status, select the status you want from the **Status** field above the list of maintenance jobs. To find a specific maintenance job, enter its ID or task name in the field above the list of maintenance jobs.

{% endlist %}


## Getting cluster maintenance logs {#maintenance-logs}

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), navigate to the relevant folder.
  1. [Navigate](../../../console/operations/select-service.md#select-service) to **Yandex MetaData Hub**.
  1. In the left-hand panel, select ![image](../../../_assets/console-icons/database.svg) **Metastore**.
  1. Click the name of your cluster and select the ![image](../../../_assets/console-icons/bars-play.svg) **Maintenance** tab.
  1. Select a maintenance job. The maintenance page will open.
  1. Click **Task logs**.

{% endlist %}


## Moving scheduled maintenance {#postpone-planned-maintenance}

Maintenance with the **Planned** status is scheduled for the date and time specified in the **Start date** column. You can reschedule it to a new date and time as needed.

To reschedule maintenance for a new date and time:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), navigate to the relevant folder.
  1. [Navigate](../../../console/operations/select-service.md#select-service) to **Yandex MetaData Hub**.
  1. In the left-hand panel, select ![image](../../../_assets/console-icons/database.svg) **Metastore**.
  1. Click the name of your cluster and select the ![image](../../../_assets/console-icons/bars-play.svg) **Maintenance** tab.
  1. Click ![image](../../../_assets/console-icons/ellipsis.svg) next to the maintenance with the **Planned** status and select ![image](../../../_assets/console-icons/arrow-uturn-cw-right.svg) **Postpone**.
  1. Select the reschedule type for the planned maintenance:
    
      * **Next window**: Reschedule to the next maintenance window.
      * **Choose date (UTC)**: Reschedule to a specific date and time.

        For this option, select the date and UTC time interval.

        Maintenance can be postponed for a maximum of two weeks from the original scheduled date.

  1. Click **Reschedule**.

{% endlist %}


## Starting scheduled maintenance immediately {#exec-planned-maintenance}

If you need to, you can perform a maintenance with the **Planned** status immediately without waiting for the time specified in the **Start date** column.

To run a scheduled cluster maintenance job immediately:

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), navigate to the relevant folder.
  1. [Navigate](../../../console/operations/select-service.md#select-service) to **Yandex MetaData Hub**.
  1. In the left-hand panel, select ![image](../../../_assets/console-icons/database.svg) **Metastore**.
  1. Click the name of your cluster and select the ![image](../../../_assets/console-icons/bars-play.svg) **Maintenance** tab.
  1. In the maintenance row, click ![image](../../../_assets/console-icons/ellipsis.svg) and select ![image](../../../_assets/console-icons/triangle-right.svg) **Carry out now**.

{% endlist %}


## Configuring a maintenance window {#set-maintenance-window}

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), navigate to the relevant folder.
  1. [Navigate](../../../console/operations/select-service.md#select-service) to **Yandex MetaData Hub**.
  1. In the left-hand panel, select ![image](../../../_assets/console-icons/database.svg) **Metastore**.
  1. Click the name of your cluster and select the ![image](../../../_assets/console-icons/bars-play.svg) **Maintenance** tab.
  1. Click ![image](../../../_assets/console-icons/calendar.svg) **Configure the maintenance window** in the top-right corner of the page.
  1. Select cluster [maintenance](../../concepts/metastore-maintenance.md) time:

      * To allow maintenance at any time, select **At any time** (default).
      * To specify the preferred maintenance start time, select **By schedule** and specify the day of the week and the UTC time interval. For example, you can choose the cluster's least busy time.
      
      Both active and stopped clusters are subject to maintenance operations. These may include installing Apache Hive™ Metastore updates and patches as well as other maintenance works.

  1. Click **Save**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To configure a [maintenance window](../../concepts/metastore-maintenance.md#maintenance-window):
    
  1. See the description of the CLI command for updating cluster settings:
    
      ```bash
      yc managed-metastore cluster update --help
      ```
  
  1. Configure the maintenance window:
    
      ```bash
      yc managed-metastore cluster update <cluster_name_or_ID> \
        --maintenance-window type=<maintenance_type>,`
                            `day=<day_of_week>,`
                            `hour=<sequence_number_of_hour_interval>
      ```
    
      Where:
      
      * `<cluster_name_or_ID>`: Cluster name or ID which you can get with the [list of clusters in the folder](cluster-list.md#list-clusters).
      * `--maintenance-window`: [Maintenance window](../../concepts/metastore-maintenance.md) settings that apply to both running and stopped clusters. The `type` setting defines the maintenance type:

        * `anytime`: Any time (default).
        * `weekly`: On a schedule. For this value, also specify the following:
            * `day`: Day of week, i.e., `MON`, `TUE`, `WED`, `THU`, `FRI`, `SAT`, or `SUN`.
            * `hour`: Sequence number of UTC hour interval, from `1` to `24`.
        
              > For example, `1` stands for the interval from `00:00` to `01:00`, and `5`, from `04:00` to `05:00`.


- Terraform {#tf}

  1. Open the current Terraform configuration file with the infrastructure plan.

      To learn how to create this file, see [Creating a cluster](cluster-create.md).

      For the complete list of configurable Apache Hive™ Metastore cluster fields, see [this Terraform provider guide](../../../terraform/resources/metastore_cluster.md).

  1. To set up a [maintenance window](../../concepts/metastore-maintenance.md#maintenance-window), add the `maintenance_window` section to the cluster description:
  
      ```hcl
      resource "yandex_metastore_cluster" "<local_cluster_name>" {
        ...
        maintenance_window = {
          type = "<maintenance_type>"
          day  = "<day_of_week>"
          hour = <sequence_number_of_hour_interval>
        }
        ...
      }
      ```

      Where:
      
      * `type`: Maintenance type. The possible values include:
      
        * `ANYTIME`: Any time.
        * `WEEKLY`: On a schedule.
      
      * `day`: Day of week for the `WEEKLY` type, i.e., `MON`, `TUE`, `WED`, `THU`, `FRI`, `SAT`, or `SUN`.
      * `hour`: UTC hour interval for the `WEEKLY` type, from `1` to `24`.
        
        > For example, `1` stands for the interval from `00:00` to `01:00`, and `5`, from `04:00` to `05:00`.

  1. Make sure the settings are correct.

      1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
      1. Run this command:
      
         ```bash
         terraform validate
         ```
      
         Terraform will show any errors found in your configuration files.

  1. Confirm updating the resources.

      1. Run this command to view the planned changes:
      
         ```bash
         terraform plan
         ```
      
         If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
      
      1. If everything looks correct, apply the changes:
         1. Run this command:
      
            ```bash
            terraform apply
            ```
      
         1. Confirm updating the resources.
         1. Wait for the operation to complete.


- REST API {#api}
  
  1. [Get an IAM token for API authentication](../../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```
  
  1. Call the [Cluster.Update](../../api-ref/Cluster/update.md) method, e.g., via the following [cURL](https://curl.se/) request:
  
      ```bash
      curl \
        --request PATCH \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --header "Content-Type: application/json" \
        --url 'https://metastore.api.cloud.yandex.net/managed-metastore/v1/clusters/<cluster_ID>' \
        --data '{
                 "updateMask": "maintenanceWindow",
                 "maintenanceWindow": {
                   "weeklyMaintenanceWindow": {
                     "day": "<day_of_week>",
                     "hour": "<sequence_number_of_hour_interval>"
                   }
                 }
               }'
      ```
    
      Where:
      
      * `<cluster_ID>`: Cluster ID which you can get with the [list of clusters in the folder](cluster-list.md#list-clusters).

      * `updateMask`: Comma-separated string of settings to update.

        In this example, only the `maintenanceWindow` setting is provided.

        {% note warning %}
        
        All settings of the cluster object you are modifying will be reset to their defaults unless explicitly provided in the request. To avoid this, list the settings you want to change in the `updateMask` parameter.

        {% endnote %}

      * `maintenanceWindow`: [Maintenance](../../concepts/metastore-maintenance.md) window settings, applying to both running and stopped clusters. In `maintenanceWindow`, provide one of these two parameters:
        
          * `anytime`: Maintenance can take place at any time.
          * `weeklyMaintenanceWindow`: Maintenance takes place once a week at the specified time:
        
            * `day`: Day of week in `DDD` format, i.e., `MON`, `TUE`, `WED`, `THU`, `FRI`, `SAT`, or `SUN`.
            * `hour`: UTC hour interval, from `1` to `24`.
        
              > For example, `1` stands for the interval from `00:00` to `01:00`, and `5`, from `04:00` to `05:00`.
  
  1. Check the [server response](../../api-ref/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}
  
  1. [Get an IAM token for API authentication](../../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
     
     ```bash
     cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
     ```
     
     Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

  1. Call the [ClusterService.Update](../../api-ref/grpc/Cluster/update.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:
  
      ```bash
      grpcurl \
        -format json \
        -import-path ~/cloudapi/ \
        -import-path ~/cloudapi/third_party/googleapis/ \
        -proto ~/cloudapi/yandex/cloud/metastore/v1/cluster_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d '{
             "cluster_id": "<cluster_ID>",
             "update_mask": {
               "paths": [
                 "maintenance_window"
               ]
             },
             "maintenance_window": {
               "weekly_maintenance_window": {
                 "day": "<day_of_week>",
                 "hour": "<sequence_number_of_hour_interval>"
               }
             }
           }' \
        metastore.api.cloud.yandex.net:443 \
        yandex.cloud.metastore.v1.ClusterService.Update \
      ```
    
      Where:

      * `cluster_id`: Cluster ID which you can get with the [list of clusters in the folder](cluster-list.md#list-clusters).
      * `update_mask`: List of settings to update as an array of strings (`paths[]`).

        {% cut "Format for listing settings" %}

        ```yaml
        "update_mask": {
          "paths": [
            "<setting_1>",
            "<setting_2>",
            ...
            "<setting_N>"
          ]
        }
        ```

        {% endcut %}

        In this example, only the `maintenance_window` setting is provided.

        {% note warning %}

        All settings of the cluster object you are modifying will be reset to their defaults unless explicitly provided in the request. To avoid this, list the settings you want to change in the `update_mask` parameter.

        {% endnote %}

      * `maintenance_window`: [Maintenance](../../concepts/metastore-maintenance.md) window settings, applying to both running and stopped clusters. In `maintenance_window`, provide one of these two parameters:
        
          * `anytime`: Maintenance can take place at any time.
          * `weekly_maintenance_window`: Maintenance takes place once a week at the specified time:
        
            * `day`: Day of week in `DDD` format, i.e., `MON`, `TUE`, `WED`, `THU`, `FRI`, `SAT`, or `SUN`.
            * `hour`: UTC hour interval, from `1` to `24`.
        
              > For example, `1` stands for the interval from `00:00` to `01:00`, and `5`, from `04:00` to `05:00`.
  
  1. Check the [server response](../../api-ref/grpc/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}

_Apache® and [Apache Hive™](https://hive.apache.org/) are either registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries._