2016-09-21 25 views
0

我正在嘗試配置一些需要多個EBS驅動器的EC2實例。我試圖通過BlockDeviceMappings定義根卷和4個其他卷。AWS :: EC2 :: Instance拒絕引導。以root身份安裝錯誤的驅動器?

問題: 據我所知,下面的代碼符合我在網上看到的任何示例。但是當Windows啓動時,它會立即死亡。看看EC2控制檯(screenshot),我可以看到該實例有7個EBS卷(而不是5個),並且/ dev/xda設置爲root而不是/ dev/sda1。

"Mappings" : { 
    "AWSRegionToAMI" : { 
     "us-east-1"  : { "Windows2012R2" : "ami-5d1b984a" }, 
     "us-west-1"  : { "Windows2012R2" : "ami-07713767" }, 
     "us-west-2"  : { "Windows2012R2" : "ami-241bd844" } 
    }, 
    "VolumeSize" : { 
     "DataDrive"  : { "Size" : "50" }, 
     "LogDrive"  : { "Size" : "50" }, 
     "TempDrive"  : { "Size" : "400" }, 
     "BackupDrive" : { "Size" : "100" } 
    }, 
    "stackmap" : { 
     "sqlha" : { 
     "Name": "MS SQL Server 2014 Always On", 
     "chefjson" : "https://s3.amazonaws.com/[redacted]", 
     "os" : "win", 
     "bootstrapurl" : "https://s3.amazonaws.com/[redacted]" 
     } 
    } 
    }, 

"WSFCNode1": { 
    "Type": "AWS::EC2::Instance", 
    "Properties": { 
    "ImageId" : { "Fn::FindInMap" : [ "AWSRegionToAMI", { "Ref" : "AWS::Region" }, "Windows2012R2" ] }, 
    "InstanceType": { "Ref": "InstanceType" }, 
    "EbsOptimized": "true", 
    "NetworkInterfaces": [ 
     { 
     "DeleteOnTermination": "true", 
     "DeviceIndex": 0, 
     "SubnetId": { "Ref": "PrivateSubnet1ID" }, 
     "SecondaryPrivateIpAddressCount": 2, 
     "GroupSet": [ 
      { "Ref": "WSFCSecurityGroup" }, 
      { "Ref": "WSFCClientSecurityGroup" } 
     ] 
     } 
    ], 
    "BlockDeviceMappings": [ 
     { 
     "DeviceName": "/dev/sda1", 
     "Ebs" : {"VolumeSize": "60"} 
     }, 
     { 
     "DeviceName": "/dev/xvdb", 
     "Ebs" : {"VolumeSize": { "Fn::FindInMap" : [ "VolumeSize", "DataDrive", "Size" ]} } 
     }, 
     { 
     "DeviceName": "/dev/xvdc", 
     "Ebs" : {"VolumeSize": { "Fn::FindInMap" : [ "VolumeSize", "LogDrive", "Size" ]} } 
     }, 
     { 
     "DeviceName": "/dev/xvdd", 
     "Ebs" : {"VolumeSize": { "Fn::FindInMap" : [ "VolumeSize", "TempDrive", "Size" ]} } 
     }, 
     { 
     "DeviceName": "/dev/xvde", 
     "Ebs" : {"VolumeSize": { "Fn::FindInMap" : [ "VolumeSize", "BackupDrive", "Size" ]} } 
     } 
    ], 
    "KeyName": { "Ref": "KeyPairName" }, 
    "UserData"  : { "Fn::Base64" : { "Fn::Join" : ["", [ 
     "<powershell>\n", 

     "# Disable UAC and allow scripts to run\n", 
     "New-ItemProperty -Path HKLM:Software\\Microsoft\\Windows\\CurrentVersion\\policies\\system -Name EnableLUA -PropertyType DWord -Value 0 -Force\n", 
     "Set-ExecutionPolicy Unrestricted -force\n", 
     "c:\\windows\\System32\\WindowsPowershell\\v1.0\\powershell.exe -noninteractive -noprofile Set-ExecutionPolicy unrestricted -force\n", 
     "c:\\windows\\syswow64\\windowspowershell\\v1.0\\powershell.exe -noninteractive -noprofile Set-ExecutionPolicy unrestricted -force\n", 

     "#Change TimeZone\n", 
     "tzutil /s ", {"Ref" : "Timezone"}, "\n", 

     "#Run Bootstrap PS1\n", 
     "$newname = '", { "Fn::Join" : ["", [{"Ref" : "Environment"}, {"Ref" : "Location"}, {"Ref" : "Stack"}, {"Ref" : "Role"} ]]},"'\n", 
     "$region = '", {"Ref" : "VPCRegion"}, "'\n", 
     "$role = '", {"Ref" : "Role"}, "'\n", 
     "$chef_rb = '", { "Fn::FindInMap" : [ "stackmap", { "Ref" : "Role" }, "chefjson"]}, "'\n", 
     "mkdir 'c:\\temp' -force\n", 
     "(new-object System.Net.WebClient).DownloadFile('https://s3.amazonaws.com/[redacted]', 'c:\\temp\\bootstrap.ps1')\n", 
     "powershell c:\\temp\\bootstrap.ps1 -newname $newname -region $region -role $role -chef_rb $chef_rb -logfile c:\\temp\\bootstrap.log -verbose true\n", 

     "#Reboot if needed\n", 
     "Start-Sleep -s 10\n", 
     "Restart-Computer\n", 
     "mkdir 'c:\\temp\\cf_reboot_cmd_ran' -force\n", 
     "shutdown -r\n", 
     "mkdir 'c:\\temp\\cf_shut_cmd_ran' -force\n", 
     "Start-Sleep -s 10\n", 
     "mkdir 'c:\\temp\\cf_ran_again' -force\n", 

     "</powershell>" 
     ] ] } 
    }, 
    "Tags": [ 
     { "Key": "Name", "Value": "SQL Node 1" } 
    ] 
    } 
}, 

令人困惑的是,甚至當我刪除所有額外的驅動器,只是做一個磁盤

"BlockDeviceMappings": [ 
     { 
     "DeviceName": "/dev/sda1", 
     "Ebs" : {"VolumeSize": "60"} 
     } 
    ], 

塊設備映射......我還是結了三卷,和一個錯誤(/dev/xda)作爲根分配。 Screenshot

這是Windows的東西嗎?我的塊設備映射需要看起來像root一樣正確掛載(在本例中爲C:)?

回答

0

沒關係。根本問題出現在我選擇的AMI中。一旦我選擇了合適的Windows AMI,一切都運行良好。

對於任何其他人遇到此問題,仔細檢查您的AMI選擇。