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
시스템 생성 대체 텍스트: onestx@Azure =$ az Vill image list-offers eastus -0 MicrosoftWindowsServer -0 t SV i ndows-HLlB WindowsServerSemiAnnual onestx@Azure =$ ——QUery [] . n
 
시스템 생성 대체 텍스트: onestx@Azure =$ az Vill image ist-offers eastus Llbuntu15. 口4뎗aooy, Llbuntul 口쎰體0야,00d(巳r LlbuntuServer Llbuntu_Core onestx@Azure =$ az Vill i mage I i St 12.口413-니S 12.口414-니S 12.口415-니S 14.口4.口-니S westeurooe -0 -0 ——QUery [] . name -0 t SV 하 LlbuntuServer ¯QUer [] . name -0 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
 
시스템 생성 대체 텍스트: Vm i mage I i St ¯SkUS ——QUery [] . name -0 tSV 2口口巳-R2-SPI 2口口巳-R2-SPI -smal 회( 2口口巳-R2-SP 1 -zhcn 2012-Datacenter 2012-Datacenter-smal Idi 회( 201 2-Datacenter-zhcn 201 2-R2-Datacenter 201 2-R2-Datacenter-smal Idi 회( 201 2-R2-Datacenter-zhcn 2016-Datacenter 2016-Datacenter 201 a-Datacenter-Server-Core-smal Idi 회( 2016-Datacenter 2016-Datacenter-with 201 a-Dat acenter-w i th-RDSH 2016-Datacenter 201 g-Datacenter 201 g-Datacenter 201 g-Datacenter 201 g-Datacenter 201 g-Datacenter 201 g-Datacenter 201 g-Datacenter-with 201 g-Datacenter eaStUS -0 MicrosoftWindowsServer WindowsServ ¯zhcn —Core —Core —Core —Core ¯zhcn Idisk -smalldisk -with-Containers -with-Containers-smal Idisk Idisk 201 g-Datacenter-with-Containers-smal Idi 회( onestx@Azure =$
 
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)
시스템 생성 대체 텍스트: onestx@Azure =$ ioaddress=$(az Vill show —name support-web-vmDl fi --show-detai Is fi --auery [oubliclos] --0 tsv) onestx@Azure =$ $ i oaddress bash: 52.234. 133. 76: command not found onestx@Azure =$
 
SSH 연결을 통해 VM에서 lsblk 명령
ssh azureuser@$ipaddress lsblk
조회됨
시스템 생성 대체 텍스트: 卜』쇡ME 버쇡」:베卜』 sda *dal 들da14 巳114 *da15 巳115 sdb 巳.1듬 *dbl 巳117 sdc 巳:턴2 srD 11 SIZE RO TYPE MOLINTPOINT 306 Ddisk Dart / 2딤l딤6 4M oart Dart /boot/efi 106M 146 Ddisk Dart /mnt 146 646 Ddisk 62巳K 「0m
 
az vm extension set 명령을 실행하여 VM에서 미리 만들어진 Bash 스크립트를 실행합니다.
(어딘가에 올려진 스크립트)
az vm extension set \
  --vm-name support-web-vm01 \
  --name customScript \
  --publisher Microsoft.Azure.Extensions \
  --protected-settings '{"commandToExecute": "./add-data-disk.sh"}'
 
어딘가에 올려진 스크립트는 아래의 내용
·         /dev/sdc 드라이브를 분할합니다.
·         드라이브에 ext4 파일 시스템을 만듭니다.
·         /uploads 디렉터리를 만들어 탑재 지점으로 사용합니다.
·         디스크를 탑재 지점에 연결합니다.
·         /etc/fstab를 업데이트하면 시스템이 다시 부팅된 후에 드라이브가 자동으로 탑재됩니다.
 
결과, sdc 밑에 sdc1 만들어짐,. Upload 폴더까지
시스템 생성 대체 텍스트: onestx@Azure =$ 卜』쇡ME 버쇡」:베卜』 巳114 巳115 巳.1듬 巳117 巳:턴2 巳:턴3 sda *dal 들da14 *da15 sdb *dbl sdc Lsdcl srD 11 ssh azureuser@$ioaddress Isblk SIZE RO TYPE MOLINTPOINT 306 Ddisk Dart / 2딤l딤6 4M oart Dart /boot/efi 106M 146 Ddisk Dart /mnt 146 646 Ddisk Dart /uoloads 646 62巳K 「0m
 
 
 
 
디스크 크기 조정 시 디스크 ID 또는 이름이 필요함
조회 명령
az disk list \
  --query '[*].{Name:name,Gb:diskSizeGb,Tier:accountType}' \
  --output table
 
시스템 생성 대체 텍스트: onestx@Azure =$ az disk I ist fi --auery I [+] . {칝짒m巳:n짒m巳, 6우dis죄2巳Gb, Tier:accountTyoe}' --outout table 칝짒m巳 suooort -web-vmDl -0s0 i sk_ 1 _aDa3c4 f6a2f 444C듬巳f 1 24巳3巳b7듬Sca듬1 uoloadDataDiskl
 
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 레벨에서는 크기를 증가시켰지면,
아직까지, 운영체제 단에서는 모르는 일이다.
어딘가에 올려진 스크립트를 이용해서 또 해줘야됨.
(윈도우 서버는 원격접속해서 해줘야겠군)
 
시작이 오래걸리네
 
시스템 생성 대체 텍스트: onestx@Azure i oaddress= otsv) onestx@Azure =$ $ i oaddress onestx@Azure (az Vm Show —name ¯QUery [oubliclos] bash: 52.224.기巳111구 command not found
 
아직 64GB
시스템 생성 대체 텍스트: onestx@Azure =$ $ i oaddress bash: 52.224.기巳111구 command not found onestx@Azure =$ ssh azureuser@$ioaddress Isblk The authenticity Of host 15212241기巳1113 (52.224.기巳1113)l can't be established. ECDSA key fingerprint is SHA256:0bHi6GZyD143NCgxZjQKQ2WzsMOMizDbEuorsgE4JvM. 격r巳 you Slure you want to continue connecting (yes/no)? YES 巳114 巳115 巳.1듬 巳117 巳:턴2 巳:턴3 Warning: Permanently added 15212241기巳11131 (ECDSA) to the list Of known hosts. 卜』쇡ME 버쇡」:베卜』 sda *dal 들da14 *da15 sdb *dbl sdc Lsdcl 306 2딤l딤6 4M 106M 146 146 646 646 SIZE RO TYPE MOLINTPOINT Ddisk oart oart oart Ddisk oart Ddisk oart /boot/efi /mnt /uoloads
 
 
az vm extension set \
  --vm-name support-web-vm01 \
  --name customScript \
  --publisher Microsoft.Azure.Extensions \
  --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에서 작성




+ Recent posts