VM생성, 디스크 생성, 변경 CLI test
2019년 3월 12일 화요일
오전 7:54
CLI 훈련중
리전설정?
az configure --defaults location=eastus
기본 RG설정
az configure --defaults group="a1fa8494-0550-45e2-afd2-86e20a0dbd7b"
VM생성 (이미지 종류값은 어디서 어떻게)
az vm create \
--name support-web-vm01 \
--image UbuntuLTS \
--size Standard_DS2_v2 \
--admin-username azureuser \
--generate-ssh-keys
이미지종류 관련
1. 게시자 목록
az vm image list-publishers -l eastus --query [].name -o tsv
2. 게시자 별 지원 이미지
az vm image list-offers -l eastus -p Canonical --query [].name -o tsv
az vm image list-offers -l eastus -p MicrosoftWindowsServer --query [].name -o tsv
3. All SKU
az vm image list-skus -l westeurope -p Canonical -f UbuntuServer --query [].name -o tsv
az vm image list-skus -l eastus -p MicrosoftWindowsServer -f WindowsServer --query [].name -o tsv
4. VM생성
az vm create -n MyVm -g MyResourceGroup --image UbuntuLTS
az vm create \
--name support-web-vm01 \
--image UbuntuLTS \
--size Standard_DS2_v2 \
--admin-username azureuser \
--generate-ssh-keys
디스크 추가 (용량 64GB)
az vm disk attach \
--vm-name support-web-vm01 \
--disk uploadDataDisk1 \
--size-gb 64 \
--sku Premium_LRS \
--new
서버아이피 주소 가져오기 az vm show 이용
ipaddress=$(az vm show \
--name support-web-vm01 \
--show-details \
--query [publicIps] \
--o tsv)
SSH 연결을 통해 VM에서 lsblk 명령
ssh azureuser@$ipaddress lsblk
조회됨
az vm extension set 명령을 실행하여 VM에서 미리 만들어진 Bash 스크립트를 실행합니다.
(어딘가에 올려진 스크립트)
az vm extension set \
--vm-name support-web-vm01 \
--name customScript \
--publisher Microsoft.Azure.Extensions \
--settings '{"fileUris":["https://raw.githubusercontent.com/MicrosoftDocs/mslearn-add-and-size-disks-in-azure-virtual-machines/master/add-data-disk.sh"]}' \
--protected-settings '{"commandToExecute": "./add-data-disk.sh"}'
어딘가에 올려진 스크립트는 아래의 내용
· /dev/sdc 드라이브를 분할합니다.
· 드라이브에 ext4 파일 시스템을 만듭니다.
· /uploads 디렉터리를 만들어 탑재 지점으로 사용합니다.
· 디스크를 탑재 지점에 연결합니다.
· /etc/fstab를 업데이트하면 시스템이 다시 부팅된 후에 드라이브가 자동으로 탑재됩니다.
결과, sdc 밑에 sdc1 만들어짐,. Upload 폴더까지
디스크 크기 조정 시 디스크 ID 또는 이름이 필요함
조회 명령
az disk list \
--query '[*].{Name:name,Gb:diskSizeGb,Tier:accountType}' \
--output table
VM할당을 취소, 안에 파일은 괜찮겠지?
az vm deallocate --name support-web-vm01
az disk update --name uploadDataDisk1 --size-gb 128
VM재시작은 꼭 필요
az vm start --name support-web-vm01
할당 취소 후 재시작하면 IP변경이 됨.
기존IP 52.234.133.76
Azure 레벨에서는 크기를 증가시켰지면,
아직까지, 운영체제 단에서는 모르는 일이다.
어딘가에 올려진 스크립트를 이용해서 또 해줘야됨.
(윈도우 서버는 원격접속해서 해줘야겠군)
시작이 오래걸리네
아직 64GB
az vm extension set \
--vm-name support-web-vm01 \
--name customScript \
--publisher Microsoft.Azure.Extensions \
--settings '{"fileUris":["https://raw.githubusercontent.com/MicrosoftDocs/mslearn-add-and-size-disks-in-azure-virtual-machines/master/resize-data-disk.sh"]}' \
--protected-settings '{"commandToExecute": "./resize-data-disk.sh"}'
스크립트 내용
# Unmount the disk /dev/sdc1.
sudo umount /dev/sdc1
# Resize partition 1 to be 128GB.
# Read from standard input provide the options we want.
sudo parted /dev/sdc <<EOF
resizepart
1
128GB
quit
EOF
# The partition tool automatically remounts the drive.
# Unmount it again so we can format it.
sudo umount /dev/sdc1
# Verify partition consistency.
sudo e2fsck -f -p /dev/sdc1
# Resize the filesystem.
sudo resize2fs /dev/sdc1
# Mount the drive (/dev/sdc1) back to the mount point (/uploads).
sudo mount /dev/sdc1 /uploads
표준HDD
|
관리디스크
표준SSD
|
프리미엄SSD
|
프리미엄스토리지 계정은 LRS만 지원한다함.
VHD 가상하드드라이브 파일은 페이지 BLOB에 저장됨. 기억.
Microsoft OneNote 2016에서 작성
'기술(Azure 만...) > [MS]Azure기본' 카테고리의 다른 글
Azure 보안 설계 기본 (0) | 2019.04.05 |
---|---|
Azure Firewall 서비스 (0) | 2019.03.29 |
Azure 스토리지 기본 ... 저장옵션 (0) | 2019.03.10 |
Azure 거버넌스3(리소스그룹,정책,태그) (0) | 2019.02.21 |
Azrue 거버넌스2 (관리그룹 개념) (0) | 2019.02.15 |