Linux/RHEL/CentOS

Managing SQL Server Services in Linux Environment

In the previous blog post we have seen how to Install SQL Server on Linux(CENTOS). In this post, let’s see how to manage SQL Server Services in Linux environment. After all as a DBA, we should know how to manage our database services 🙂 Let’s get started…

In Linux world, to manage services, we’ll be using command called “SYSTEMCTL“. We can check the status, stop,start,disable,enable any service running on a linux box using that command.

Syntax is very simple to remember: systemctl action ServiceName. Check this documentation for more details.
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Services.html

Verify the current status of SQL Server services:

Syntax: systemctl status mssql-server

As you can see SQL Server Service is enabled and is running. Okay, let’s stop and disable them.

Stop and Disable SQL Server services:

Syntax: sudo systemctl stop mssql-server
sudo systemctl disable mssql-server
Once this is done, check the status of SQL services(See below screenshot for all the three steps)

Now, Let’s start SQL services(Since we have disabled the services as well besides stopping, let’s enable and then start SQL)

Enable and Start SQL Server Services:

Syntax: sudo systemctl enable mssql-server
sudo systemctl start mssql-server

It successfully created syslink right after enabling the service. Then I started SQL service, Let’s check the status of the service again.

Happy SQLing on Linux 🙂 Fun Fun….

Advertisements

Microsoft Loves Linux – Installing SQL Server on Linux

In this blog post, let’s see how to Install SQL Server on Linux. It’s been a while since Microsoft announced SQL on Linux, but I thought of waiting for a while before I set this thing in my lab. With the release of SQL Server 2017 CTP 2.0, It’s about time. Okay ,so let’s get started!

Note: I’ve Centos installed in my lab. That’s where I started learning/exploring Linux. I am installing SQL Server on CentOS (Which is exactly same as RHEL). Every single command shown in this blog post should work on RHEL as well.

Step 1: Connect to Linux machine and download config/repo file using CURL command and verify if it downloaded the file.

As you can see in the above screenshot, I logged in as root user. It’s not required, in fact not recommended to ever login as root user to perform any sort of activities on linux box.(Well, I guess It’s okay sometimes If you are Linux admin and/or you absolutely understand what you are doing 🙂 ). You can just make use of sudo instead. ( As long as you are listed in sudoers file or a member of wheel group, you should be able to use sudo)

Step 2: Now we know that the file exists, lets try installing SQL using YUM Package.  I logged out of root and I am using my regular account “Sreekanth”. See below, It didn’t let me Install SQL because I didn’t have rights to use sudo.

As I mentioned above, I will be adding “Sreekanth” to wheel group by logging in as root again.

Now…logging in as “Sreekanth”, my regular user account, Let’s try it again…

Well, It works. If you notice, it says “Run sudo /opt/mssql/bin/mssql-conf setup to complete setup”…Okay let’s do that. That’s our next step.

Step 3:

This is the step where we accept license terms, set “sa” pwd …all that good stuff.

Done. That’s it guys! I am really impressed how easy it was actually to install SQL Server on Linux. It’s actually way faster than installing SQL on windows box. This entire process took less than 3 minutes for me! Wooohoooo!

Let’s check few other things before wrapping up. Let’s check the status of SQL Server service on our Linux box.

Okay…that confirms SQL service is actually Up and Running. Now, let’s open port 1433 in firewall.

Step 4: Let’s connect to this sql server instance from another client machine. (connect to IP address using the sa account which we provisioned earlier)

I see Agent XPs are disabled. Okay…let’s turn it on.

Give it a shot setting up in your own test area. Trust me, This reaaaaally feels good once you have SQL Server running on your Linux box 🙂  That’s it folks for today! Hope this blog post helps…Later.

Installing Linux (CentOS 7) on a VM.

All these days…I’ve seen my fellow Oracle/MySQL DBAs working on NIX platforms, but I haven’t really got a chance to work Full time on these machines being a SQL Server DBA. Well, with Microsoft’s recent announcement(SQL coming to Linux), I’ve decided and committed to explore Linux in depth.  “MySQL” and “Linux” are my go to technologies for my 2016 Road Map besides VMWare! I know that’s too much…but hey, there’s nothing wrong in setting goals for ourselves 🙂

So, why did I choose CentOS? Well, It’s simple….It’s free to download and a replica of RHEL(Red Hat Enterprise Linux). From my understanding, All the commands which run on CentOS should run in RHEL. Once we get the familiarity with these Operating Systems, working on any Linux/Unix machines should not be difficult. So, if you want to get started to Linux, my recommendation is to begin with CentOS.

Screenshot Tour of installing CentOS 7 on Oracle Virtual box:

Prerequisites:

Download CentOS 7.0(ISO) from their website(Just Bing it or google it).

Download Oracle VirtualBox and install on your machine. (I prefer installing it on a VM rather than creating a dual boot machine with Windows and Linux, YMMV).

Step1:

1

Step 2:

2

Step 3:

3

Step 4:

4

Step 5:

5

Step 6:

6

Step 7:

7

Step 8:

8

Step 9:

9

Step 10:

10

Step 11:

11

In the above step, you can leave it to Minimal Install if you are sure that you absolutely don’t need a GUI. I selected KDE plasma for GUI…(We can load/start OS without GUI if needed, that’s probably what I would do after couple of days)

Step 12:

12

13

Once done, it asked me to reboot the VM. Now am ready 🙂

Note: I haven’t enabled networking and didn’t installed few things. well, if I see something wrong with my setup and if it isn’t working as expected….well, I can destroy my VM and build a new one as needed in just few minutes! That’s the beauty of a Virtual machine.