Tag Archive: amazon

Getting Started with Amazon EC2 SQL Server 2005

Sometimes you need an offsite database server in case something goes wrong, but you can’t afford a full-blown disaster recovery datacenter.  Or maybe you’ve got some ideas that you’d like to try out with a big SQL Server 2005 box, but you don’t have the hardware sitting around idle.  Or maybe you’d just like to learn SQL Server 2005 – sure, it’s not the latest and greatest, but it’s still the most popular version out in the wild.  Now you’ve got a way to accomplish this for around $1 per hour.

With Amazon EC2, DBAs can “rent” virtual servers running Windows 2003 and SQL Server 2005.  In this article, I’ll explain the five big steps required to turn on your own SQL Server in Amazon’s datacenters.

Step 1: Understand what “cheap” SQL Server hosting costs.

As of this writing (10/2008), here’s the smallest SQL Server you can get at Amazon EC2, what’s known as a “Standard Large” configuration:

  • 7.5 GB of memory
  • 4 EC2 compute units (2 virtual cores with
  • 850 GB of storage
  • 64-bit Windows 2003
  • SQL Server 2005 Standard
  • $1.10 per hour, or roughly $800 per month

Yes, that’s a lot of money, and no, that does not include your bandwidth.  You’ll also incur some additional fees for bandwidth – probably nowhere near $100/mo, but you can use the Amazon EC2 pricing calculator to estimate your numbers.

Let me put it this way: $9 for this much power for one day is a heck of a deal.  I can do a lot of learning and experimenting for my $9.  Even if I use it as a lab box one day per week, that’s still around $40/mo – not a bad deal, especially if I’m a junior DBA who wants a sandbox to break stuff.  At $800/mo, well, we’re in Jaguar XF territory.

Step 2: Get an Amazon EC2 hosting account.

Sign up for an account at aws.amazon.com.  It’s free to enroll, but you have to link it to a method of payment like your credit card or checking account.  Your server usage will be deducted automatically from your account, so don’t blame me if you turn on a whole virtual datacenter and you can’t pay your rent.

After you’ve got the account set up, enable your account for EC2 (the virtual server hosting part) and S3 (where you can store your hard drives):

Step 3: Get the Elasticfox plugin for Firefox to manage your virtual EC2 SQL Servers.

Elasticfox is a browser-based way to manage your virtual army.  It’s free, it’s open source, and it’s the easiest way to get started with EC2.  There’s a guide on getting started with Elasticfox, but I’ll give you the highlight reel:

  • Download the Elasticfox plugin and install it
  • Launch Firefox and click Tools, Elasticfox.
  • Click the Credentials button and input your Amazon Web Services access key and secret key.  Click OK.
  • Create a key pair (to encrypt your Windows admin login) by clicking the KeyPairs tab and click the button to create a new keypair.  Type in anything for the key name, and save the certificate file.
  • Build a set of firewall rules by clicking the Security Groups tab.  In theory, you could skip this step and leave all your ports open, but come on.  Click the Create Security Group button and create a group named SQL Servers.
  • Click the Grant Permission button to set up a firewall rule.  For testing purposes, you can leave the CIDR (source) IPs at 0.0.0.0/0, which means the entire internet.  For production, you would want to restrict this access to your company’s subnet.  In the Protocol Details, set up each of these:
    • TCP/IP 3389 – remote desktop
    • TCP/IP 1433 – SQL connections (if you want to connect to your cloud-based server using SSMS on your desktop)

Step 4: Start up a virtual EC2 SQL server.

Go back to the AMIs and Instances tab and your Elasticfox screen will look something like the below screenshot (you can click on it to enlarge).  I’ve resized my columns to make it easier to see the instances I want:

Elasticfox AMI List

Elasticfox AMI List

In the screenshot, there’s an edit box at the right side where I typed in “sql” to help filter down the list of instances.  Amazon has a ton of servers available, and you have to pay close attention to get the right one.  Here’s a zoomed screenshot, and the highlighted one is the one I’ll be using:

Readthe filename carefully: the “Anon” means it’s not using the extra-charge Windows Authentication Services, and the “v1.01″ is the latest version available as of this writing (10/2008).  Newer versions mean newer patches of Windows and SQL, so the newer the better.

Right-click on the instance you want and click Launch Instance.  The next screen is full of pitfalls.

The Instance Type must be m1.large or greater.  The default is probably going to be m1.small, but that won’t work.  If you try to launch a SQL Server with m1.small, you’ll get this error:

Amazon EC2 Launch Error

Amazon EC2 Launch Error

The error says:

“EC2 responded with an error for RunInstances
InvalidParameterValue: The requested instance type’s architecture (i386) does not match the architec…”

The virtual image for SQL Server is a 64-bit machine, and you have to launch it with an InstanceType of m1.large or larger.  This catches me all the dang time.

For the KeyPair dropdown, choose the certificate name you generated, and under Security Groups, move SQL Server over into the “Launch In” group.

Click Launch, and if all goes well, your instance will show up in the “Your Instances” list in the bottom of the screen.  It takes a minute for the server to boot, but the Elasticfox screen doesn’t update on its own – you have to push the Refresh button manually to see if the server’s available.

Step 5: Connect to your new virtual EC2 SQL Server.

When the server’s State shows “running”, right-click on it and click Get Administrator Password.  Elasticfox will ask for the key pair certificate file that we created earlier.  I’ve had problems with it not always recognizing the file, so just try again and it’ll probably work.  The administrator password will be saved to your clipboard.  Windows doesn’t always allow pasting into the password field, so you may need to bring up Notepad, paste the password in there, and then look at that Notepad screen while you’re logging in.

Click on the server and click the Connect button in Elasticfox.  Elasticfox starts the Remote Desktop client and directs it to the server’s public DNS name, which is going to be something completely forgettable.  Don’t worry – if you’re planning to use this server for disaster recovery, you can assign it a permanent IP address and a better DNS name, and there’s plenty of instructions for that in the Amazon documentation.

When you start SQL Server Management Studio, you’ll either have to put in (local) for the server name to connect to, or start the SQL Server Browser service.

Before you create databases, go into Windows Explorer and take a look at your hard drive configuration:

800 GB, here I come!

800 GB, here I come!

In this screenshot, I’ve got two local drives, D and E, each with 420 GB.  Cha-ching!

From here, the world is your oyster.  You could set up database mirroring, and use this as a disaster recovery server.  Be aware that SQL 2005′s database mirroring is not compressed, so your bandwidth charges may be higher.  Instead, I’d suggest doing log shipping.  The advantage to using log shipping is that you can compress it with Quest LiteSpeed, plus you don’t necessarily have to be running the SQL Server at all times.  You can copy the files to a cheap non-SQL box at Amazon, and only start up the SQL Server once per day (or per week!) to apply the log files.  (I see a blog post coming on that after PASS when things die down.)

Another great use: testing software.  The whole reason I wrote this article today was that I had to test a new beta of Quest Change Director, and I needed a quick new environment to test it in.

I’ve got an upcoming project where I’m working with a European client on a SharePoint whitepaper, and both of us work for secure public companies with paranoid IT departments.  Neither company wants to give VPN access to the others’ staff, so instead we can just build our lab in Amazon EC2 from scratch and both access it from anywhere on the planet.  Everybody wins.

Just don’t forget to shut the server down when you’re done with it, or else you’ll keep paying by the hour!

Update 10/30Stephen Moore asked about SQL Express, and yes, they do have AMIs prebuilt with SQL Express and they start as low as $.125 per hour.  That’s a steal if you only have small databases.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

Amazon EC2 Windows support now live!

You can now spin up a virtual server in Amazon’s datacenter with Windows running.

Even better, you can spin up a fresh new SQL Server for around $1 per hour.

And of course, this comes on a day when I just told myself I wasn’t going to do anything except work on SQLServerPedia, and on a weekend when I’ve got a ton of stuff planned.  You guys will get a head start on me with this one.  I’ll definitely be all over it next week – I can’t wait to write a video tutorial on how to do database mirroring to Amazon’s datacenter.  Gosh, if only there was somewhere that I could host that training video…

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

Amazon EC2 will offer Windows hosting

A lot of cool things are happening at PDC this year, and Amazon’s already showing their cards: Amazon EC2 will offer Windows hosting.

That means you can turn on a brand new Windows machine – or ten – and pay by the hour according to the capacity you’re using.  Less than a dollar an hour in most cases.

What’s that mean for DBAs?

Let’s say you want to have a disaster recovery option for your SQL Server, but you can’t afford a full-time datacenter.  You can turn on a very low-power server in Amazon EC2, just fast enough to handle your incoming logged work, and keep it ready at all times.  When your primary server dies, you could shut down that Amazon instance, turn on a much higher-powered server, and be able to keep up with your load no matter how bulky it is – but without having to pay for that high-powered server all the time.

Or how about another scenario – log shipping.  Copy your transaction logs to Amazon S3 storage – cloud-based, by-the-gb storage – and whenever your main datacenter craters, you can turn on a new Windows box at Amazon and be running your databases from there.  Is it the best solution?  Of course not – but in a disaster, sometimes any solution is better than being completely down.

But wait, there’s more.  Say you want to do proof-of-concept development & testing, like you want to test what happens if you make a major schema change, or you want to test using SQL Server Analysis Services against your data, but your management won’t give you the money to go buy a new testbed server.  Start up a Windows machine at Amazon EC2, pay $1/hour, and do all the development you want.

That’s it – between this and Microsoft’s stuff, I’m adding a cloud category to the blog.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

Oracle announces cloud computing support

I don’t have much insight to add here, but it’s something my readers are probably into: Oracle now supports running on Amazon EC2.  They’ve got prebuilt EC2 instances that you can just turn on, a cloud management portal, and licensing options.

This is such a cool time to be a database administrator.  I can’t wait for the day where people don’t make bad architecture decisions just because they can’t afford to get a real database (and I don’t just mean Oracle by that, of course) from the get-go.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

Google App Engine: the Amazon Web Services gets a competitor

I’ve followed Amazon Web Services since its unveiling because I saw it as a really disruptive service that enabled startups to get off the ground for much less capital.

Now AWS finally has a competitor: the new Google App Engine, described in a blog entry over at the new Google App Engine Blog.  The feature list includes:

  • “Dynamic webserving, with full support of common web technologies” – for now, the only language they support is Python.
  • “Persistent storage (powered by Bigtable and GFS with queries, sorting, and transactions)”- Amazon came out of the gate without the querying, sorting and transactions, and it hurt them initially.  Web apps need databases, period.  I don’t just say that because I’m a DBA, I say that because I’ve also written (crappy) web apps.  Google’s Bigtable is obviously proven, since they use it for web indexing, but there could be a learning curve for new developers.
  • “Automatic scaling and load balancing” – to me, this is one of the two biggest feature advantages Google has over Amazon.  Amazon’s EC2 will scale, but it’s manually done, and third party companies have built solutions just to handle the scaling & load balancing.  This is the expensive part of building a .com – the infrastructure.
  • “Google APIs for authenticating users and sending email” – whoa. Sure, this is cool from a developer perspective, but think about it from a business perspective.  New web apps built on the Google App Engine will most likely use Google’s authentications, and at that point, people will be logging into the web app with Google usernames & passwords.  That means Google suddenly has deep hooks into every new web app, because the web app’s authors will be very reluctant to move their apps elsewhere.  The move would suddenly be obvious, because end users would have to log in with different usernames/passwords.  Presto, lock-in.  Brilliant move on Google’s part because they can say they’re just offering a service, and you don’t HAVE to use it.  Everybody will, and everybody will hope their awesome App Engine web app gets bought out by Google.
  • “Fully featured local development environment”

Humina humina humina – that’s a lot of power in five bullet points.

Amazon still has advantages because they’re more of a virtualization service provider than a shared web host provider.  With Amazon EC2, the developer can run servers around the clock with running processes, whereas the Google App Engine specifies that:

“Application code only runs in response to a web request, and must return response data within a few seconds. A request handler cannot spawn a sub-process or execute code after the response has been sent.”

That’s probably due to their automatic scaling and load balancing stuff – they spin up web apps on demand, and they don’t want to leave the web server running for hours on a bunch of different boxes.  Amazon has an edge here because developers can use background processes to churn through data or do queue-based stuff.  Speaking of queues, Amazon has more features than just EC2: they have Mechanical Turk, Simple Queueing Service, and now their Fulfillment Service.  They’re doing a lot more than just web hosting.

Building a pure web app?  Use Google App Engine.  Building a business with lots of moving parts?  Amazon Web Services still probably makes more sense.  Either way, it’s such an exciting time to be a developer.

The cost on all this: free for sites that host up to around 5 million page views per month.  Free.  Frrrrree.  It rolls off the tongue.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

Erika’s view of the internet

Upon viewing The Sheep Market, Erika remarked:

“People on the internet will work for nothing, and they buy everything.”

I got a good laugh out of that. It’s pretty much true, and The Sheep Market is a great piece of evidence. Aaron Koblin used Amazon’s Mechanical Turk to get 10,000 drawings of sheep at a cost of $.02 each. He’s now reselling them in 20-packs in sticker form for $20, netting him a tidy profit. Brilliant and funny idea.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

Amazon’s new virtual computing system

Amazon just announced EC2, their rent-a-datacenter plan. You build a custom virtual machine using their tools, and upload it to them. Then you can turn on that virtual machine anytime you want for a whopping ten cents per hour.

It gets even better – if you have scalability needs, like if your site suddenly becomes hugely popular, then you can turn on more machines. You just get billed ten cents per hour per machine.

There’s other costs for storage and bandwidth, but the bottom line is that the cost for a startup ebusiness just got dirt cheap. Implement your idea in a virtual machine, and you’ll be able to handle obscene growth without forking over huge money right away. You don’t have to have a lot of money tied up in a datacenter, don’t have to hire a huge infrastructure staff, etc.

This makes it even easier for your average geek to build a business without the overhead involved with finding and funding staff. It’s awesome. It’s amazing. And it works on a Mac. Gotta love that.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube