azure 虚拟机连不上_如何在Windows Azure上设置虚拟机(Linux或其他)的负载平衡Web场(命令行)

azure 虚拟机连不上

azure 虚拟机连不上

A buddy of mine was thinking to move some of his Linux-based website to Azure. If you're running a Web Site that this node.js, ASP, ASP.NET, or PHP, it's easiest to use Azure Web Sites. I showed how to do setup Azure Web Sites in minutes with Git in this post. They hide the underlying OS from you, are automatically updated, scale easily, and share disks.

我的一个伙伴正在考虑将他的一些基于Linux的网站迁移到Azure。 如果您正在运行一个使用此node.js,ASP,ASP.NET或PHP的网站,则最容易使用Azure网站。 在本文中,我展示了如何在几分钟内使用Git设置Azure网站。 它们向您隐藏了底层操作系统,可以自动更新,轻松扩展并共享磁盘。

However, he likes VMs and the control they give him, plus he can run whatever he wants, move things around and generally control his world.

但是,他喜欢虚拟机及其提供给他的控制,此外,他还可以运行自己想要的任何东西,移动事物并总体上控制他的世界。

I'll be using the open source (GitHub) cross platform CLI tools (command line interface) for Azure. If you have node package manager you can "npm install azure-cli --global" then import your subscription. You can also get the command line tools by downloading and installing from www.windowsazure.com.

我将使用Azure的开源( GitHub )跨平台CLI工具(命令行界面)。 如果您具有节点软件包管理器,则可以“ npm install azure-cli --global”,然后导入您的订阅。 您还可以通过从以下位置下载并安装来获取命令行工具www.windowsazure.com

设置Linux VM (Setting up a Linux VM)

We'll create a the initial VM using the Portal (I'll show you how to do it from the command line in a minute). This virtual machine will be for setting up a template VM image. I'm going to create an Ubuntu 13.04 server, then add Apache and PHP. Then I'll capture a generic image of my now-set-up machine and use it to create copies that I'll add to a farm. This image will show up later in "My Images" in the Azure Portal.

我们将使用门户网站创建一个初始VM(我将在一分钟内向您展示如何从命令行执行该操作)。 该虚拟机将用于设置模板VM映像。 我将创建一个Ubuntu 13.04服务器,然后添加Apache和PHP。 然后,我将捕获我现在设置的计算机的一般图像,并使用它来创建要添加到服务器场中的副本。 该图像稍后将显示在Azure门户的“我的图像”中。

NOTE: There's an amazing community-driven category of prepped and ready Virtual Machine images at the Open Tech VM Depot. It's like the Azure's best kept secret. I'll do a post on it later but it's really deep and broad and worth checking out.

注意:Open Tech VM Depot中,有一个由社区驱动的令人惊叹的类别,其中包括准备好的虚拟机映像。 这就像Azure最好保密的秘密。 稍后我将在其上发表文章,但它的深度和广度确实值得一读。

From within the Azure Portal I'll go New | Virtual Machine | and select Ubuntu Server 13.04.

在Azure门户中,我将进入“新建” | 虚拟机| 并选择Ubuntu Server 13.04。

Selecting Ubuntu from the Azure Gallery

The name doesn't matter, but I'll setup a user name and password (or use a SSH key):

名称无关紧要,但是我将设置用户名和密码(或使用SSH密钥):

Creating a VM

Note I'll create a stand-alone Virtual Machine:

注意我将创建一个独立的虚拟机:

Making a Stand-Alone VM

TIP: If I didn't want to use the Portal at all to make this VM, I could even find a VM image programmatically, then create a VM instance, all from the command line. Using "azure vm list" would get me the list of VMs to choose from. The Ubuntu one I wanted is "Ubuntu-13_04-amd64-server-20130501-en-us-30GB" (with a guid in the name as well) so I'd just "azure vm create MyDNSName ImageName [options]" and then proceed from there.

提示:如果我根本不想使用Portal来制作此VM,我什至可以以编程方式找到VM映像,然后从命令行创建VM实例。 使用“ azure vm list”可以获取要选择的VM列表。 我想要的Ubuntu是“ Ubuntu-13_04-amd64-server-20130501-en-us-30GB”(名称中也带有GUID),因此我只想“ azure vm create MyDNSName ImageName [options]”,然后从那里继续。

