tencent cloud

Feedback

Practice Tutorial on Switching HDFS DataNode Maintenance Status

Last updated: 2024-10-30 10:40:18
    The DataNode maintenance status (IN_MAINTENANCE) is applicable for scenes where the DataNode is temporarily offline but does not require data migration, such as quick service repairs or disk replacement. In the DataNode maintenance mode, the operation entry is not enabled by default in the console and requires manual configuration by the user for support.
    Note:
    1. This operation is only supported for Hadoop 3.x and later versions.
    2. DataNodes in a paused status do not support maintenance operations.

    Enabling Console Switching Management Status Operation Entry

    1. Modify the contents of hdfshosts to JSON format.
    Use the console cluster script feature to execute the script files hdfshosts_txt_to_json.sh and hdfshosts_txt_to_json_rollback.sh on the Master node. The contents of the script files are as follows:
    #!/bin/bash
    
    cd /usr/local/service/hadoop/etc/hadoop
    file=hdfshosts
    if [ ! -f "$file" ];then
    echo "$file not exists"
    exit -1
    fi
    
    bak_file="$file.txt.bak"
    if [ ! -f "$bak_file" ];then
    cp -f $file $file.txt.bak
    fi
    
    output_file="$file.tmp"
    ## Generate JSON File
    echo '[' > "$output_file"
    first_record=true
    while IFS= read -r line
    do
    if [ "$first_record" = false ]; then
    echo ',' >> "$output_file"
    fi
    
    echo " {\\"hostName\\": \\"$line\\"}" >> "$output_file"
    
    first_record=false
    done < "$file"
    echo ']' >> "$output_file"
    mv -f $output_file $file
    chown hadoop:hadoop $file
    chmod 755 $file
    cat $file
    #!/bin/bash
    
    cd /usr/local/service/hadoop/etc/hadoop
    file=hdfshosts
    bak_file="$file.txt.bak"
    cp -f $bak_file $file
    chown hadoop:hadoop $file
    chmod 755 $file
    cat $file
    2. Add a configuration item to hdfs-site.xml.
    Add the configuration parameter dfs.namenode.hosts.provider.classname with the value org.apache.hadoop.hdfs.server.blockmanagement.CombinedHostFileManager.
    
    
    
    3. After the configuration is saved and applied, restart NameNode.
    4. Check via WebUI or by running hdfs dfsadmin -report.
    5. (Recommended) Perform a scale-in and scale-out operation on the core nodes once, as the above operations will modify the hdfshosts file, preventing potential issues in the future.
    6.The Switch Management Status button will appear in the HDFS Role Management section.

    DataNode Entering Maintenance Status

    1. Log in to the EMR console and click the corresponding Cluster ID/Nam in the cluster list to enter the cluster details page.
    2. On the cluster details page, click Cluster Services, and then select HDFS component and go to Operations > Role Management in the top right corner.
    3. After checking the DataNode role whose operation status is started in role management, switch the status and put DataNode into maintenance status operation.
    4. When you choose to enter maintenance status, you can set the maintenance duration. During the ma4.intenance period, the DataNode will cease to provide external services and no data migration will occur. If the service is not recovered after the configured maintenance period expires, data migration will start.

    DataNode Exiting Maintenance Status

    1. If the node repair is completed within the maintenance period, the DataNode will automatically resume providing external services after the timeout. However, the maintenance status should be manually exited by the user via the console.
    2. Log in to the EMR console and click the corresponding Cluster ID/Name in the cluster list to enter the cluster details page.
    3. After selecting the DataNode role with the operation status set to Started (Under Maintenance) in Role Management, change the status to take DataNode out of maintenance mode operation.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support