El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page
Help Center/ Auto Scaling/ User Guide (Kuala Lumpur Region)/ FAQs/ Others/ How Do I Enable Automatic Initialization of EVS Disks on Instances that Have Been Added to an AS Group During Scaling Actions?

How Do I Enable Automatic Initialization of EVS Disks on Instances that Have Been Added to an AS Group During Scaling Actions?

Updated on 2022-08-15 GMT+08:00

Scenarios

After an ECS instance is created, you need to manually initialize EVS disks attached to the instance before using them. If multiple instances are added to the AS group, you must initialize the EVS disks on each instance, which takes a while.

This section describes how to configure a script to enable automatic initialization of EVS disks, including disk partitioning and attachment of specified directories. The script can only be used to initialize one EVS disk.

This section uses CentOS 6.5 as an example. For how to configure automatic initialization of EVS disks on other OSs, see the relevant OS documentation.

Procedure

  1. Log in to the instance as user root.
  2. Run a command to switch to the directory where the script will be stored:

    cd /script directory

    For example:

    cd /home

  3. Run the following command to create the script:

    vi script name

    For example:

    vi fdisk_mount.sh

  4. Press i to enter editing mode.

    The following script is used as an example to show how to implement automatic initialization of one data disk:

    #!/bin/bash 
    bash_scripts_name=fdisk_mount.sh 
    ini_path=/home/fdisk.ini 
    disk= 
    size= 
    mount= 
    partition= 
     
    function get_disk_from_ini() 
    { 
    disk=`cat $ini_path|grep disk| awk -F '=' '{print $2}'` 
    if [ $disk = "" ] 
    then 
        echo "disk is null in file,exit" 
        exit 
    fi 
    result=`fdisk -l $disk | grep $disk` 
    if [ $result = 1 ] 
    then 
        echo "disk path is not exist in linux,exit" 
        exit 
    fi 
     
    } 
     
    function get_size() 
    { 
    size=`cat $ini_path| grep size|awk -F '=' '{print $2}'` 
    if [ $size = "" ] 
    then 
        echo "size is null,exit" 
        exit 
    fi 
    } 
     
    function make_fs_mount() 
    { 
    mkfs.ext4 -T largefile $partition 
    if [ $? -ne 0 ] 
    then 
        echo "mkfs disk failed,exit" 
        exit 
    fi  
     
    dir=`cat $ini_path|grep mount |awk -F '=' '{print $2}'` 
    if [ $dir = "" ] 
    then 
        echo "mount dir is null in file,exit" 
        exit 
    fi 
     
    if [ ! -d $dir ] 
    then 
        mkdir -p $dir 
    fi 
     
    mount $partition $dir 
    if [ $? -ne 0 ] 
    then 
        echo "mount disk failed,exit" 
        exit 
    fi  
     
    echo "$partition $dir ext3 defaults 0 0" >> /etc/fstab 
    } 
     
    function remove_rc() 
    { 
    cat /etc/rc.local | grep $bash_scripts_name 
    if [ $? ne 0 ] 
    then 
        sed -i '/'$bash_scripts_name'/d' /etc/rc.local 
    fi 
    } 
     
    ################## start ####################### 
    ##1. Check whether the configuration file exists.
    if [ ! -f $ini_path ] 
    then 
        echo "ini file not exist,exit" 
        exit 
    fi 
     
    ##2. Obtain the device path for the specified disk from the configuration file.
    get_disk_from_ini 
     
    ##3. Obtain the size of the size partition from the configuration file.
    get_size 
     
    ##4. Partition the disk.
    fdisk $disk  <<EOF 
    n 
    p 
    1 
    1 
    $size        
    w 
    EOF 
    partition=`fdisk -l $disk 2>/dev/null| grep "^/dev/[xsh].*d" | awk '{print $1}'` 
     
    ##5. Format the partition and attach the partition to the specified directory.
    make_fs_mount 
     
    ##6. Change startup items to prevent re-execution of the scripts.
    remove_rc 
     
    echo 'SUCESS'
  5. Press Esc, enter :wq, and press Enter to save the changes and exit.
  6. Run the following command to create the configuration file:

    vi fdisk.ini

  7. Press i to enter editing mode.

    The drive letter, size, and mount directory of the EVS disk are configured in the configuration file. You can change the settings based on the following displayed information.

    disk=/dev/xdev 
    size=+100G 
    mount=/opt/test
  8. Press Esc, enter :wq, and press Enter to save the changes and exit.
  9. Run the following command to open configuration file rc.local:

    vi /etc/rc.local

  10. Press i to add the following content to rc.local:

    /home/fdisk_mount.sh

    After rc.local is configured, the EVS disk initialization script will be automatically executed when the ECS starts.

  11. Press Esc, enter :wq, and press Enter to save the changes and exit.
  12. Create a private image using an ECS.
  13. Create an AS configuration.

    When you specify the AS configuration information, select the private image created in the preceding step and select an EVS disk.

  14. Create an AS group.

    When you configure the AS group, select the AS configuration created in the preceding step.

    After the AS group is created, EVS disks of new instances added to this AS group in scaling actions will be automatically initialized.

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback