Blog ala Vidar

SQL, AppFrame and other cool technologies

Monthly Archives: July 2010

Home Server

I was asked by one of my co-workers, Jan-Børge, what I recommended for a home server. This lead me to give a little talk about what I’ve done in my home-network yesterday. I’m guessing Jan-Børge isn’t the only one wanting to have a server at home to play with, so here’s my recommendations. I’m recommending two servers; one for plain home-server (backup all your PCs, have one place to put your music, videos and pictures etc) and one virtual-hosting server where you can create several virtual servers to test what ever you want. I’ve done the last one myself, where I’ve now got 5 virtual servers; Active Directory, Exchange, Home Server, Web Server and SQL Server.

First of, you of course need legal Windows licenses. The cheapest way to do this is buying your own TechNet Standard subscription. This costs $199 the first year and $149 the next years. With this you can download and install Windows 7, Office 2010, Windows Server 2008 R2, SQL Server, Exchange +++. You got 10 licenses for each OS. Now, the reason why Microsoft has this offer is for IT pro’s (and developers) to get to know Microsoft technology for testing-purposes, before buying it in the company they’re working in. Most of what I’ve tested is either already in use in Omega, or we’re planning on supporting it in some way.

Home Server Vail

If you’re going to buy a server and install Home Server, buy a 64 bit machine, and install the beta of VAIL (Home Server 2.0). It’s being released later this year, but I’ve used the beta a while now and I haven’t run into any issues yet. For hardware I’d recommend a 64 bit processor. Doesn’t matter how fast it is. The minimum requirements for RAM is 1 GB, but I’d put in 2 GB. Make sure the main board has graphics and network integrated. Other than this, just buy the cheapest you can get. I’ve got 2 x 2TB disks, but how much disk space you want is of course up to you. If you suddenly run low on disk space, just order more and plug it in. You need to click ONE button after installing the new disk(s), and it adds it to both backup-space and shared folders. Pretty neat!

After you’ve installed the server you need to connect all your computers to the server. This is done by visiting http://name-of-your-home-server/connect. After this is done, you’ll get three icons on the desktop, and the server will take backup of your computer every night. It will also check all computers if anti virus is installed and updated, anti-malware protection is on and firewall is on.

By double-clicking the Dashboard, you get to administer your home server. Here you can create new shared folders (defaults are Documents, Music, Pictures, Recorded TV, Users and Videos), do manual backups of your computers, find deleted files from your computers, administer the home server web-site and much more.

Virtual Hosting-Server

If you are going to run several virtual servers on one physical server, you need much RAM and CPU cores. The speed of each core isn’t really that important, but I’d recommend 8 GB RAM and Quad core if you’re having 4-5 virtual servers. I would also recommend big disks, and a powerful PSU, so you can add many disks etc. Other than this, buy the cheapest you get.

When it comes to software, I really recommend Windows Server 2008 R2 with Hyper-V. Managing virtual servers with Hyper-V is like eating ice-cream. It’s very easy, and everyone loves it!

Here you see my virtual servers. If I for some reason needed more RAM for the SQL Server, or maybe more CPUs, I just shut it down, right click, properties, and change memory from 1024 to 4096, and change a dropdown box from 1 CPU to 4 CPUs. Then I just click save and turn it on again. Same goes for hard disks. I can create a new file on the physical server (with the .vhd file extension) and add it to the properties of the server. VERY easy.

My Vacation

This weekend is the last in my vacation which basically means that I’m coming to Ølen again after 3 weeks of vacation. So, what have I been doing the last weeks? A lot of things! First on the priority list was the World Cup of soccer and Tour de France, but there’s a lot of “free time” from these events, especially after the World Cup was finished. I’ve of course used my vacation to be the perfect uncle, babysitting my soon to be 1 year old nephew, visiting family etc., but I’ve also used A LOT of time in front of the computer. First I reinstalled my server, playing some more with Exchange, but when that was done I had to find something else to keep me busy; Mentor

Mentor is a website that focuses on connecting people who want to learn something with people who want to teach something. We’re first focusing on .NET, SQL and related Microsoft technologies, but it would be cool if oracle and java guys were using this too! Basically what we’re trying to do is to make a site where people can register which topics (“tags”) they’re interested in and then connecting them with other people of these topics. This has been (and will be) a great opportunity for me to learn ASP.NET MVC. WAIT! Did you read wrong? Vidar doing web-development? Has hell frozen over? Not yet. I’ve just found out that MVC actually makes web-development pretty easy. If you’re interested in this topic I really recommend you watching this great session about ASP.NET MVC2 Basics Introduction by Scott Hanselman. Actually all sessions with this guy is worth recommending, because he’s a real code ninja, and he’s hilarious.

