Sitecore and SQL Server on Linux

Posted Monday, November 28, 2016 3:03 PM by Kevin
SQL Plus Linux

So, I had a couple of hours today to play around with something and I had recently seen the news about public availability of the SQL Server on Linux preview... Short version - it seems to work with Sitecore. Of course I would never use this in a real environment (probably not even a development environment), but it is encouraging to see that all of the basic SQL Server features required by Sitecore seem to be working already. I'm kind of excited for this to get to a level that I can trust it for production sites (I really love Linux), so I'll definitely be keeping an eye on it.

Now - if you want to see this for yourself, the quickest way is to just spin up a Linux virtual machine. I downloaded Ubuntu Linux Server version 16.04.1 LTS (the LTS stands for Long Term Support) which is the version recommended by Microsoft. I used VMWare Player on my machine to create the VM and it pretty much fully automated the OS installation. Just be sure to use bridged networking if you want to access your VM from outside of the host machine (with VMware at least, the default is NAT). Your mileage may vary with other virtualization products like HyperV or Virtualbox, but Ubuntu makes installation relatively painless if you follow the on-screen prompts.

Once the VM was up and running and I was logged in to a prompt, I just followed the instructions here https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-ubuntu and... Well, it was that easy. I could connect to SQL Server from a Windows machine using SQL Server Management Studio and the sa credentials I created during installation.

Getting the Sitecore databases attached was actually really easy too. If you've done this in a Windows version of SQL Server, the process is basically the same. You just need to get the .MDF and .LDF files onto the Linux machine. For this, I installed openssh-server (from the prompt on the Ubuntu box, I typed "sudo apt-get install openssh-server") and used the scp command from the Git Bash prompt on my Windows machine (or you could use pscp.exe that comes with Putty if you prefer). There are lots of ways to get files in and out of a Linux server, but this was quick and easy for me given the tools I had at hand. So anyway, I used scp to copy the files into my home directory on the Linux server then moved those files to /var/opt/mssql/data and changed their owner to the mssql user (command was "chown mssql.mssql Sitecore*"). Then in SQL Server Management Studio, I attached the databases as per normal (note that the root of the Linux filesystem is considered C:\ by Management Studio, so my files were in C:\var\opt\mssql\data).

Then I just pointed my Sitecore ConnectionStrings.config at those databases on that server like I normally would and... Everything seemed to work!

The current SQL Server for Linux preview isn't optimized for performance and I'm sure it will be a while before we have some best practices for configuring and deploying it in production environments. And although everything I tried in Sitecore appeared to work fine, there's still a chance some SQL Server feature that doesn't yet work in Linux is required by some bit of Sitecore somewhere. So I wouldn't use this for anything serious, but it was a fun experiment just to see what would happen!

Filed under: ,

Comments

No Comments