Once this Linux VM has started up, I'll SSH into it. You can see that Azure has mapped a random high number public port to the VM's internal SSH port 22.

一旦这个Linux VM启动,我将通过SSH进入它。 您可以看到Azure已将一个随机的大量公共端口映射到VM的内部SSH端口22。

My VM's IP Address

I SSH in. I'm gonna add Apache, PHP, restart apache, then add a test.php that will show PHP is working as well as output the current IP address so I can tell which machine served the request.

我使用SSH。我将添加Apache,PHP,重新启动apache,然后添加一个test.php,它将显示PHP正在工作以及输出当前IP地址,以便我可以确定是哪台机器满足了该请求。

sudo apt-get install apache2
sudo apt-get install libapache2-mod-php5 php5

I'll add a test.php

我将添加一个test.php

sudo nano /var/www/test.php

and put in

放进去

<?php echo gethostbyname(trim(`hostname`)); ?>
<?php phpinfo(); ?>

Then I'll exit SSH. VMs are locked down by default, so to test this I need to add an endpoint. I can do that via the Portal but I'd like to see what I can do from the Azure command line.

然后我将退出SSH。 虚拟机默认情况下处于锁定状态,因此要进行测试,我需要添加一个端点。 我可以通过门户网站执行此操作,但是我想从Azure命令行中查看可以执行的操作。

Run vm endpoint create to map external 80 to internal 80.

运行vm endpoint create将外部80映射到内部80。

azure vm endpoint create mylinuxtemplate 80 80

At this point I should be able to hit mylinuxtemplate.cloudapp.net:80/test.php and see it work.

在这一点上,我应该能够访问mylinuxtemplate.cloudapp.net:80/test.php并看到它的工作。

My VM's test.php page

Cool. So I've got my Linux VM template the way I want it. Now I want to "capture it" as an image so I can stamp out more of them. This "waagent" on Linux is like "sysprep" on Windows.

凉。 因此,我已经按照自己的方式获得了Linux VM模板。 现在,我想将其“捕获”为图像,以便可以删除更多图像。 在Linux上,此“ waagent”类似于Windows上的“ sysprep”。

From within a SSH session, run waagent -deprovision.

在SSH会话中,运行waagent -deprovision。

~$ sudo waagent -deprovision
scott@mylinuxtemplate:~$ sudo waagent -deprovision
WARNING! The waagent service will be stopped.
WARNING! All SSH host key pairs will be deleted.
WARNING! Nameserver configuration in /etc/resolvconf/resolv.conf.d/{tail,originial} will be deleted.
WARNING! Cached DHCP leases will be deleted.
WARNING! root password will be disabled. You will not be able to login as root.
Do you want to proceed (y/n)? y

WINDOWS PEOPLE: If you're a Windows person, you can setup your Windows VM just as you like it, then run %windir%\system32\sysprep.exe on it, capture an image of the VM and do everything described in this post as well!

WINDOWS人员:如果您是Windows用户,则可以根据需要设置Windows VM,然后在其上运行%windir%\ system32 \ sysprep.exe,捕获该VM的映像,并按照本文中的描述进行操作也一样!

I could shut it down and capture an image from the Portal, but again, it's command line fun today. Note that shutting down can take a little while.

我可以关闭它并从Portal捕获图像,但是再次,今天它在命令行上很有趣。 请注意,关闭可能需要一段时间。

azure vm shutdown mylinuxtemplate
azure vm capture mylinuxtemplate hanselmanlinuxwebfarmimage --delete

The capture command will DELETE the Virtual Machine. Remember that it was just a template. However, how I have a reusable image! I can see the images available to me, both user images and gallery images with "azure vm list."

capture命令将删除虚拟机。 请记住,这只是一个模板。 但是,我如何拥有可重用的图像! 我可以通过“ azure vm list”看到可用的图像,包括用户图像和图库图像。

