이 튜토리얼에서는 마이그레이션 센터 검색 클라이언트 CLI 게스트 검색을 사용하여 일괄 VMware 가상 머신(VM) 인스턴스에서 데이터를 검색하고 수집하는 프로세스를 안내합니다. 대규모 VM 배치는 모니터링하고 문제를 해결하기 어려울 수 있습니다. 따라서 1,000개 미만의 소규모 그룹으로 일괄 처리하는 것이 좋습니다.
목표
이 튜토리얼에서는 다음과 같은 방법을 알아봅니다.
mcdc CLI 다운로드
VMWare 인벤토리 검색 수행
검색된 모든 VM이 포함된 CSV 파일 생성
CSV 파일을 VM의 하위 집합이 포함된 여러 CSV 파일로 분할
CSV 파일의 모든 VM에서 게스트 검색 수행
오프라인 평가 보고서 생성
비용
이 튜토리얼에서는 온프레미스 리소스를 사용하므로 Google Cloud비용이 발생하지 않습니다.
시작하기 전에
Linux 머신을 준비하여 mcdc CLI를 설치하고 실행합니다. Linux 머신의 최소 요구사항은 다음과 같습니다.
CSV 파일에서 VM 게스트 검색을 실행하려면 Migrate to Containers GitHub 저장소에서 collection 스크립트를 사용합니다.
이전 단계에서 생성된 CSV 파일마다 이 단계를 반복합니다.
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)
이 스크립트는 discover vsphere guest 명령어를 사용하여 VM에 게스트 수집 스크립트를 업로드하고 실행합니다.
이 스크립트를 백그라운드에서 실행하고 출력을 로그 파일로 전달하는 것이 가장 좋습니다. 이렇게 하려면 스크립트에 입력으로 전달되는 텍스트 파일을 만들어야 합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-03-26(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)."]]