I recently “upgraded” my local server, and finally made the jump into Linux servers. I am now running Ubuntu 13.04 Server for everything from hosting to file services. As a result of this jump (and the need to still be able to develop for .Net and other MS web based services), I still needed to be able to have a SQL Server instance, and IIS 7.5.
As a result, I installed VirtualBox with Windows 2008 R2 server, configured all my networking and shared some folders from my Linux install for usage and storage purposes in my virtual machine.
Most of the reasons for doing it like this was because I did not want to make the virtual drive for the machine too large, another is so I can have my sync services run without fail.
So, my though was that I could simply attach the drive, and be able to attach any databases on it to my SQL Server instance, however, this failed miserably. The issue was permissions between the SQL Server instance and my linux box, and since you cannot have windows account, let alone windows service accounts on a linux box, I asked my good buddy over at Internet Services Inc., who happened to confirm my suspicions, but also mentioned that if I were able to install AD (active directory), or LDAP (lightweight directory access protocol), on the linux box, and make that machine the provider for all my networked machines accounts, that I should be able to do it.
So, I researched, and searched, and searched… and found that OpenLDAP is pretty difficult to install and configure. Not being much of a networking guy, I decided to expiriment a bit. I decided that if I create a user on the windows box, that matched a user on the linux box, that it may just work.
I was pleasantly supprised, and found that it did indeed work as I intended it to, however, I was not able to simply attach a database from the networked location. It just didn’t show when I browsed for it. I had to script it (below).
So, in summary, this is possible to do:
- Install LAMP with SMB services
- remember your login, you will need this later
- Share a folder on the LAMP
- Install VirtualBox
- Create a new Virtual Machine, and install Windows 2008 R2 Server on it, with SQL 2012 Server
- Note, this was done with this version, so I do not know if previous versions allow the same results
- Create a new user on the Windows Install, with the same username and password from your LAMP install
- Now, open up ‘Sql Server Configuration Manager’
- Under ‘SQL Server Services’ right-click ‘SQL Server’ and select ‘Properties’
- Under the ‘Logon’ tab, click the ‘Browse’ button next to ‘Account Name’, and find your newly created user account
- Hit ‘OK’, and let the service restart
- Run the following script
DBCC TraceOn(1807); EXEC sp_attach_db @dbname = N'YOURDATABASENAME', @filename1 = N'\192.168.2.XDB_FOLDER_LOCATIONDATABASEFILENAME.mdf', @filename2 = N'\192.168.2.XDB_FOLDER_LOCATIONDATABASELOGFILENAME.ldf'; DBCC TraceOff(1807);
- Now, fire up SMSS and verify that it is indeed attached