NOTE: When you delete Virtual Machines, you're just deleting the "configuration" of the VM. You're not deleting the disk that was associated with it, as it's possible you might want to start that VM up again. If you're really trying to remove things, make sure you delete the instance of the VM and then delete the disk, too.

注意:删除虚拟机时,仅删除VM的“配置”。 您不会删除与其关联的磁盘,因为可能要重新启动该VM。 如果您确实要删除内容,请确保删除VM实例,然后再删除磁盘

从命令行创建Linux VM场 (Creating a Linux VM Farm from the command line)

Now I have an image sitting in my storage account that I can use to make "n" VMs from. I'll make one VM to start. I can watch it startup with "azure site list" after making it. When it's ready, I can make more! Make sure you use the --ssh switch or you will NOT be able to SSH into the machine!

现在,我在存储帐户中有一个映像,可以用来制作“ n”个虚拟机。 我将启动一个VM。 制作完成后,我可以用“ azure网站列表”观看它的启动。 准备就绪后,我可以做更多! 确保使用--ssh开关,否则将无法通过SSH进入计算机!

C:\> azure vm create hanselmanlinuxfarm hanselmanlinuxwebfarmimage scott MyPassword123 --location "West US" --ssh
info: Executing command vm create
+ Looking up image
+ Looking up cloud service
+ Creating cloud service
+ Creating VM
info: vm create command OK
C:\> azure vm list
info: Executing command vm list
+ Fetching VMs
data: DNS Name VM Name Status
data: ------------------------------- ------------------ ----------
data: hanselmanlinuxfarm.cloudapp.net hanselmanlinuxfarm CreatingVM
info: vm list command OK
C:\> azure vm list
info: Executing command vm list
+ Fetching VMs
data: DNS Name VM Name Status
data: ------------------------------- ------------------ ---------
data: hanselmanlinuxfarm.cloudapp.net hanselmanlinuxfarm ReadyRole
info: vm list command OK

WEIRD: Azure has a concept called a "Cloud Service" which is a lousy name, IMHO. For us, let's consider it a "container" for our VMs. It's a logical container that will hold and associate all our VMs (and other cloudy stuff) together. When you have one VM you have one cloud service associated with it, but you can't see it in the Portal but because it doesn't really provide value...yet. When you have TWO VMs in the same container, then you'll see that cloud service "container" appear in the Portal.

奇怪: Azure有一个称为“云服务”的概念,这是一个糟糕的名称,恕我直言。 对于我们来说,让我们将其视为虚拟机的“容器”。 这是一个逻辑容器,可以将我们所有的虚拟机(和其他多云的东西)保持在一起并关联在一起。 当您拥有一个VM时,您将拥有一个与之关联的云服务,但是您无法在Portal中看到它,但是因为它并没有真正提供价值...。 当在同一容器中有两个VM时,您会看到云服务“容器”出现在门户中。

I've made a hanselmanlinuxfarm VM now so there's a hanselmanlinuxfarm cloud service 'container.' Now, I'm going to make a few more VMs but I'll connect them to the first VM. There's two ways to do this. First, the --connect option from the command line. Note that you don't have control over the name of your VM this way, if you care. If you have hundreds, you likely don't.

我现在已经制作了hanselmanlinuxfarm虚拟机,因此有一个hanselmanlinuxfarm云服务“容器”。 现在,我将再制造几台VM,但将它们连接到第一个VM。 有两种方法可以做到这一点。 首先,从命令行使用--connect选项。 请注意,如果您愿意,您无法通过这种方式来控制VM的名称。 如果您有数百个,则可能没有。

The command will find the existing cloud service (again, 'container') then make a new VM. I'm going to run this command twice so I'll have three VMs total.

该命令将找到现有的云服务(再次是“容器”),然后创建一个新的VM。 我将两次运行此命令,因此我将总共拥有三个VM。

SO IMPORTANT: It's the --connect used on this second call that is the key. It makes the second (and then n+1) VM and adds it to the same cloud service "container." It seems the VMs associated with each other. The name of the next VM will be whatever-2, then -3, etc but they will also use the same external name, like hanselmanlinuxfarm.cloudapp.net.