I registered Mentor at CodePlex, and got joined by Jan Leon and Arild. But with CodePlex (which is GREAT for open source projects) you don’t have full access to TFS (Team Foundation Server) and you have to publish your project within 30 days. I don’t want to publish this project as an open source project, since I don’t see the big win on this, although if anyone wants the source code I won’t mind sending it. I’ve been participating on several open source projects, and I really like the idea, but I don’t see why I should publish this. Anyhow, this is another discussion. If you REALLY want me to, contact me and we’ll discuss it. Using TFS on CodePlex whet my appetite for it, so I installed it on a server internally in Omega. I would really recommend using this instead of SVN (for the core parts of AppFrame, custom projects etc.). You can also connect to TFS using SVN with the help of SvnBridge.

Other than this I’ve created PowerPoint slides for my sessions at AppEd, and done other AppEd-planning things. I’m currently thinking of a great way of recording each session, without the session being interrupted because of the recording (software failure, people having to talk into a microphone etc.). Thinking of using Camtasia, but not sure yet. Oh, did I mention we’ve got several surprises for those attending AppEd? One clue for one of these surprises is already in this blog post; “Code Ninja”.

Apprentice

A couple of months back I signed up on a Norwegian forum to be a teacher for people who wanted to start learning programming. Last week I got my first “apprentice” which got me to start thinking about what a great idea this actually is. Why isn’t there some site out there where you can find someone to help you start programming? Or maybe get better at something you already know.

I’ve got a lot of spare time, but what we’re talking about here is a couple of mails and/or MSN-chats a week. Everyone got time for that! I’m don’t know everything about SQL Server, but I’m sure I could teach most of you a couple of things. I’ve also got experience with .NET, PHP, MySQL and many other things, but that’s a bit rusty, so I’d love to get better at least with .NET. Having someone you can just shoot questions to would be awesome. I know, there are a lot of Q&A  sites out there. I’ve started being active on StackOverflow and ServerFault.com lately, and before I’ve been on MSDN forums.

So, what I’ve been thinking of lately is, what about making a site to connect teachers and students? Maybe integrate it with StackOverflow using their API to do the Q&A-part, but have somewhat of a social site where you can find interesting articles (or videos?) about your favorite subjects, and connect with someone who’s willing to answer a couple of questions a week, to get you started with programming (or maybe a new topic like LINQ, WCF or similar).

Would you be interested in participating on such a site?
As a “teacher” you’d get a profile, adding all your feeds (blogs, youtube videos or similar), where people can vote on your feed-items, and the top articles would show on the front page (maybe just links to the original blog-post, not to “steal” any content). You’d also get to help the community, and of course kill as much time as you wanted by rating articles and being contacted by “students”.
As a “student” you’d browse through teacher’s profiles, articles and of course get in contact with someone willing to help you on your way with either starting programming, a new language or just a new feature.
As a “developer” you’d get to help me build this site

So, bottom line. You got any thoughts about this? Would you use the site? Contact me either you’ve got ideas, comments or you want to participate!

Missing Indexes

In SQL Server 2005, Microsoft introduced Dynamic Management Views and Functions (DMV/DMFs). These provides real-time data about indexes, hardware, query usage and many many other things. Using this, you can actually get suggested indexes from the SQL Server itself, that in it’s mind it would gain performance if you implemented them. So, why isn’t these generated automatically? The simple answer is disk-usage. If you implemented all these, you’d end up with A LOT of indexes, and therefore a much bigger database. So, which should you implement?

SELECT
  DENSE_RANK() OVER (ORDER BY MIGS.avg_user_impact DESC, MIG.index_handle) AS IndexRank,
  RIGHT(MID.statement, CHARINDEX('[', REVERSE(MID.statement))) AS table_name,
  MIC.column_id, MIC.column_name, MIC.column_usage,
  MIGS.unique_compiles, MIGS.user_seeks,
  MIGS.avg_total_user_cost, MIGS.avg_user_impact
    FROM sys.dm_db_missing_index_details AS MID
    CROSS APPLY sys.dm_db_missing_index_columns (MID.index_handle) AS MIC
    INNER JOIN sys.dm_db_missing_index_groups AS MIG
        ON MIG.index_handle = MID.index_handle
    INNER JOIN sys.dm_db_missing_index_group_stats AS MIGS
        ON MIG.index_group_handle = MIGS.group_handle
    WHERE statement LIKE '%atbl%'
      AND MIGS.unique_compiles > 10
    ORDER BY
      MIGS.avg_user_impact DESC,
      MIG.index_handle,
      CASE
        WHEN column_usage = 'EQUALITY' THEN 1
        WHEN column_usage = 'INEQUALITY' THEN 2
        ELSE 3
      END,
      column_id

Using this query, you get indexes, with it’s columns, ordered by the average user impact. You should consider those that have a relatively high avg_user_impact and/or avg_total_user_cost.