Raccolta collettiva dei dati e rilevamento degli ospiti
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questo tutorial ti guida nella procedura di rilevamento e raccolta dei dati
su un batch di istanze di macchine virtuali (VM) VMware utilizzando
l'individuazione guest della CLI del client predittivo di Migration Center. Grandi batch di VM potrebbero essere difficili
da monitorare e risolvere i problemi. Ti consigliamo di raggrupparli in gruppi più piccoli di meno di 1000.
Obiettivi
In questo tutorial imparerai a:
Scarica la CLI mcdc.
Esegui un rilevamento dell'inventario VMware.
Genera un file CSV con tutte le VM rilevate.
Dividi il file CSV in più file CSV contenenti un sottoinsieme delle VM.
Esegui il rilevamento degli ospiti su tutte le VM in un file CSV.
Generare un report di valutazione offline.
Costi
Questo tutorial utilizza risorse on-premise e non comporta costi Google Cloud.
Prima di iniziare
Prepara una macchina Linux per installare ed eseguire
l'interfaccia a riga di comando mcdc. La macchina Linux deve soddisfare i seguenti requisiti minimi:
glibc versione 2.25 o successive
4 GB di RAM e 10 GB di spazio su disco
Connettività di rete a vCenter e agli host ESX
Assicurati di disporre di un utente vSphere con le autorizzazioni necessarie:
Privilegi di lettura per le VM
Privilegi di lettura per tutti gli host ESX
Modifiche all'attività degli ospiti
Esecuzione del programma di operazioni guest
Query sulle operazioni degli ospiti
Scarica l'interfaccia a riga di comando mcdc
Connettiti alla macchina Linux:
sshMACHINE_IP
Sostituisci MACHINE_IP con l'indirizzo IP del tuo computer Linux.
Scarica l'ultima versione della CLI mcdc e rendila eseguibile:
CSV_FILES_PREFIX: il prefisso per i file CSV generati.
LINES_PER_FILE: il numero di righe per ogni file CSV generato. Il valore predefinito è 10.
Lo script genera vari file CSV.
Visualizza l'elenco dei file CSV generati:
ls-lrtCSV_FILES_PREFIX*
Esegui il rilevamento guest su tutte le VM in un file CSV
Per eseguire l'individuazione guest per le VM in un file CSV, utilizza lo script
collection dal repository GitHub di Migrate to Containers.
Ripeti questo passaggio per ogni file CSV generato nel passaggio precedente.
url_regex='^https?://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]\.[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]$'read-r-p"CSV file name: "CSV_FILE
if[[!-r"$CSV_FILE"]];thenecho"The file $CSV_FILE does not exist or can not be accessed."exit1firead-r-p"vSphere URL: "VSPHERE_URL
if![[$VSPHERE_URL=~$url_regex]];thenecho"vSphere URL $VSPHERE_URL IS not a valid URL"exit1firead-r-p"vSphere username: "VSPHERE_USER
read-r-s-p"vSphere password: "VSPHERE_PASSWORD
echo""read-r-p"Default username: "DEFAULT_USER
read-r-s-p"Default password: "DEFAULT_PASSWORD
echo""# CSV fields#NAME;PLATFORM VM ID;OS;IP;USERNAME;PASSWORDwhileIFS=";"read-rvm_namevm_idosipusernamepassword
doif[-z"$username"]thenusername=$DEFAULT_USERfiif[-z"$password"]thenpassword=$DEFAULT_PASSWORDfiif[!-z"$vm_id"]then# Note that the below only works for VMWare VMs# vm_id after the last slash if prefixed by vSphere IPmod_vm_id=$(echo"$vm_id"|sed's/.*\///')mcdcdiscovervsphereguest--url$VSPHERE_URL-u$VSPHERE_USER-p$VSPHERE_PASSWORD--vm-user$username--vm-password$password$mod_vm_idelseecho"Skipping VM: $vm_name because it has no VM ID"fidone < <(tail-n+1$CSV_FILE)
Lo script utilizza il comando discover vsphere guest per caricare ed eseguire lo
script di raccolta guest sulla VM.
È consigliabile eseguire questo script in background e indirizzare l'output a un file di log. Per farlo, devi creare un file di testo che viene passato come input allo script.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[],[],null,["# Batching guest discovery and data collection\n\n*** ** * ** ***\n\nThis tutorial walks you through the process of discovering and collecting data\non a batch of VMware virtual machine (VM) instances using the\nMigration Center discovery client CLI guest discovery. Large batches of VMs may be difficult\nto monitor and troubleshoot. We recommend batching into smaller groups of less\nthan 1,000.\n\nObjectives\n----------\n\nIn this tutorial, you will learn how to:\n\n- Download the `mcdc` CLI.\n- Run a VMWare inventory discovery.\n- Generate a CSV file with all the discovered VMs.\n- Split the CSV file into multiple CSV files containing a subset of the VMs.\n- Run guest discovery on all the VMs in a CSV file.\n- Generate an offline assessment report.\n\nCosts\n-----\n\nThis tutorial uses on-premises resources and incurs no Google Cloud\ncosts.\n\nBefore you begin\n----------------\n\n1. Prepare a Linux machine to install and run the\n `mcdc` CLI. The Linux machine must have the\n following minimum requirements:\n\n - `glibc` version 2.25 or later\n - 4 GB RAM and 10 GB disk space\n - Network connectivity to vCenter and ESX hosts\n2. Ensure that you have a vSphere user with the necessary permissions:\n\n - Read privileges to VMs\n - Read privileges to all the ESX hosts\n - Guest operation modifications\n - Guest operation program execution\n- Guest operation queries \n\nDownload the `mcdc` CLI\n-----------------------\n\n1. Connect to the Linux machine: \n\n ```bash\n ssh MACHINE_IP\n ```\n\n Replace \u003cvar translate=\"no\"\u003eMACHINE_IP\u003c/var\u003e with the IP address of your Linux machine.\n2. Download the latest version of the `mcdc` CLI and make it executable: \n\n ```bash\n curl -O \"https://mcdc-release.storage.googleapis.com/$(curl -s https://mcdc-release.storage.googleapis.com/latest)/mcdc\"\n chmod +x mcdc\n ```\n3. Add the `mcdc` CLI to your shell path: \n\n ```bash\n PATH=$PATH:`pwd`\n ```\n\nPerform a VMware inventory discovery\n------------------------------------\n\n- Run the inventory discovery:\n\n ./mcdc discover vsphere -u \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e --url https://\u003cvar translate=\"no\"\u003eVSPHERE_URL\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e: your vCenter username\n - \u003cvar translate=\"no\"\u003eVSPHERE_URL\u003c/var\u003e: the URL for your vCenter Server instance or the vSphere Client\n\n The output of the `discover` command looks like the following: \n\n ```\n [+] Found 528 VMs\n Collecting data...\n 528 / 528 [---------------------------------------------------] 100.00% 5 p/s\n [✓] Collection completed.\n ```\n\nGenerate a CSV file with all the discovered VMs\n-----------------------------------------------\n\nTo generate a CSV file, use the `export` script from the Migrate to Containers\nrepository on GitHub. \n\n\n vms=$(mcdc report --format csv | tail -n +2 | awk -F ',' '{; print $2\";\"$3\";\"$4\";;;\"}')\n printf \"%s\\n\" \"Name;Platform VM ID;OS Family;IP;USERNAME;PASSWORD\"\n printf \"%s\\n\" \"$vms\"\n\nThe script uses the `report` command to generate a CSV file containing all the\nVMs that were discovered in the previous step.\n\n1. Download the script:\n\n curl -O https://raw.githubusercontent.com/GoogleCloudPlatform/migrate-to-containers/main/scripts/mcdc/mcdc_discovery_export_guest_tools.sh\n chmod +x mcdc_discovery_export_guest_tools.sh\n\n2. Run the script and save the output to a file:\n\n ./mcdc_discovery_export_guest_tools.sh \u003e \u003cvar translate=\"no\"\u003eVMS_CSV_FILE\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eVMS_CSV_FILE\u003c/var\u003e with the name you want for the CSV file.\n\nSplit the CSV file into multiple CSV files with a subset of the VMs\n-------------------------------------------------------------------\n\nTo split the large CSV file into smaller CSV files, use the `splitter` script\nfrom the Migrate to Containers repository on GitHub. \n\n tail -n +2 $1 | split -d -l $num_of_lines - $2\n for file in $2*\n do\n head -n 1 $1 \u003e tmp_file\n cat \"$file\" \u003e\u003e tmp_file\n mv -f tmp_file \"$file\"\n done\n\n1. Download the script:\n\n curl -O https://raw.githubusercontent.com/GoogleCloudPlatform/migrate-to-containers/main/scripts/mcdc/csv_splitter.sh\n chmod +x csv_splitter.sh\n\n2. Run the script:\n\n ./csv_splitter.sh \u003cvar translate=\"no\"\u003eVMS_CSV_FILE\u003c/var\u003e \u003cvar translate=\"no\"\u003eCSV_FILES_PREFIX\u003c/var\u003e \u003cvar translate=\"no\"\u003eLINES_PER_FILE\u003c/var\u003e \u003cvar translate=\"no\"\u003eVMS_CSV_FILE\u003c/var\u003e \u003cvar translate=\"no\"\u003eCSV_FILES_PREFIX\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eVMS_CSV_FILE\u003c/var\u003e: the input CSV file to split.\n - \u003cvar translate=\"no\"\u003eCSV_FILES_PREFIX\u003c/var\u003e: the prefix for the generated CSV files.\n - \u003cvar translate=\"no\"\u003eLINES_PER_FILE\u003c/var\u003e: the number of lines per generated CSV file. The default value is `10`.\n\n The script generates various CSV files.\n3. View the list of generated CSV files:\n\n ls -lrt \u003cvar translate=\"no\"\u003eCSV_FILES_PREFIX\u003c/var\u003e*\n\nRun guest discovery on all the VMs in a CSV files\n-------------------------------------------------\n\nTo run the guest discovery for the VMs in a CSV file, use the\n`collection` script from the Migrate to Containers GitHub repository.\n\nRepeat this step for each CSV file generated in the previous step. \n\n\n url_regex='^https?://[-A-Za-z0-9\\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\\+&@#/%=~_|]\\.[-A-Za-z0-9\\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\\+&@#/%=~_|]$'\n\n read -r -p \"CSV file name: \" CSV_FILE\n if [[ ! -r \"$CSV_FILE\" ]]; then\n echo \"The file $CSV_FILE does not exist or can not be accessed.\"\n exit 1\n fi\n\n read -r -p \"vSphere URL: \" VSPHERE_URL\n if ! [[ $VSPHERE_URL =~ $url_regex ]]; then\n echo \"vSphere URL $VSPHERE_URL IS not a valid URL\"\n exit 1\n fi\n read -r -p \"vSphere username: \" VSPHERE_USER\n read -r -s -p \"vSphere password: \" VSPHERE_PASSWORD\n echo \"\"\n read -r -p \"Default username: \" DEFAULT_USER\n read -r -s -p \"Default password: \" DEFAULT_PASSWORD\n\n echo \"\"\n\n # CSV fields\n #NAME;PLATFORM VM ID;OS;IP;USERNAME;PASSWORD\n while IFS=\";\" read -r vm_name vm_id os ip username password\n do\n if [ -z \"$username\" ]\n then\n username=$DEFAULT_USER\n fi\n if [ -z \"$password\" ]\n then\n password=$DEFAULT_PASSWORD\n fi\n\n if [ ! -z \"$vm_id\" ]\n then\n # Note that the below only works for VMWare VMs\n # vm_id after the last slash if prefixed by vSphere IP\n mod_vm_id=$(echo \"$vm_id\" | sed 's/.*\\///')\n mcdc discover vsphere guest --url $VSPHERE_URL -u $VSPHERE_USER -p $VSPHERE_PASSWORD --vm-user $username --vm-password $password $mod_vm_id\n else\n echo \"Skipping VM: $vm_name because it has no VM ID\"\n fi\n done \u003c \u003c(tail -n +1 $CSV_FILE)\n\nThe script uses the `discover vsphere guest` command to upload and execute the\nguest collection script on the VM.\n\nIt's best to execute this script in the background and direct the output to a\nlog file. To do so, you need to create a text file which is passed as input to\nthe script.\n\n1. Create the text file:\n\n cat \u003c\u003cEOF \u003e\u003e \u003cvar translate=\"no\"\u003eINPUT_FILE\u003c/var\u003e\n \u003cvar translate=\"no\"\u003eCSV_FILES_PREFIX\u003c/var\u003e\u003cvar translate=\"no\"\u003eCSV_FILE_SUFFIX\u003c/var\u003e\n \u003cvar translate=\"no\"\u003eVSPHERE_URL\u003c/var\u003e\n \u003cvar translate=\"no\"\u003eVSPHERE_USER\u003c/var\u003e\n \u003cvar translate=\"no\"\u003eVSPHERE_PASSWORD\u003c/var\u003e\n \u003cvar translate=\"no\"\u003eVM_USER\u003c/var\u003e\n \u003cvar translate=\"no\"\u003eVM_PASSWORD\u003c/var\u003e\n EOF\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eINPUT_FILE\u003c/var\u003e: input filename\n - \u003cvar translate=\"no\"\u003eCSV_FILES_PREFIX\u003c/var\u003e: CSV filename prefix\n - \u003cvar translate=\"no\"\u003eCSV_FILE_SUFFIX\u003c/var\u003e: CSV filename suffix\n - \u003cvar translate=\"no\"\u003eVSPHERE_URL\u003c/var\u003e: the URL for your vCenter Server instance or the vSphere Client\n - \u003cvar translate=\"no\"\u003eVSPHERE_USER\u003c/var\u003e: vCenter username\n - \u003cvar translate=\"no\"\u003eVSPHERE_PASSWORD\u003c/var\u003e: vCenter password\n - \u003cvar translate=\"no\"\u003eVM_USER\u003c/var\u003e: VM username\n - \u003cvar translate=\"no\"\u003eVM_PASSWORD\u003c/var\u003e: VM password\n2. Run the guest collection script:\n\n nohup ./mcdc_collect_vms_guest_tools.sh \u003c\u003cvar translate=\"no\"\u003eINPUT_FILE\u003c/var\u003e \u003e /tmp/mcdc.out 2\u003e&1 &\n\n3. Repeat steps 1 and 2 for each CSV file generated in the previous step.\n\nGenerate an offline assessment report\n-------------------------------------\n\n- After all the data is collected, you can produce a detailed HTML report:\n\n ```bash\n ./mcdc report --format html --full \u003e REPORT_NAME.html\n \n ```\n\nWhat's next\n-----------\n\n- Learn how to [collect guest data from EC2 instances](/migrate/containers/docs/mcdc-aws-collection-tutorial).\n- Learn more about the [`mcdc` CLI](/migration-center/docs/discovery-client-cli-overview).\n- Look [through scripts samples](https://github.com/GoogleCloudPlatform/migrate-to-containers/tree/main/scripts/mcdc)."]]