重要提示:第二个调用中使用的--connect是关键。 它创建第二个(然后是n + 1个)VM,并将其添加到相同的云服务“容器”中。 看来虚拟机彼此关联。 下一个VM的名称将是2,然后是-3,依此类推,但它们还将使用相同的外部名称,例如hanselmanlinuxfarm.cloudapp.net。

I'll do this twice, each time using a different high SSH port number that will map to 22 internally. If I don't want SSH expose externally, I can delete the public endpoint later.

我将执行两次,每次使用不同的高SSH端口号(内部将映射到22)。 如果我不希望SSH从外部公开,则可以稍后再删除公共端点。

C:\> azure vm create --connect hanselmanlinuxfarm hanselmanlinuxwebfarmimage scott MyPassword --ssh 12345
info: Executing command vm create
+ Looking up image
+ Looking up cloud service
+ Getting cloud service properties
+ Looking up deployment
+ Creating VM
info: vm create command OK

When creating a Linux VM you MUST add a --ssh flag to the command line or you'll not be able to SSH into the box. Make sure to add a high port number so you'll get a mapping from that port to 22, so maybe 12346 -> 22, etc. If you make these VMs from the Portal, it will pick a random port for you. When you do it from the command line, you need to choose.

创建Linux VM时,必须在命令行中添加--ssh标志,否则将无法通过SSH进入该框中。 确保添加一个较大的端口号,这样您就可以从该端口映射到22,因此可以映射到12346-> 22,依此类推。如果从门户网站制作这些VM,它将为您选择一个随机端口。 从命令行执行此操作时,需要选择。

At this point, azure vm list says I have three. Two are ready and the last is being created now. You can tell these VMs are running in the same Cloud Service "container" because the DNS name is the same. These VMs are officially a "farm."

此时,azure vm列表显示我有三个。 两个已经准备好,最后一个正在创建中。 由于DNS名称相同,您可以告诉这些VM在相同的Cloud Service“容器”中运行。 这些VM正式是“农场”。

C:\> azure vm list
info: Executing command vm list
+ Fetching VMs
data: DNS Name VM Name Status
data: ------------------------------- -------------------- ----------
data: hanselmanlinuxfarm.cloudapp.net hanselmanlinuxfarm ReadyRole
data: hanselmanlinuxfarm.cloudapp.net hanselmanlinuxfarm-2 ReadyRole
data: hanselmanlinuxfarm.cloudapp.net hanselmanlinuxfarm-3 CreatingVM
info: vm list command OK

OK, now here's making a fourth VM from the Portal, just as an FYI.

好的,现在就像FYI一样,从Portal制作第四个VM。

创建Linux VM并从门户网站添加到服务器场 (Creating a Linux VM and adding to the Farm from the Portal)

Just so you know, you can add VMs to your farm from the Portal also.

众所周知,您也可以从Portal将VM添加到服务器场。

Now I can reuse this VM image

Give your new VM a name, then "connect it to an existing virtual machine." I don't like this phrasing, and I'm curious what you think. Basically it's "add this VM to this collection of VMs." It doesn't matter which one you select from this dropdown, as long as you pick one that's in the Cloud Service "container".

为您的新VM命名,然后“将其连接到现有虚拟机”。 我不喜欢这样的措辞,我很好奇您的想法。 基本上是“将此虚拟机添加到此虚拟机集合中”。 只要您从Cloud Service“容器”中选择一个,就从该下拉列表中选择哪个都无所谓。

Connecting to an existing VM within a Farm

I won't click OK, but if I did, at this point I've would've a fourth VM, this one via the Portal.

我不会单击“确定”,但是如果我单击“确定”,那么此时我将拥有第四个VM,即通过门户网站获得的VM。

负载平衡我Linux VM场 (Load Balancing my Linux VM Farm)

I have three identical VMs running Apache and PHP and my test.php page.

我有三个运行Apache和PHP的相同虚拟机,以及我的test.php页面。

