问题描述
我正在尝试使用CLI创建Linux VM而无需任何手动步骤。 VM将运行Mongo,我想为其分配3个附加数据磁盘,这些磁盘安装在/ data / log和/ journal上
我使用的CLI命令看起来有点像:
az vm create \
--name mongo-node-1 \
--resource-group myresourcegroup \
- admin-username myrootuser \
--custom-data" $(cat mongo-node.yml)" \
--data-disks-sizes-gb 50 10 10 \
--image规范:UbuntuServer:18.04-LTS:最新
我期望按照我指定的顺序创建数据磁盘:
/ dev / sdc:50 GiB
/ dev / sdd:10 GiB
/ dev / sde:10 GiB
但相反磁盘以另一种顺序创建:
/ dev / sdc:10 GiB
/ dev / sdd:50 GiB
/ dev / sde: 10 GiB
这是非常不切实际的,因为我想创建文件系统&将它挂载到我在启动VM时提供给Azure CLI的CloudInit userdata文件中:
#cloud-config
repo_upgrade:all
repo_upgrade_exclude:[]
runcmd:
- echo"LC_ALL = C" | tee -a / etc / environment
- echo'type = 83'| sfdisk / dev / sdc
- echo'type = 83'| sfdisk / dev / sdd
- echo'type = 83'| sfdisk / dev / sde
- mkfs -t ext4 / dev / sdc1
- mkfs -t ext4 / dev / sdd1
- mkfs -t ext4 / dev / sde1
- mount / dev / sdc1 / data
- mount / dev / sdd1 / journal
- mount / dev / sde1 / log
- apt-key adv --keyserver hkp://keyserver.ubuntu。 com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
- apt-get update
- apt-get install -y mongodb-org
I'm trying to create a Linux VM using the CLI without any manual steps. The VM will run Mongo for which I want to allocate 3 additional data disks that are mounted on /data /log and /journal
The CLI command I use looks a bit like:
az vm create \ --name mongo-node-1 \ --resource-group myresourcegroup \ --admin-username myrootuser \ --custom-data "$(cat mongo-node.yml)" \ --data-disk-sizes-gb 50 10 10 \ --image Canonical:UbuntuServer:18.04-LTS:latest
I'm expecting the creation of the data disks to be completed in the order I specified:
/dev/sdc: 50 GiB /dev/sdd: 10 GiB /dev/sde: 10 GiB
But instead the disks are created in another order:
/dev/sdc: 10 GiB /dev/sdd: 50 GiB /dev/sde: 10 GiB
Which is very impractical because I want to create the filesystem & mount it in the CloudInit userdata file I'm supplying to the Azure CLI when launching the VM:
#cloud-config repo_upgrade: all repo_upgrade_exclude: [] runcmd: - echo "LC_ALL=C" | tee -a /etc/environment - echo 'type=83' | sfdisk /dev/sdc - echo 'type=83' | sfdisk /dev/sdd - echo 'type=83' | sfdisk /dev/sde - mkfs -t ext4 /dev/sdc1 - mkfs -t ext4 /dev/sdd1 - mkfs -t ext4 /dev/sde1 - mount /dev/sdc1 /data - mount /dev/sdd1 /journal - mount /dev/sde1 /log - apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 - apt-get update - apt-get install -y mongodb-org
For this to work I need to be sure upfront which of the created devices is the 50GB disk, because I don't want to use a 10GB disk as the data storage: those are used for the journal and log files. And I don't see how I can do this with the Azure CLI...
这篇关于Azure CLI vm创建和创建数据磁盘的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!