C:\> azure vm list
info: Executing command vm list
+ Fetching VMs
data: DNS Name VM Name Status
data: ------------------------------- -------------------- ---------
data: hanselmanlinuxfarm.cloudapp.net hanselmanlinuxfarm ReadyRole
data: hanselmanlinuxfarm.cloudapp.net hanselmanlinuxfarm-2 ReadyRole
data: hanselmanlinuxfarm.cloudapp.net hanselmanlinuxfarm-3 ReadyRole

info: vm list command OK

Let me open up port 80 on all three.  Since I want them load balanced I can't do this, as this is how you map single non-load-balanced ports.

让我在所有三个端口上打开端口80。 因为我希望它们实现负载平衡,所以我不能这样做,因为这是您映射单个非负载平衡端口的方式。

azure vm endpoint create hanselmanlinuxfarm   80 80
azure vm endpoint create hanselmanlinuxfarm-2 80 80
azure vm endpoint create hanselmanlinuxfarm-3 80 80

For load balanced ports I need to use "create-multiple." Not only may I want to open multiple ports all at once, but also since I want load-balancing, I also may want a probe set up. For example, since I'm using HTTP, if there's a result other than 200 returned from test.php then I'll want that VM pulled out of the farm. It will also pull the VM out of rotation if it doesn't hear back in 30 seconds.

对于负载平衡端口,我需要使用“ create-multiple”。 我不仅可能要一次打开多个端口,而且由于我想进行负载平衡,所以我可能还需要设置一个探针。 例如,由于我使用的是HTTP,如果从test.php返回的结果不是200,那么我希望该VM从服务器场中退出。 如果在30秒内没有听到声音,还会将VM拉出旋转状态。

Here I'm creating those 80 to 80 maps, but also watching test.php for anything other than an HTTP 200.

在这里,我将创建80到80幅地图,同时还要查看test.php中除HTTP 200之外的任何内容。

azure vm endpoint create-multiple hanselmanlinuxfarm   80:80:HttpTrafficIn:http:80:/test.php
azure vm endpoint create-multiple hanselmanlinuxfarm-2 80:80:HttpTrafficIn:http:80:/test.php
azure vm endpoint create-multiple hanselmanlinuxfarm-3 80:80:HttpTrafficIn:http:80:/test.php

In this case "HttpTrafficIn" is what I am calling the Load Balancing Set Name.

在这种情况下,“ HttpTrafficIn”就是我所说的负载平衡集名称。

NOTE: I'm doing a pull request now to add the ability to see the ProbePath from the endpoint command but for now you can see it with "azure vm show" like this:

注意:我现在正在执行拉取请求,以添加从端点命令查看ProbePath的功能,但现在您可以使用“ azure vm show”看到它,如下所示:

C:\>azure vm show hanselmanlinuxfarm
info: Executing command vm show
+ Fetching VM
data: DNSName "hanselmanlinuxfarm.cloudapp.net"
data: VMName "hanselmanlinuxfarm"
data: IPAddress "100.68.xx.xx"
data: InstanceStatus "RoleStateUnknown"
data: InstanceSize "Small"
data: InstanceStateDetails ""
data: OSVersion ""
data: Image "hanselmanlinuxwebfarmimage"
data: DataDisks ""
data: Network Endpoints 0 LoadBalancedEndpointSetName "HttpTrafficIn"
data: Network Endpoints 0 LocalPort "80"
data: Network Endpoints 0 Name "endpname-80-80"
data: Network Endpoints 0 Port "80"
data: Network Endpoints 0 LoadBalancerProbe Path "/test.php"
data: Network Endpoints 0 LoadBalancerProbe Port "80"
data: Network Endpoints 0 LoadBalancerProbe Protocol "http"
data: Network Endpoints 0 Protocol "tcp"
data: Network Endpoints 0 Vip "137.135.xx.xx"
info: vm show command OK

Cool, so now let's see if I have a load-balanced farm.

太好了,现在让我们看看我是否有一个负载均衡的服务器场。

PERF NOTE: In order to get the best performance from your Azure VMs (or any cloud VM) considering putting things like MySQL/PostgreS databases on a separate disk with different caching semantics. You want the OS disk and the Data Disks to be separate. For example. I have a Windows VM running MySQL. The OS is on a standard 30 gig disk, but the MySQL Database is alone on a 5 gig disk that's attached. It keeps things separate and tidy, plus it performs better

PERF注意:为了从Azure VM(或任何云VM)获得最佳性能,请考虑将MySQL / PostgreS数据库之类的东西放在具有不同缓存语义的单独磁盘上。 您希望OS磁盘和数据磁盘分开。 例如。 我有一个运行MySQL的Windows VM。 该操作系统位于标准的30 gig磁盘上,而MySQL数据库仅位于所连接的5 gig磁盘上。 它使事情分离整洁,而且性能更好

检查我的新农场(Checking on my new Farm)

If I log into the Portal, I can look at each individual VM or I can look at the farm as if it's one 'cloud service.' Get it?

如果我登录到门户网站,则可以查看每个单独的VM,也可以查看服务器场,就好像它是一项“云服务”一样。 得到它?

My Linux Farm working as a team
All three VMs are "running"

使我的农场更加可靠 (Making my Farm more reliable)

I want to make sure my new VMs are all on different racks in the Azure Data Center. I know they are in "West US" because I put them there, but I'm not sure if they are together on the same rack or near each other or what.  Since a rack is within a "fault domain" meaning that a Rack could, I dunno, spontaneously explode, then I want to tell Azure that all these VMs are part of an "availability set." This is a name I apply to the VMs that says "make these more available by keeping them apart."

我想确保我的新VM都位于Azure数据中心的不同机架上。 我知道它们位于“美国西部”,因为我将它们放在那里,但是我不确定它们是一起放在同一机架上还是彼此靠近或处于什么位置。 由于机架位于“故障域”内,这意味着机架可能会自发爆炸,因此我想告诉Azure所有这些VM都是“可用性集”的一部分。 这是我在VM上使用的名称,上面写着“通过使它们分开来使它们可用”。

From the Portal I'm going to pick the first VM and select Configure, then Create an Availability Set. I'll name it "hanselmanlinux" but it can be anything.

我将从门户中选择第一个VM,然后选择“配置”,然后选择“创建可用性集”。 我将其命名为“ hanselmanlinux”,但可以是任何东西。

I'm making an availability set

Adding an Availability Set can involve Azure moving my VM somewhere else within the Data Center and it may need to restart it if it does. Sometimes this is fast, other times it takes a minute or 10 as it's a big deal initially, so be aware. Once everyone's in the set, it's less of a big deal.

添加可用性集可能涉及Azure将我的VM移到数据中心内的其他位置,如果需要,可能需要重新启动它。 有时这会很快,而其他时候则需要一分钟或十分钟,因为最初这很重要,所以要注意。 一旦所有人都参与其中,那就没什么大不了的了。

When it's done, head over to the other VMs and add them one at a time to the same availability set. The result looks like this in the Portal, and now I'm assured that my three VMs are all in different Fault Domains (and racks).

完成后,转到其他虚拟机,然后一次将它们添加到同一可用性集。 结果在门户中看起来像这样,现在我可以放心,我的三个VM都位于不同的故障域(和机架)中。

All my VMs are in one Availability Set now

打我的网络农场 (Hitting my Web Farm)

Now I can hit hanselmanlinuxfarm.cloudapp.net/test.php and see the IP changing (as well as the CPU% changing in my portal!) or even watch HTOP over SSH and get a live view. Hey, I've got a little Linux farm!

现在,我可以访问hanselmanlinuxfarm.cloudapp.net/test.php并查看IP的更改(以及门户中CPU%的更改!),甚至可以通过SSH观看HTOP并进行实时查看。 嘿,我有一个Linux小农场!

My tiny farm has three machines

Here's my SSH'ed into one of them, looking at htop (it's better than top!)

这是我的SSH,其中之一是htop(比top好!)

SSH'ed into a Linux machine on Azure looking at CPU time with HTOP

我的完整剧本,总结 (My Complete Script, Summarized)

Here's my complete script. I used azure vm image list | find /I "13_04" to find an Ubuntu image. I could have done this with bash as well.

这是我完整的脚本。 我使用过azure vm映像列表| 查找/ I“ 13_04”查找Ubuntu映像。 我也可以用bash做到这一点。

C:\>azure vm image list | find /i "13_04"
data: b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-13_04-amd64-server-20130423-en-us-30GB
data: b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-13_04-amd64-server-20130501-en-us-30GB
data: b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-raring-13_04-amd64-server-20130511-en-us-30GB
data: b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-raring-13_04-amd64-server-20130515-en-us-30GB
data: b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-raring-13_04-amd64-server-20130517-en-us-30GB
data: b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-raring-13_04-amd64-server-20130518-en-us-30GB
data: b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu_DAILY_BUILD-raring-13_04-amd64-server-20130521-en-us-30GB

Once I've found an image, I create my first VM from the command line in a location of my choice. Again, it's Linux, don't forget the -ssh.

找到映像后,可以从命令行在自己选择的位置创建我的第一个VM。 同样,它是Linux,请不要忘记-ssh。

azure vm create mylinuxtemplate b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-13_04-amd64-server-20130501-en-us-30GB scott MyPassword --location "West US" --ssh

Get it how you like it. SSH in, set it up, run the waagent to prep it. Shut it down and capture it.

随心所欲地获取它。 SSH输入,进行设置,运行waagent进行准备。 关闭它并捕获它。

azure vm shutdown mylinuxtemplate
azure vm capture mylinuxtemplate mylinuxfarmimage --delete

Finally, here's a basic batch file to make 5 VMs. Note the first command is different from the Nth. Of course, with bash you could make a script like "spinup 5" and automate to your heart's content. The HTTP probe is optional on the endpoint creation.

最后,这是制作5个VM的基本批处理文件。 请注意,第一个命令与第N个命令不同。 当然,使用bash,您可以制作“ spinup 5”之类的脚本,并使内容自动化。 HTTP探针在端点创建上是可选的。

azure vm create hanselmanlinuxfarm hanselmanlinuxwebfarmimage scott password --location "West US" --ssh
azure vm create --connect hanselmanlinuxfarm hanselmanlinuxwebfarmimage scott password --ssh 12345
azure vm create --connect hanselmanlinuxfarm hanselmanlinuxwebfarmimage scott password --ssh 12346
azure vm create --connect hanselmanlinuxfarm hanselmanlinuxwebfarmimage scott password --ssh 12347
azure vm create --connect hanselmanlinuxfarm hanselmanlinuxwebfarmimage scott password --ssh 12348
azure vm endpoint create-multiple hanselmanlinuxfarm 80:80:HttpTrafficInLhttp:80:/test.php
azure vm endpoint create-multiple hanselmanlinuxfarm-2 80:80:HttpTrafficInLhttp:80:/test.php
azure vm endpoint create-multiple hanselmanlinuxfarm-3 80:80:HttpTrafficInLhttp:80:/test.php
azure vm endpoint create-multiple hanselmanlinuxfarm-4 80:80:HttpTrafficInLhttp:80:/test.php
azure vm endpoint create-multiple hanselmanlinuxfarm-5 80:80:HttpTrafficInLhttp:80:/test.php

After it ran, I went in to the Portal and set up Availability Sets manually. That's only available in PowerShell today, but setting availability sets is coming soon to the cross-platform tools!

运行后,我进入门户并手动设置可用性集。 这仅在今天的PowerShell中可用,但是跨平台工具即将设置可用性集!

Next time, maybe I'll try"azure vm scale" to move these tiny VMs into 8 processor 56 gig monsters.

下次,也许我会尝试“ azure vm scale”将这些微型VM移入8个处理器的56个演出怪物中。

Sponsor: Big thanks to SoftFluent for sponsoring the feed this week! Less Plumbing, More Productivity! Generate rock-solid foundations for your .NET applications from Visual Studio and focus on what matters!

赞助商:非常感谢SoftFluent本周赞助了feed! 减少管道,提高生产率! 从Visual Studio为您的.NET应用程序打下坚实的基础,并专注于重要事项!

翻译自: https://www.hanselman.com/blog/how-to-setup-a-load-balanced-web-farm-of-virtual-machines-linux-or-otherwise-on-windows-azure-command-line

azure 虚拟机连不上

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值